Make WordPress Core


Ignore:
Timestamp:
01/18/2010 08:34:48 PM (17 years ago)
Author:
ryan
Message:

Coding standards, space after if

File:
1 edited

Legend:

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

    r12584 r12752  
    268268                return;
    269269
    270         if( ! is_blog_installed() )
     270        if ( ! is_blog_installed() )
    271271                return;
    272272
    … …  
    632632        // populate comment_count field of posts table
    633633        $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
    634         if( is_array( $comments ) )
     634        if ( is_array( $comments ) )
    635635                foreach ($comments as $comment)
    636636                        $wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
    … …  
    12001200
    12011201        // Separate individual queries into an array
    1202         if( !is_array($queries) ) {
     1202        if ( !is_array($queries) ) {
    12031203                $queries = explode( ';', $queries );
    1204                 if('' == $queries[count($queries) - 1]) array_pop($queries);
     1204                if ('' == $queries[count($queries) - 1]) array_pop($queries);
    12051205        }
    12061206
    … …  
    12111211        // Create a tablename index for an array ($cqueries) of queries
    12121212        foreach($queries as $qry) {
    1213                 if(preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
     1213                if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
    12141214                        $cqueries[trim( strtolower($matches[1]), '`' )] = $qry;
    12151215                        $for_update[$matches[1]] = 'Created table '.$matches[1];
    1216                 }
    1217                 else if(preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
     1216                } else if (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
    12181217                        array_unshift($cqueries, $qry);
    1219                 }
    1220                 else if(preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
     1218                } else if (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
    12211219                        $iqueries[] = $qry;
    1222                 }
    1223                 else if(preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
     1220                } else if (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
    12241221                        $iqueries[] = $qry;
    1225                 }
    1226                 else {
     1222                } else {
    12271223                        // Unrecognized query type
    12281224                }
    … …  
    12301226
    12311227        // Check to see which tables and fields exist
    1232         if($tables = $wpdb->get_col('SHOW TABLES;')) {
     1228        if ($tables = $wpdb->get_col('SHOW TABLES;')) {
    12331229                // For every table in the database
    1234                 foreach($tables as $table) {
     1230                foreach ($tables as $table) {
    12351231                        // If a table query exists for the database table...
    1236                         if( array_key_exists(strtolower($table), $cqueries) ) {
     1232                        if ( array_key_exists(strtolower($table), $cqueries) ) {
    12371233                                // Clear the field and index arrays
    12381234                                unset($cfields);
    … …  
    12481244
    12491245                                // For every field line specified in the query
    1250                                 foreach($flds as $fld) {
     1246                                foreach ($flds as $fld) {
    12511247                                        // Extract the field name
    12521248                                        preg_match("|^([^ ]*)|", trim($fld), $fvals);
    … …  
    12551251                                        // Verify the found field name
    12561252                                        $validfield = true;
    1257                                         switch(strtolower($fieldname))
    1258                                         {
     1253                                        switch (strtolower($fieldname)) {
    12591254                                        case '':
    12601255                                        case 'primary':
    … …  
    12701265
    12711266                                        // If it's a valid field, add it to the field array
    1272                                         if($validfield) {
     1267                                        if ($validfield) {
    12731268                                                $cfields[strtolower($fieldname)] = trim($fld, ", \n");
    12741269                                        }
    … …  
    12791274
    12801275                                // For every field in the table
    1281                                 foreach($tablefields as $tablefield) {
     1276                                foreach ($tablefields as $tablefield) {
    12821277                                        // If the table field exists in the field array...
    1283                                         if(array_key_exists(strtolower($tablefield->Field), $cfields)) {
     1278                                        if (array_key_exists(strtolower($tablefield->Field), $cfields)) {
    12841279                                                // Get the field type from the query
    12851280                                                preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
    … …  
    12871282
    12881283                                                // Is actual field type different from the field type in query?
    1289                                                 if($tablefield->Type != $fieldtype) {
     1284                                                if ($tablefield->Type != $fieldtype) {
    12901285                                                        // Add a query to change the column type
    12911286                                                        $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
    … …  
    12951290                                                // Get the default value from the array
    12961291                                                        //echo "{$cfields[strtolower($tablefield->Field)]}<br>";
    1297                                                 if(preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
     1292                                                if (preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
    12981293                                                        $default_value = $matches[1];
    1299                                                         if($tablefield->Default != $default_value)
    1300                                                         {
     1294                                                        if ($tablefield->Default != $default_value) {
    13011295                                                                // Add a query to change the column's default value
    13021296                                                                $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'";
    … …  
    13071301                                                // Remove the field from the array (so it's not added)
    13081302                                                unset($cfields[strtolower($tablefield->Field)]);
    1309                                         }
    1310                                         else {
     1303                                        } else {
    13111304                                                // This field exists in the table, but not in the creation queries?
    13121305                                        }
    … …  
    13141307
    13151308                                // For every remaining field specified for the table
    1316                                 foreach($cfields as $fieldname => $fielddef) {
     1309                                foreach ($cfields as $fieldname => $fielddef) {
    13171310                                        // Push a query line into $cqueries that adds the field to that table
    13181311                                        $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
    … …  
    13241317                                $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
    13251318
    1326                                 if($tableindices) {
     1319                                if ($tableindices) {
    13271320                                        // Clear the index array
    13281321                                        unset($index_ary);
    13291322
    13301323                                        // For every index in the table
    1331                                         foreach($tableindices as $tableindex) {
     1324                                        foreach ($tableindices as $tableindex) {
    13321325                                                // Add the index to the index data array
    13331326                                                $keyname = $tableindex->Key_name;
    … …  
    13371330
    13381331                                        // For each actual index in the index array
    1339                                         foreach($index_ary as $index_name => $index_data) {
     1332                                        foreach ($index_ary as $index_name => $index_data) {
    13401333                                                // Build a create string to compare to the query
    13411334                                                $index_string = '';
    1342                                                 if($index_name == 'PRIMARY') {
     1335                                                if ($index_name == 'PRIMARY') {
    13431336                                                        $index_string .= 'PRIMARY ';
    1344                                                 }
    1345                                                 else if($index_data['unique']) {
     1337                                                } else if($index_data['unique']) {
    13461338                                                        $index_string .= 'UNIQUE ';
    13471339                                                }
    13481340                                                $index_string .= 'KEY ';
    1349                                                 if($index_name != 'PRIMARY') {
     1341                                                if ($index_name != 'PRIMARY') {
    13501342                                                        $index_string .= $index_name;
    13511343                                                }
    13521344                                                $index_columns = '';
    13531345                                                // For each column in the index
    1354                                                 foreach($index_data['columns'] as $column_data) {
    1355                                                         if($index_columns != '') $index_columns .= ',';
     1346                                                foreach ($index_data['columns'] as $column_data) {
     1347                                                        if ($index_columns != '') $index_columns .= ',';
    13561348                                                        // Add the field to the column list string
    13571349                                                        $index_columns .= $column_data['fieldname'];
    1358                                                         if($column_data['subpart'] != '') {
     1350                                                        if ($column_data['subpart'] != '') {
    13591351                                                                $index_columns .= '('.$column_data['subpart'].')';
    13601352                                                        }
    … …  
    13621354                                                // Add the column list to the index create string
    13631355                                                $index_string .= ' ('.$index_columns.')';
    1364                                                 if(!(($aindex = array_search($index_string, $indices)) === false)) {
     1356                                                if (!(($aindex = array_search($index_string, $indices)) === false)) {
    13651357                                                        unset($indices[$aindex]);
    13661358                                                        //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
    … …  
    13871379
    13881380        $allqueries = array_merge($cqueries, $iqueries);
    1389         if($execute) {
    1390                 foreach($allqueries as $query) {
     1381        if ($execute) {
     1382                foreach ($allqueries as $query) {
    13911383                        //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
    13921384                        $wpdb->query($query);
Note: See TracChangeset for help on using the changeset viewer.