PostgreSQL-For-Wordpress / postgresql-for-wordpress

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

cannot upgrade to 4.6.1 #6

Closed david-barbion closed 12 months ago

david-barbion commented 8 years ago

There is something preventing upgrade to 4.6.1. I finally isolate the function create_lock() in wp-admin/includes/class-wp-upgrader.php.

I put a return true before the if condition. Thus, this is an unacceptable patch as it could break things, and will be deleted after the update.

However, I don't know how this is related to postgresql.

ngocphamm commented 6 years ago

I had this as well updating to 4.9. I guess it would happen to every updates.

tibetoine commented 4 years ago

Wordpress version : 5.5.1 Postgresql version : 13.x

I can confirm this issue. I went deep into the code (both wordpress and this project code).

Here is the explanation of this issue:

When Wordpress try to update, it executes the function create_lock in file 'class-wp-upgrader.php' $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO$wpdb->options(option_name,option_value,autoload) VALUES (%s, %s, 'no') /* LOCK */", $lock_option, time() ) );

this mysql request is converted to : DO $$BEGIN INSERT INTO wp2_options ( option_name, option_value, autoload ) VALUES ('core_updater.lock', '1604078344', 'no') /* LOCK */; EXCEPTION WHEN unique_violation THEN END;$$;

Problem is that this kind of request desn't seem to return any row. So result is 0.

Therefore, wordpress think this request failed ....

tibetoine commented 4 years ago

I found a solution : in file : driver_pgsql.php, replace $sql = 'DO $$BEGIN INSERT'.substr($sql, 13).'; EXCEPTION WHEN unique_violation THEN END;$$;'; by $sql = 'INSERT'.substr($sql, 13).' ON CONFLICT DO NOTHING';

mattbucci commented 12 months ago

Closed by https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress/pull/19