PostgreSQL-For-Wordpress / postgresql-for-wordpress

A maintained fork of https://wordpress.org/plugins/postgresql-for-wordpress/
GNU General Public License v2.0
228 stars 71 forks source link

Misc errors shown when upgrading wordpress (INSERT IGNORE INTO from includes/class-wp-upgrader.php) #121

Open kenreiss opened 4 months ago

kenreiss commented 4 months ago

1. driver_pgsql.php: 550:

      preg_match("/^INSERT INTO\s+`?([a-z0-9_]+)`?/i", $query, $matches);
SHOULD BE CHANGED TO:
      preg_match("/^INSERT INTO\s+[\"`]?([a-z0-9_]+)[\"`]?/i", $sql, $matches);
BECAUSE $sql is the rewritten statement. Also modified RE so " and ` are both matched when around tableName.  using $query produces errors when the original query was "INSERT IGNORE INTO"

2. driver_pgsql.php: 557:

    $GLOBALS['pg4wp_ins_id'] = $row[$primaryKey]; 
SHOULD BE wrapped with:
  if (is_array($row) && $primaryKey) {     ...    }
BECAUSE $row returns a bool WHEN original query was  "INSERT IGNORE INTO" which got changed into "ON CONFLICT DO NOTHING" and then returned empty results, since it did nothing.