Page MenuHomePhabricator

[WikibaseMediaInfo] test fails with PHPUnit 6
Open, Needs TriagePublic

Description

WikibaseMediaInfo fails a tests when run under PHPUnit 6. The suite attempts to insert a page with page_id=2 but there is already a page with that id which causes a 1062 Duplicate entry '2' for key 'PRIMARY'.

There was 1 error:

1) Wikibase\MediaInfo\Tests\MediaWiki\Maintenance\CreatePagePropsTest::testDBUpdates
   with data set #0 (
   array(
     array(2, 6, 'File.jpg', '', 0, 1, 0, '20180625104925', '20180625104925', 0, 213, 'wikitext', null),
     array(3, 6, 'File2.jpg', '', 0, 1, 0, '20180625104925', '20180625104925', 0, 213, 'wikitext', null)
   ),
   array())
Wikimedia\Rdbms\DBQueryError: 
Query:
INSERT  INTO `unittest_page` 
    (page_id,page_namespace,page_title,page_restrictions,page_is_redirect,page_is_new,page_random,page_touched,page_links_updated,page_latest,page_len,page_content_model,page_lang)
VALUES
    ('2','6','File.jpg','','0','1','0','20180625104925','20180625104925','0','213','wikitext',NULL),
    ('3','6','File2.jpg','','0','1','0','20180625104925','20180625104925','0','213','wikitext',NULL)

Function: Wikimedia\Rdbms\Database::insert
Error: 1062 Duplicate entry '2' for key 'PRIMARY' (localhost:/tmp/quibble-mysql-821zo5jf/socket)

/workspace/src/includes/libs/rdbms/database/Database.php:1443
/workspace/src/includes/libs/rdbms/database/Database.php:1413
/workspace/src/includes/libs/rdbms/database/Database.php:1186
/workspace/src/includes/libs/rdbms/database/Database.php:2010
/workspace/src/extensions/WikibaseMediaInfo/tests/phpunit/mediawiki/Maintenance/CreatePagePropsTest.php:114
/workspace/src/tests/phpunit/MediaWikiTestCase.php:469
/workspace/src/maintenance/doMaintenance.php:94

Repro: check experimental on dummy change: https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/WikibaseMediaInfo/+/441778/

Event Timeline

hashar created this task.Jun 26 2018, 11:18 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 26 2018, 11:18 AM

A wild guess is that it might be related to PHPUnit data providers. https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/WikibaseLexeme/+/450044/ / T200693

@Addshore would you have time to look into that WikibaseMediaInfo weird failure please ? :]

A wild guess is that it might be related to PHPUnit data providers. https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/WikibaseLexeme/+/450044/ / T200693
@Addshore would you have time to look into that WikibaseMediaInfo weird failure please ? :]

Looks like it could be something similar to the thing you linked.

CreatePagePropsTest::provideDBUpdatesData

Runs the following:

	protected function newPageId() {
		static $pageId;
		if ( $pageId === null ) {
			$db = wfGetDB( DB_REPLICA );
			$pageId = (int)$db->selectField( 'page', 'MAX(page_id) + 1' );
		} else {
			$pageId++;
		}

		return $pageId;
	}

Doing this in the provider / doing any db interaction in the provider is evil

CI now fails due to an unrelated Selenium test (WikibaseLexeme). Locally I can not reproduce the issue anymore .... That is a mystery.

So it might not be much of an issue. But surely the data provider should not interact with the database. I think we have addDBData() for that?

Addshore moved this task from incoming to monitoring on the Wikidata board.Sep 18 2018, 2:34 PM