Opened 3 years ago
Closed 3 years ago
#56617 closed defect (bug) (reported-upstream)
WordPress database error when running PHPUnit tests
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.1 |
Component: | Build/Test Tools | Keywords: | has-testing-info has-patch |
Focuses: | Cc: |
Description
When running PHPUnit tests, a database error is reported before the first test is run
WordPress database error Table 'wordpress_tests.wptests_posts' doesn't exist for query SELECT wptests_posts.* FROM wptests_posts WHERE 1=1 AND ( 0 = 1 ) AND wptests_posts.post_type = 'wp_template_part' AND ((wptests_posts.post_status = 'publish')) GROUP BY wptests_posts.ID ORDER BY wptests_posts.post_date DESC made by require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, register_block_core_template_part, build_template_part_block_variations, build_template_part_block_instance_variations, get_block_templates, WP_Query->__construct, WP_Query->query, WP_Query->get_posts <div id="error"><p class="wpdberror"><strong>WordPress database error:</strong> [Table 'wordpress_tests.wptests_posts' doesn't exist]<br /><code> SELECT wptests_posts.* FROM wptests_posts WHERE 1=1 AND ( 0 = 1 ) AND wptests_posts.post_type = 'wp_template_part' AND ((wptests_posts.post_status = 'publish')) GROUP BY wptests_posts.ID ORDER BY wptests_posts.post_date DESC </code></p></div>Installing...
Bisecting indicates that this began with https://github.com/WordPress/wordpress-develop/commit/3b63a75108b7f6d5e9112c556285ab1bc80ddbcf
This seems very similar to #55632, but likely a slightly different cause.
Attachments (1)
Change History (16)
#3
@
3 years ago
- Keywords has-testing-info added
Testing Instructions
These steps define how to reproduce the issue, and indicate the expected behavior.
Steps to Reproduce
- Drop all tables in the database used for PHPUnit tests.
- 🐞 Run the test suite.
Expected Results
When testing a patch to validate it works as expected:
- ✅ There should be no database errors.
When reproducing a bug:
- ❌ There should be database errors displayed in the ticket summary above.
Test Report Icons:
🐞 <= Indicates where issue ("bug") occurs.
✅ <= Behavior is expected.
❌ <= Behavior is NOT expected.
#4
@
3 years ago
- Keywords needs-patch added
Reproduction Report
This report validates that the issue can be reproduced.
Environment
- Server: Apache (Linux)
- WordPress: 6.1-beta1-54282-src
- Browser: Chrome 105.0.0.0
- OS: Windows 10
- Theme: Twenty Twenty-Two
- Plugins: None activated
Actual Results
- ✅ Database errors in the ticket summary above are displayed. Issue reproduced.
#6
@
3 years ago
- Keywords has-patch added; needs-patch removed
56617.diff is a patch along the lines of [53306] / #55632, though it likely needs to be committed to Gutenberg first and then merged into core.
#7
@
3 years ago
FYI - this issue is breaking WP-CLI's tests, too.
@SergeyBiryukov Your patch seems sensible to me. I've put it in a PR: https://github.com/WordPress/gutenberg/pull/44584
#8
@
3 years ago
Thanks for spotting the issue and collaborating on a fix!
The Gutenberg github pull request has now been merged - https://github.com/WordPress/gutenberg/pull/44584. The PR is marked for backport to WordPress core, so I think this trac ticket can be closed.
The patch in this ticket could optionally be committed, but the file will be overwritten when Gutenberg backports happen, so it may not be worth it. I leave it up to you.
This ticket was mentioned in PR #3421 on WordPress/wordpress-develop by SergeyBiryukov.
3 years ago
#9
Trac ticket: https://core.trac.wordpress.org/ticket/56617
#10
follow-up:
↓ 11
@
3 years ago
PR 3421 is failing due to a modified version-controlled file.
Looks like this change needs to be made upstream in this file, which seems to now return an array during installation and just needs to be backported.
#11
in reply to:
↑ 10
;
follow-up:
↓ 12
@
3 years ago
Replying to costdev:
Looks like this change needs to be made upstream in this file, which seems to now return an array during installation and just needs to be backported.
Right, the change was made upstream in PR 44584, as noted in comment:8. Since the package version has not been bumped yet, the check for version-controlled file modifications fails, which I think is expected.
What I did not expect, however, is for unit tests to fail with a fatal error on PHP 8.0+, so I guess this needs more investigation.
#12
in reply to:
↑ 11
@
3 years ago
Replying to SergeyBiryukov:
What I did not expect, however, is for unit tests to fail with a fatal error on PHP 8.0+, so I guess this needs more investigation.
Ah, it looks like 56617.diff was wrong. The function needs to return an array, as pointed out by @bjorsch and @danielbachhuber. Thanks! The tests now pass on PHP 8.0+. PR 44584 should be good to backport.
SergeyBiryukov commented on PR #3421:
3 years ago
#14
Closing in favor of https://github.com/WordPress/gutenberg/pull/44584.
Just noticed that too. This is visible when unfolding the "Install WordPress" step in https://github.com/WordPress/wordpress-develop/actions/runs/3091302908/jobs/5001205357.