Make WordPress Core


Ignore:
Timestamp:
07/17/2014 09:13:53 AM (11 years ago)
Author:
DrewAPicture
Message:

Fix syntax for single- and multi-line comments in wp-admin-directory files.

See #28931.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/upgrade.php

    r29154 r29206  
    6262        update_option('default_pingback_flag', 0);
    6363
    64     // Create default user. If the user already exists, the user tables are
    65     // being shared among blogs. Just set the role in that case.
     64    /*
     65     * Create default user. If the user already exists, the user tables are
     66     * being shared among blogs. Just set the role in that case.
     67     */
    6668    $user_id = username_exists($user_name);
    6769    $user_password = trim($user_password);
     
    626628    $active_plugins = __get_option('active_plugins');
    627629
    628     // If plugins are not stored in an array, they're stored in the old
    629     // newline separated format. Convert to new format.
     630    /*
     631     * If plugins are not stored in an array, they're stored in the old
     632     * newline separated format. Convert to new format.
     633     */
    630634    if ( !is_array( $active_plugins ) ) {
    631635        $active_plugins = explode("\n", trim($active_plugins));
     
    717721    $wpdb->show_errors();
    718722
    719     // populate comment_count field of posts table
     723    // Populate comment_count field of posts table.
    720724    $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
    721725    if ( is_array( $comments ) )
     
    723727            $wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
    724728
    725     // Some alpha versions used a post status of object instead of attachment and put
    726     // the mime type in post_type instead of post_mime_type.
     729    /*
     730     * Some alpha versions used a post status of object instead of attachment
     731     * and put the mime type in post_type instead of post_mime_type.
     732     */
    727733    if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
    728734        $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
     
    881887    // < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
    882888    if ( $wp_current_db_version < 3570 ) {
    883         // Create link_category terms for link categories. Create a map of link cat IDs
    884         // to link_category terms.
     889        /*
     890         * Create link_category terms for link categories. Create a map of link
     891         * cat IDs to link_category terms.
     892         */
    885893        $link_cat_id_map = array();
    886894        $default_link_cat = 0;
     
    990998 */
    991999function upgrade_old_slugs() {
    992     // upgrade people who were using the Redirect Old Slugs plugin
     1000    // Upgrade people who were using the Redirect Old Slugs plugin.
    9931001    global $wpdb;
    9941002    $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'");
     
    13051313    global $wp_current_db_version, $wpdb;
    13061314
    1307     // Always
     1315    // Always.
    13081316    if ( is_main_network() ) {
    1309         // Deletes all expired transients.
    1310         // The multi-table delete syntax is used to delete the transient record from table a,
    1311         // and the corresponding transient_timeout record from table b.
     1317        /*
     1318         * Deletes all expired transients. The multi-table delete syntax is used
     1319         * to delete the transient record from table a, and the corresponding
     1320         * transient_timeout record from table b.
     1321         */
    13121322        $time = time();
    13131323        $sql = "DELETE a, b FROM $wpdb->sitemeta a, $wpdb->sitemeta b
     
    13191329    }
    13201330
    1321     // 2.8
     1331    // 2.8.
    13221332    if ( $wp_current_db_version < 11549 ) {
    13231333        $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
     
    14161426        return true;
    14171427    }
    1418     //didn't find it try to create it.
     1428
     1429    // Didn't find it try to create it..
    14191430    $wpdb->query($create_ddl);
    1420     // we cannot directly tell that whether this succeeded!
     1431
     1432    // We cannot directly tell that whether this succeeded!
    14211433    if ( $wpdb->get_var( $query ) == $table_name ) {
    14221434        return true;
     
    14791491        }
    14801492    }
    1481     //didn't find it try to create it.
     1493
     1494    // Didn't find it try to create it.
    14821495    $wpdb->query($create_ddl);
    1483     // we cannot directly tell that whether this succeeded!
     1496
     1497    // We cannot directly tell that whether this succeeded!
    14841498    foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
    14851499        if ($column == $column_name) {
     
    15521566    // Note: \\\ inside a regex denotes a single backslash.
    15531567
    1554     // Replace one or more backslashes followed by a single quote with
    1555     // a single quote.
     1568    /*
     1569     * Replace one or more backslashes followed by a single quote with
     1570     * a single quote.
     1571     */
    15561572    $content = preg_replace("/\\\+'/", "'", $content);
    15571573
    1558     // Replace one or more backslashes followed by a double quote with
    1559     // a double quote.
     1574    /*
     1575     * Replace one or more backslashes followed by a double quote with
     1576     * a double quote.
     1577     */
    15601578    $content = preg_replace('/\\\+"/', '"', $content);
    15611579
     
    16561674            continue;
    16571675
    1658         // Clear the field and index arrays
     1676        // Clear the field and index arrays.
    16591677        $cfields = $indices = array();
    1660         // Get all of the field names in the query from between the parens
     1678
     1679        // Get all of the field names in the query from between the parentheses.
    16611680        preg_match("|\((.*)\)|ms", $qry, $match2);
    16621681        $qryline = trim($match2[1]);
    16631682
    1664         // Separate field lines into an array
     1683        // Separate field lines into an array.
    16651684        $flds = explode("\n", $qryline);
    16661685
     1686        // todo: Remove this?
    16671687        //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
    16681688
    1669         // For every field line specified in the query
     1689        // For every field line specified in the query.
    16701690        foreach ($flds as $fld) {
    1671             // Extract the field name
     1691
     1692            // Extract the field name.
    16721693            preg_match("|^([^ ]*)|", trim($fld), $fvals);
    16731694            $fieldname = trim( $fvals[1], '`' );
    16741695
    1675             // Verify the found field name
     1696            // Verify the found field name.
    16761697            $validfield = true;
    16771698            switch (strtolower($fieldname)) {
     
    16881709            $fld = trim($fld);
    16891710
    1690             // If it's a valid field, add it to the field array
     1711            // If it's a valid field, add it to the field array.
    16911712            if ($validfield) {
    16921713                $cfields[strtolower($fieldname)] = trim($fld, ", \n");
     
    16941715        }
    16951716
    1696         // For every field in the table
     1717        // For every field in the table.
    16971718        foreach ($tablefields as $tablefield) {
    1698             // If the table field exists in the field array...
     1719
     1720            // If the table field exists in the field array ...
    16991721            if (array_key_exists(strtolower($tablefield->Field), $cfields)) {
    1700                 // Get the field type from the query
     1722
     1723                // Get the field type from the query.
    17011724                preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
    17021725                $fieldtype = $matches[1];
     
    17101733
    17111734                // Get the default value from the array
     1735                    // todo: Remove this?
    17121736                    //echo "{$cfields[strtolower($tablefield->Field)]}<br>";
    17131737                if (preg_match("| DEFAULT '(.*?)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
     
    17201744                }
    17211745
    1722                 // Remove the field from the array (so it's not added)
     1746                // Remove the field from the array (so it's not added).
    17231747                unset($cfields[strtolower($tablefield->Field)]);
    17241748            } else {
     
    17271751        }
    17281752
    1729         // For every remaining field specified for the table
     1753        // For every remaining field specified for the table.
    17301754        foreach ($cfields as $fieldname => $fielddef) {
    1731             // Push a query line into $cqueries that adds the field to that table
     1755            // Push a query line into $cqueries that adds the field to that table.
    17321756            $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
    17331757            $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
    17341758        }
    17351759
    1736         // Index stuff goes here
    1737         // Fetch the table index structure from the database
     1760        // Index stuff goes here. Fetch the table index structure from the database.
    17381761        $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
    17391762
    17401763        if ($tableindices) {
    1741             // Clear the index array
     1764            // Clear the index array.
    17421765            unset($index_ary);
    17431766
    1744             // For every index in the table
     1767            // For every index in the table.
    17451768            foreach ($tableindices as $tableindex) {
    1746                 // Add the index to the index data array
     1769
     1770                // Add the index to the index data array.
    17471771                $keyname = $tableindex->Key_name;
    17481772                $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
     
    17501774            }
    17511775
    1752             // For each actual index in the index array
     1776            // For each actual index in the index array.
    17531777            foreach ($index_ary as $index_name => $index_data) {
    1754                 // Build a create string to compare to the query
     1778
     1779                // Build a create string to compare to the query.
    17551780                $index_string = '';
    17561781                if ($index_name == 'PRIMARY') {
     
    17641789                }
    17651790                $index_columns = '';
    1766                 // For each column in the index
     1791
     1792                // For each column in the index.
    17671793                foreach ($index_data['columns'] as $column_data) {
    17681794                    if ($index_columns != '') $index_columns .= ',';
    1769                     // Add the field to the column list string
     1795
     1796                    // Add the field to the column list string.
    17701797                    $index_columns .= $column_data['fieldname'];
    17711798                    if ($column_data['subpart'] != '') {
     
    17731800                    }
    17741801                }
    1775                 // Add the column list to the index create string
     1802                // Add the column list to the index create string.
    17761803                $index_string .= ' ('.$index_columns.')';
    17771804                if (!(($aindex = array_search($index_string, $indices)) === false)) {
    17781805                    unset($indices[$aindex]);
     1806                    // todo: Remove this?
    17791807                    //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
    17801808                }
     1809                // todo: Remove this?
    17811810                //else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".$index_string."<br />".print_r($indices, true)."</pre>\n";
    17821811            }
    17831812        }
    17841813
    1785         // For every remaining index specified for the table
     1814        // For every remaining index specified for the table.
    17861815        foreach ( (array) $indices as $index ) {
    1787             // Push a query line into $cqueries that adds the index to that table
     1816            // Push a query line into $cqueries that adds the index to that table.
    17881817            $cqueries[] = "ALTER TABLE {$table} ADD $index";
    17891818            $for_update[] = 'Added index ' . $table . ' ' . $index;
    17901819        }
    17911820
    1792         // Remove the original table creation query from processing
     1821        // Remove the original table creation query from processing.
    17931822        unset( $cqueries[ $table ], $for_update[ $table ] );
    17941823    }
     
    17971826    if ($execute) {
    17981827        foreach ($allqueries as $query) {
     1828            // todo: Remove this?
    17991829            //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
    18001830            $wpdb->query($query);
     
    18481878        return false;
    18491879
    1850     // Copy files from the old locations to the site theme.
    1851     // TODO: This does not copy arbitrary include dependencies. Only the
    1852     // standard WP files are copied.
     1880    /*
     1881     * Copy files from the old locations to the site theme.
     1882     * TODO: This does not copy arbitrary include dependencies. Only the standard WP files are copied.
     1883     */
    18531884    $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
    18541885
     
    18591890            $oldpath = ABSPATH;
    18601891
    1861         if ($oldfile == 'index.php') { // Check to make sure it's not a new index
     1892        // Check to make sure it's not a new index.
     1893        if ($oldfile == 'index.php') {
    18621894            $index = implode('', file("$oldpath/$oldfile"));
    18631895            if (strpos($index, 'WP_USE_THEMES') !== false) {
    18641896                if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
    18651897                    return false;
    1866                 continue; // Don't copy anything
     1898
     1899                // Don't copy anything.
     1900                continue;
    18671901                }
    18681902        }
Note: See TracChangeset for help on using the changeset viewer.