WordPress.org

Make WordPress Core

Ticket #41335: upgrade.diff

File upgrade.diff, 1.2 KB (added by kmaxim, 4 years ago)
  • src/wp-admin/includes/upgrade.php

    diff --git src/wp-admin/includes/upgrade.php src/wp-admin/includes/upgrade.php
    index f383b3d..c158a7d 100644
    function dbDelta( $queries = '', $execute = true ) { 
    21632163
    21642164        // Create a tablename index for an array ($cqueries) of queries
    21652165        foreach ($queries as $qry) {
    2166                 if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) {
     2166                if ( preg_match( "|CREATE TABLE IF NOT EXISTS ([^ ]*)|", $qry, $matches ) ) {
    21672167                        $cqueries[ trim( $matches[1], '`' ) ] = $qry;
    2168                         $for_update[$matches[1]] = 'Created table '.$matches[1];
     2168                        $for_update[ $matches[1] ]            = 'Created table ' . $matches[1];
     2169                } elseif ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) {
     2170                        $cqueries[ trim( $matches[1], '`' ) ] = $qry;
     2171                        $for_update[ $matches[1] ]            = 'Created table ' . $matches[1];
     2172                } elseif ( preg_match( "|CREATE DATABASE IF NOT EXISTS ([^ ]*)|", $qry, $matches ) ) {
     2173                        array_unshift( $cqueries, $qry );
    21692174                } elseif ( preg_match( "|CREATE DATABASE ([^ ]*)|", $qry, $matches ) ) {
    21702175                        array_unshift( $cqueries, $qry );
    21712176                } elseif ( preg_match( "|INSERT INTO ([^ ]*)|", $qry, $matches ) ) {