Make WordPress Core

Ticket #45826: 45826.diff

File 45826.diff, 5.0 KB (added by subrataemfluence, 6 years ago)
  • wp-admin/

    diff --git wp-admin/install-helper.php wp-admin/install-helper-new.php
    index 42eb31e..ce5cc4a 100755
    old new  
    3535 */
    3636
    3737/** Load WordPress Bootstrap */
    38 require_once(dirname(dirname(__FILE__)).'/wp-load.php');
     38require_once( dirname( dirname( __FILE__ ) ).'/wp-load.php' );
    3939
    40 if ( ! function_exists('maybe_create_table') ) :
     40if ( ! function_exists( 'maybe_create_table' ) ) :
    4141/**
    4242 * Create database table, if it doesn't already exist.
    4343 *
    if ( ! function_exists('maybe_create_table') ) : 
    4949 * @param string $create_ddl Create database table SQL.
    5050 * @return bool False on error, true if already exists or success.
    5151 */
    52 function maybe_create_table($table_name, $create_ddl) {
     52function maybe_create_table( $table_name, $create_ddl ) {
    5353        global $wpdb;
    54         foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    55                 if ($table == $table_name) {
     54        foreach ( $wpdb->get_col( "SHOW TABLES",0 ) as $table ) {
     55                if ( $table == $table_name ) {
    5656                        return true;
    5757                }
    5858        }
    5959        // Didn't find it, so try to create it.
    60         $wpdb->query($create_ddl);
     60        $wpdb->query( $create_ddl );
    6161
    6262        // We cannot directly tell that whether this succeeded!
    63         foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    64                 if ($table == $table_name) {
     63        foreach ( $wpdb->get_col( "SHOW TABLES",0 ) as $table ) {
     64                if ( $table == $table_name ) {
    6565                        return true;
    6666                }
    6767        }
    function maybe_create_table($table_name, $create_ddl) { 
    6969}
    7070endif;
    7171
    72 if ( ! function_exists('maybe_add_column') ) :
     72if ( ! function_exists( 'maybe_add_column' ) ) :
    7373/**
    7474 * Add column to database table, if column doesn't already exist in table.
    7575 *
    if ( ! function_exists('maybe_add_column') ) : 
    8282 * @param string $create_ddl SQL to add column to table.
    8383 * @return bool False on failure. True, if already exists or was successful.
    8484 */
    85 function maybe_add_column($table_name, $column_name, $create_ddl) {
     85function maybe_add_column( $table_name, $column_name, $create_ddl ) {
    8686        global $wpdb;
    87         foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
     87        foreach ( $wpdb->get_col( "DESC $table_name",0 ) as $column ) {
    8888
    89                 if ($column == $column_name) {
     89                if ( $column == $column_name ) {
    9090                        return true;
    9191                }
    9292        }
    9393
    9494        // Didn't find it, so try to create it.
    95         $wpdb->query($create_ddl);
     95        $wpdb->query( $create_ddl );
    9696
    9797        // We cannot directly tell that whether this succeeded!
    98         foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
    99                 if ($column == $column_name) {
     98        foreach ( $wpdb->get_col( "DESC $table_name",0 ) as $column ) {
     99                if ( $column == $column_name ) {
    100100                        return true;
    101101                }
    102102        }
    endif; 
    116116 * @param string $drop_ddl SQL statement to drop column.
    117117 * @return bool False on failure, true on success or doesn't exist.
    118118 */
    119 function maybe_drop_column($table_name, $column_name, $drop_ddl) {
     119function maybe_drop_column( $table_name, $column_name, $drop_ddl ) {
    120120        global $wpdb;
    121         foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
    122                 if ($column == $column_name) {
     121        foreach ( $wpdb->get_col( "DESC $table_name",0 ) as $column ) {
     122                if ( $column == $column_name ) {
    123123
    124124                        // Found it, so try to drop it.
    125                         $wpdb->query($drop_ddl);
     125                        $wpdb->query( $drop_ddl );
    126126
    127127                        // We cannot directly tell that whether this succeeded!
    128                         foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
    129                                 if ($column == $column_name) {
     128                        foreach ( $wpdb->get_col( "DESC $table_name",0 ) as $column ) {
     129                                if ( $column == $column_name ) {
    130130                                        return false;
    131131                                }
    132132                        }
    function maybe_drop_column($table_name, $column_name, $drop_ddl) { 
    165165 * @param mixed  $extra      Optional. Extra value.
    166166 * @return bool True, if matches. False, if not matching.
    167167 */
    168 function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) {
     168function check_column( $table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null ) {
    169169        global $wpdb;
    170170        $diffs = 0;
    171         $results = $wpdb->get_results("DESC $table_name");
     171        $results = $wpdb->get_results( "DESC $table_name" );
    172172
    173         foreach ($results as $row ) {
     173        foreach ( $results as $row ) {
    174174
    175                 if ($row->Field == $col_name) {
     175                if ( $row->Field == $col_name ) {
    176176
    177177                        // Got our column, check the params.
    178                         if (($col_type != null) && ($row->Type != $col_type)) {
     178                        if ( ( $col_type != null ) && ( $row->Type != $col_type ) ) {
    179179                                ++$diffs;
    180180                        }
    181                         if (($is_null != null) && ($row->Null != $is_null)) {
     181                        if ( ( $is_null != null ) && ( $row->Null != $is_null ) ) {
    182182                                ++$diffs;
    183183                        }
    184                         if (($key != null) && ($row->Key  != $key)) {
     184                        if ( ( $key != null ) && ( $row->Key  != $key ) ) {
    185185                                ++$diffs;
    186186                        }
    187                         if (($default != null) && ($row->Default != $default)) {
     187                        if ( ( $default != null ) && ( $row->Default != $default ) ) {
    188188                                ++$diffs;
    189189                        }
    190                         if (($extra != null) && ($row->Extra != $extra)) {
     190                        if ( ( $extra != null ) && ( $row->Extra != $extra ) ) {
    191191                                ++$diffs;
    192192                        }
    193                         if ($diffs > 0) {
     193                        if ( $diffs > 0 ) {
    194194                                return false;
    195195                        }
    196196                        return true;