[wp-trac] [WordPress Trac] #39327: Database connection errors in unit tests on 4.7
WordPress Trac
noreply at wordpress.org
Thu Jan 5 14:27:41 UTC 2017
#39327: Database connection errors in unit tests on 4.7
------------------------------------------+---------------------
Reporter: rmccue | Owner: pento
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 4.7.1
Component: Build/Test Tools | Version: 4.7
Severity: normal | Resolution: fixed
Keywords: has-patch commit fixed-major | Focuses:
------------------------------------------+---------------------
Comment (by jdgrimes):
I think this also [https://github.com/WordPoints/wordpoints/issues/595
caused issues] in one of my plugin's unit tests. I have `backupGlobals`
set to false, too. The errors were like:
{{{
WordPress Database Error: Table 'wptests_test' already exists [CREATE
TEMPORARY TABLE `wptests_test` ( `id` BIGINT );]
}}}
Which was coming from some tests where a table gets created. Previously,
the table would be automatically dropped after the test was done, because
it was temporary. Then it could be created again as part of the next test.
However, now apparently a single DB session is being used throughout the
tests, which means that the temporary tables persist between tests now.
The fix is to either drop the tables manually, or else reset the
connection in `tearDown()` (`$wpdb->close(); $wpdb->db_connect()`).
(Calling `$wpdb->db_connect()` in `setUp()` as @mnelson4 is doing would
probably also work.)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39327#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list