Skip to content

Bugfix/wp upgrader#10356

Closed
todeveni wants to merge 6 commits intoWordPress:trunkfrom
todeveni:bugfix/wp-upgrader
Closed

Bugfix/wp upgrader#10356
todeveni wants to merge 6 commits intoWordPress:trunkfrom
todeveni:bugfix/wp-upgrader

Conversation

@todeveni
Copy link

Check for correct return value in create_lock() in lock creating query.
wpdb::query() returns 0 when there are no rows affected, eg. the lock already exists and no INSERT was performed.

Add two tests for WP_upgrader::create_lock()

Trac ticket: https://core.trac.wordpress.org/ticket/64080


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

github-actions bot commented Oct 20, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props skithund, westonruter, afragen.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@todeveni
Copy link
Author

@westonruter Thanks for review/suggestions! Changed as suggested

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried running the new unit tests here but without the change to src/wp-admin/includes/class-wp-upgrader.php. The result is they still pass. I think the tests need to recreate the error scenario to demonstrate that the change to the create_lock method fixes something.

@westonruter
Copy link
Member

Oh, but:

This doesn't happen at least on current release of MariaDB and PHP 8.4.

And I'm running MySQL.

$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'off') /* LOCK */", $lock_option, time() ) );

if ( ! $lock_result ) {
if ( 0 === $lock_result ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've chatted with @afragen about this. We're unsure how this actually makes a chance. If the query method “returns an integer value indicating the number of rows affected/selected” then a value of zero is just as falsy as false, so the result would be the same?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the actual return value from MariaDB if no matching row is found?

What I found in searching was it returns an empty set but I don't know the exact syntax of it. It's possible that that could be the difference.

Copy link
Member

@afragen afragen Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are instances in WPDB::query() where the return value is false and 0 !== false. While this gives the expected result it seems sloppy as the return is an actual boolean.

@afragen
Copy link
Member

afragen commented Oct 27, 2025

I asked @costdev to take a look and here are his thoughts.

1. The code performs the same whether `wpdb::query()` returns `0` or `false`.
2. The PR doesn't solve a problem.
3. However, the PR introduces a BC break: When `wpdb::query()` returns `false`, Core will go through checks and possibly release the lock. The PR guarantees that `false` will never cause a released lock.
4. The first test's docblock has no `@ticket`.
5. The second test's code doesn't make clear what it's actually doing, and there are 3 `assertTrue()` calls but only one has a third `$message` argument to explain what went wrong if the assertion fails.
6. There's no bug reproduction on the ticket to prove the bug is one in Core, nor to narrow it down to a cause.

IMO: The bug should actually be reproduced and confirmed to be a Core bug, and the cause is narrowed down. I appreciate that Toni did work on this, including adding tests, but it's too early as demonstrated by the PRs ineffectiveness and introduction of a BC break in Core

@todeveni
Copy link
Author

Closing, since the actual bug is in caching and different approach is needed.

@todeveni todeveni closed this Oct 27, 2025
@todeveni todeveni deleted the bugfix/wp-upgrader branch October 27, 2025 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants