Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#56617 closed defect (bug) (reported-upstream)

WordPress database error when running PHPUnit tests

Reported by: bjorsch's profile bjorsch 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 &#039;wordpress_tests.wptests_posts&#039; doesn&#039;t exist]<br /><code>
			SELECT   wptests_posts.*
			FROM wptests_posts 
			WHERE 1=1  AND ( 
  0 = 1
) AND wptests_posts.post_type = &#039;wp_template_part&#039; AND ((wptests_posts.post_status = &#039;publish&#039;))
			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)

56617.diff (572 bytes) - added by SergeyBiryukov 3 years ago.

Download all attachments as: .zip

Change History (16)

#1 @Chouby
3 years ago

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.

#2 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 6.1

#3 @costdev
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

  1. Drop all tables in the database used for PHPUnit tests.
  2. 🐞 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 @costdev
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.

#5 @SergeyBiryukov
3 years ago

Introduced in [54257].

@SergeyBiryukov
3 years ago

#6 @SergeyBiryukov
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 @danielbachhuber
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 @talldanwp
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.

#10 follow-up: @costdev
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.

Last edited 3 years ago by costdev (previous) (diff)

#11 in reply to: ↑ 10 ; follow-up: @SergeyBiryukov
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 @SergeyBiryukov
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.

#13 @SergeyBiryukov
3 years ago

#56777 was marked as a duplicate.

#15 @desrosj
3 years ago

  • Milestone 6.1 deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

I'm closing this one as reported-upstream. The fix has been merged into the Gutenberg repo in GB-44584. The change is within one of the @wordpress npm packages, so this will get fixed when the next sync happens in #56467.

Note: See TracTickets for help on using tickets.