-
Notifications
You must be signed in to change notification settings - Fork 21
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
WordPress 6.7 Compatibility: Avoid errors in the database where a TEXT type can't have a default value #2667
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2667 +/- ##
============================================
+ Coverage 62.7% 65.4% +2.8%
- Complexity 0 4596 +4596
============================================
Files 319 474 +155
Lines 5074 19268 +14194
Branches 1231 0 -1231
============================================
+ Hits 3180 12610 +9430
- Misses 1721 6658 +4937
+ Partials 173 0 -173
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…nit Tests." This reverts commit e75eb99.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this issue. Although can you clarify how you are running into the error?
I'm not able to reproduce it locally as I run a newer version of MariaDB which supports defaults for text columns. Checking on some of the GH action runs it also seems like it's not running into the issue.
Like in this run here: https://github.com/woocommerce/google-listings-and-ads/actions/runs/11701884828/job/32588901868
It's using WP6.7 RC3:
download https://wordpress.org/wordpress-6.7-RC3.tar.gz /tmp/wordpress.tar.gz
But it's also using a newer version of MySQL (which supports defaults for text columns):
mysql Ver 8.0.39-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
So if the error is coming from MySQL I'm just wondering how this is specifically related to WP 6.7 and wouldn't occur in older versions of WP? I'm also not finding anything in WP 6.7 that made these checks stricter.
Anyways I am approving the PR as it would allow it to support older MySQL versions (not recommended but still supported).
I tested the PR with the change, and as you mentioned the categories
column is always passed as an empty string so there are no compatibility problems.
Hi @mikkamp, thanks for the review!
Originally, I haven't reproduced the issue locally either. After changing my local DB to MySQL 8.0.39, I can reproduce it.
It was firstly noticed on GitHub Actions. After testing with different combinations of WP and WC versions, the error occurs when using WordPress 6.7-RC3. It won't make the testing fail but only output error messages: https://github.com/woocommerce/google-listings-and-ads/actions/runs/11701884828/job/32588901868#step:6:29 After further research, it appears that WordPress 6.7 changed CREATE TABLE `wp_gla_attribute_mapping_rules` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`attribute` varchar(255) NOT NULL,
`source` varchar(100) NOT NULL,
`category_condition_type` varchar(10) NOT NULL,
`categories` text DEFAULT '',
PRIMARY KEY `id` (`id`)
); In the original loose comparison, the logical comparison matched from the ALTER TABLE wp_gla_attribute_mapping_rules ALTER COLUMN `categories` SET DEFAULT ''; Therefore, I believe this PR could be categorized as a WordPress 6.7 compatibility adjustment. |
Thanks for the clarification, that makes sense. I was looking for actual failures in the test runs, but I can see the output mixed in with the test results now. |
Changes proposed in this Pull Request:
There are database errors when running PHP Unit Tests with WordPress 6.7-RC3.
Considering the null
categories
will be sanitized to''
before inserting it into database, it may not be an issue to change thecategories
column in thegla_attribute_mapping_rules
table to:google-listings-and-ads/src/DB/Query/AttributeMappingRulesQuery.php
Lines 42 to 44 in 4535b71
Screenshots:
📷 Before
📷 After
Detailed test instructions:
Changelog entry