Plugin Directory

Changeset 429271


Ignore:
Timestamp:
08/26/2011 11:12:33 PM (15 years ago)
Author:
hawk__
Message:

Changed the way $wpdb is used to avoid some cases were it would be used undefined

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postgresql-for-wordpress/trunk/pg4wp/driver_pgsql.php

    r429260 r429271  
    123123        }
    124124        global $wpdb;
     125       
    125126        $logto = 'queries';
    126127        // This is used to catch the number of rows returned by the last "SELECT" REQUEST
     
    198199            $sql = str_replace( 'post_date_gmt > 1970', 'post_date_gmt > to_timestamp (\'1970\')', $sql);
    199200           
     201            // Akismet sometimes doesn't write 'comment_ID' with 'ID' in capitals where needed ...
     202            if( false !== strpos( $sql, $wpdb->comments))
     203                $sql = str_replace(' comment_id ', ' comment_ID ', $sql);
     204           
    200205        } // SELECT
    201206        elseif( 0 === strpos($sql, 'UPDATE'))
     
    227232           
    228233            // Fix inserts into wp_categories
    229             if( false !== strpos($sql, 'INSERT INTO '.$wpdb->prefix.'categories'))
     234            if( false !== strpos($sql, 'INSERT INTO '.$wpdb->categories))
    230235            {
    231236                $sql = str_replace('"cat_ID",', '', $sql);
     
    237242           
    238243            // Multiple values group when calling INSERT INTO don't always work
    239             if( false !== strpos( $sql, $wpdb->prefix.'options') && false !== strpos( $sql, '), ('))
     244            if( false !== strpos( $sql, $wpdb->options) && false !== strpos( $sql, '), ('))
    240245            {
    241246                $pattern = '/INSERT INTO.+VALUES/';
     
    276281            // This handles removal of duplicate entries in table options
    277282            if( false !== strpos( $sql, 'DELETE o1 FROM '))
    278                 $sql = "DELETE FROM ${table_prefix}options WHERE option_id IN " .
    279                     "(SELECT o1.option_id FROM ${table_prefix}options AS o1, ${table_prefix}options AS o2 " .
     283                $sql = "DELETE FROM $wpdb->options WHERE option_id IN " .
     284                    "(SELECT o1.option_id FROM $wpdb->options AS o1, $wpdb->options AS o2 " .
    280285                    "WHERE o1.option_name = o2.option_name " .
    281286                    "AND o1.option_id < o2.option_id)";
     287           
     288            // Akismet sometimes doesn't write 'comment_ID' with 'ID' in capitals where needed ...
     289            if( false !== strpos( $sql, $wpdb->comments))
     290                $sql = str_replace(' comment_id ', ' comment_ID ', $sql);
    282291        }
    283292        // Fix tables listing
     
    318327        // Remove illegal characters
    319328        $sql = str_replace('`', '', $sql);
    320        
    321         // Akismet sometimes doesn't write 'comment_ID' with 'ID' in capitals where needed ...
    322         if( false !== strpos( $sql, $wpdb->prefix.'comments'))
    323             $sql = str_replace(' comment_id ', ' comment_ID ', $sql);
    324329       
    325330        // Field names with CAPITALS need special handling
     
    376381        $GLOBALS['pg4wp_result'] = pg_query($sql);
    377382        if( (PG4WP_DEBUG || PG4WP_LOG_ERRORS) && $GLOBALS['pg4wp_result'] === false && $err = pg_last_error())
    378             if( false === strpos($err, 'relation "'.$wpdb->prefix.'options"'))
     383            if( false === strpos($err, 'relation "'.$wpdb->options.'"'))
    379384                error_log("Error running :\n$initial\n---- converted to ----\n$sql\n----\n$err\n---------------------\n", 3, PG4WP_LOG.'pg4wp_errors.log');
    380385       
Note: See TracChangeset for help on using the changeset viewer.