-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Fix product attributes lookup data and filter by attribute widget with non-ASCII named attributes #34432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix product attributes lookup data and filter by attribute widget with non-ASCII named attributes #34432
Conversation
The issue manifested when the product attributes lookup table was enabled. - In PHP 8, saving a variable product with an attribute whose name contains non-ASCII characters threw an error. - In PHP 7, no error, but the lookup table was filled with entries for all the existing terms of the attribute, not just those used for variations. This resulted in the filter by attribute widget being rendered incorrectly.
Test Results SummaryCommit SHA: cccad0c
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
|
Note to self: confirm if this also resolves #33971. |
|
Hi @Konamiman 👋 I was able to replicate the problem and the fix works as described (no fatal error, and the attribute/term counts are accurate).
☝🏽 However, as you can see in the above screenshot it appears that filtering doesn't work for these non-ASCII terms (see also the issue I referenced in my earlier comment).
|
|
Optional thought: thinking of the fatal error, I wonder if a safeguard should be applied here to check for WP_Errors? |
|
@barryhughes It's highly wtf that I didn't think of testing if the filters actually worked 🤦🏻♂️ I think that since one has the same root cause and it makes sense to fix it in this same pull request. As for the table regeneration on update, yes, I think we could do that only if there are references to non-ASCII attributes in the lookup table (it's as simple as checking if the table has values with EDIT: The filters are working as expected for me. Does your url look like |
|
@barryhughes About the safeguard: that makes sense too, but I'm not sure what could we do in this case as the taxonomy is expected to exist at that point and if its id/slug pair can't be obtained then the entire feature is broken. |
|
I have found that the old WooCommerce "Filter by attribute" widget filters just fine, but the new blocks based widget not only doesn't, but also displays incorrect counts: The incorrect count might to be caused by the fact that the blocks code is accessing the terms table directly, instead of doing As for the incorrect filtering, it's likely caused by how the request url is constructed: Old widget: |
|
At this point I think we are happy to move forward without the migration and the further issue with the block-based widget is something we'll create a new issue for (so the relevant team can take a look at that). On that basis, I think this is good to merge ... just pausing to check with you first of all (@Konamiman) before actually hitting 'merge' (to ensure my understanding is correct). |
|
@barryhughes I agree. The incorrect lookup table entries will affect only shops who meet all of:
I'd say that while the number of affected shops might not be negligible, it's certainly not going to be the majority of them, so a migration for everyone could be conterproductive. Anyway I'm merging from trunk to make the warnings about the Yodas disappear. 🙁 After that I'd say we're good to merge. |




All Submissions:
Changes proposed in this Pull Request:
This pull request fixes three bugs related to the product attributes lookup table that were apparent when using an attribute with non-ASCII characters for variations:
The lookup table will require regeneration, at least for the affected products, after applying this fix.
How to test the changes in this Pull Request:
Other information:
pnpm changelog add --filter=<project>?FOR PR REVIEWER ONLY: