Closed david-barbion closed 12 months ago
I had this as well updating to 4.9. I guess it would happen to every updates.
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 ....
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';
There is something preventing upgrade to 4.6.1. I finally isolate the function
create_lock()
inwp-admin/includes/class-wp-upgrader.php
.I put a
return true
before theif
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.