jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/367346 )
Change subject: Update Wikidata - fix several issues ...................................................................... Update Wikidata - fix several issues * fix js error on Wikidata (wikibase mobile module not found) * fix bug in quality constraints * better error messages for lua Change-Id: I220be5806341b6be0c3cf5e7aebfb8833fb67d64 --- M composer.lock M extensions/Constraints/includes/ConstraintRepository.php M extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua M extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua M extensions/Wikibase/repo/Wikibase.hooks.php M extensions/Wikibase/repo/Wikibase.php M extensions/Wikibase/repo/includes/ParserOutput/EntityParserOutputGenerator.php M extensions/Wikibase/repo/tests/phpunit/includes/RepoHooksTest.php M vendor/composer/installed.json 9 files changed, 242 insertions(+), 177 deletions(-) Approvals: Aude: Looks good to me, approved Lucas Werkmeister (WMDE): Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/composer.lock b/composer.lock index 707114b..29b06e4 100644 --- a/composer.lock +++ b/composer.lock @@ -965,7 +965,7 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseQualityConstraints", - "reference": "9d3322957304b4e8538919fc7af7d3d5ca8f9c19" + "reference": "c853576b8a173d5dcdf82aade2603e2589595e65" }, "require": { "php": ">=5.5.9", @@ -1026,7 +1026,7 @@ "support": { "issues": "https://phabricator.wikimedia.org/project/profile/1202/" }, - "time": "2017-07-20T22:41:04+00:00" + "time": "2017-07-21T19:59:47+00:00" }, { "name": "wikibase/data-model", @@ -1484,12 +1484,12 @@ "source": { "type": "git", "url": "https://github.com/wikimedia/mediawiki-extensions-Wikibase.git", - "reference": "f0cd38d5bb64efa20eca6d31b889d0a8bf7c9ed5" + "reference": "48684cef3f4fb79d517a247ddea72f2e4883d07b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/f0cd38d5bb64efa20eca6d31b889d0a8bf7c9ed5", - "reference": "f0cd38d5bb64efa20eca6d31b889d0a8bf7c9ed5", + "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/48684cef3f4fb79d517a247ddea72f2e4883d07b", + "reference": "48684cef3f4fb79d517a247ddea72f2e4883d07b", "shasum": "" }, "require": { @@ -1565,7 +1565,7 @@ "wikibaserepo", "wikidata" ], - "time": "2017-07-18T10:24:51+00:00" + "time": "2017-07-24T00:47:16+00:00" }, { "name": "wikibase/wikimedia-badges", diff --git a/extensions/Constraints/includes/ConstraintRepository.php b/extensions/Constraints/includes/ConstraintRepository.php index 29fbd93..0943baa 100644 --- a/extensions/Constraints/includes/ConstraintRepository.php +++ b/extensions/Constraints/includes/ConstraintRepository.php @@ -137,6 +137,11 @@ $constraintTypeItemId = $result->constraint_type_qid; $constraintParameters = json_decode( $result->constraint_parameters, true ); + if ( $constraintParameters === null ) { + // T171295 + $constraintParameters = []; + } + $constraints[] = new Constraint( $result->constraint_guid, PropertyId::newFromNumber( $result->pid ), diff --git a/extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua b/extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua index ff8f54c..4e50136 100644 --- a/extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua +++ b/extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua @@ -30,10 +30,12 @@ -- -- @param {table} data entity.create = function( data ) - if type( data ) ~= 'table' or type( data.schemaVersion ) ~= 'number' then - error( 'The entity data must be a table obtained via mw.wikibase.getEntityObject' ) + if type( data ) ~= 'table' then + error( 'Expected a table obtained via mw.wikibase.getEntityObject, got ' .. type( data ) .. ' instead' ) end - + if type( data.schemaVersion ) ~= 'number' then + error( 'data.schemaVersion must be a number, got ' .. type( data.schemaVersion ) .. ' instead' ) + end if data.schemaVersion < 2 then error( 'mw.wikibase.entity must not be constructed using legacy data' ) end diff --git a/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua b/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua index 1078aee..0f3cd3f 100644 --- a/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua +++ b/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua @@ -198,7 +198,7 @@ }, { name = 'mw.wikibase.entity.create 1', func = testCreate, args = { {} }, - expect = 'The entity data must be a table obtained via mw.wikibase.getEntityObject' + expect = 'data.schemaVersion must be a number, got nil instead' }, { name = 'mw.wikibase.entity.create 2', func = testCreate, type='ToString', args = { testItem }, @@ -210,7 +210,7 @@ }, { name = 'mw.wikibase.entity.create (no table)', func = testCreate, type='ToString', args = { nil }, - expect = 'The entity data must be a table obtained via mw.wikibase.getEntityObject' + expect = 'Expected a table obtained via mw.wikibase.getEntityObject, got nil instead' }, { name = 'mw.wikibase.entity.getLabel 1', func = testGetLabel, type='ToString', args = { 'de' }, diff --git a/extensions/Wikibase/repo/Wikibase.hooks.php b/extensions/Wikibase/repo/Wikibase.hooks.php index d6563a1..66c20dd 100644 --- a/extensions/Wikibase/repo/Wikibase.hooks.php +++ b/extensions/Wikibase/repo/Wikibase.hooks.php @@ -57,6 +57,22 @@ } /** + * Handler for the BeforePageDisplayMobile hook that adds the wikibase mobile styles. + * + * @param OutputPage $out + * @param Skin $skin + */ + public static function onBeforePageDisplayMobile( OutputPage &$out, Skin &$skin ) { + $title = $out->getTitle(); + $entityNamespaceLookup = WikibaseRepo::getDefaultInstance()->getEntityNamespaceLookup(); + $isEntityTitle = $entityNamespaceLookup->isEntityNamespace( $title->getNamespace() ); + + if ( $isEntityTitle ) { + $out->addModules( 'wikibase.mobile' ); + } + } + + /** * Handler for the SetupAfterCache hook, completing the content and namespace setup. * This updates the $wgContentHandlers and $wgNamespaceContentModels registries * according to information provided by entity type definitions and the entityNamespaces diff --git a/extensions/Wikibase/repo/Wikibase.php b/extensions/Wikibase/repo/Wikibase.php index 76a74c9..a5c266f 100644 --- a/extensions/Wikibase/repo/Wikibase.php +++ b/extensions/Wikibase/repo/Wikibase.php @@ -1004,6 +1004,7 @@ $wgHooks['ResourceLoaderRegisterModules'][] = 'Wikibase\RepoHooks::onResourceLoaderRegisterModules'; $wgHooks['BeforeDisplayNoArticleText'][] = 'Wikibase\ViewEntityAction::onBeforeDisplayNoArticleText'; $wgHooks['InfoAction'][] = '\Wikibase\RepoHooks::onInfoAction'; + $wgHooks['BeforePageDisplayMobile'][] = '\Wikibase\RepoHooks::onBeforePageDisplayMobile'; // update hooks $wgHooks['LoadExtensionSchemaUpdates'][] = '\Wikibase\Repo\Store\Sql\ChangesSubscriptionSchemaUpdater::onSchemaUpdate'; diff --git a/extensions/Wikibase/repo/includes/ParserOutput/EntityParserOutputGenerator.php b/extensions/Wikibase/repo/includes/ParserOutput/EntityParserOutputGenerator.php index 73b1528..0829638 100644 --- a/extensions/Wikibase/repo/includes/ParserOutput/EntityParserOutputGenerator.php +++ b/extensions/Wikibase/repo/includes/ParserOutput/EntityParserOutputGenerator.php @@ -371,10 +371,6 @@ // Then load JavaScript accordingly depending on $editable. $parserOutput->addModules( 'wikibase.ui.entityViewInit' ); $parserOutput->addModules( 'wikibase.entityPage.entityLoaded' ); - - // Load mobile styles, which have targets => mobile - // and will only be loaded on mobile devices - $parserOutput->addModules( 'wikibase.mobile' ); } /** diff --git a/extensions/Wikibase/repo/tests/phpunit/includes/RepoHooksTest.php b/extensions/Wikibase/repo/tests/phpunit/includes/RepoHooksTest.php index bcc1330..c3d0caf 100644 --- a/extensions/Wikibase/repo/tests/phpunit/includes/RepoHooksTest.php +++ b/extensions/Wikibase/repo/tests/phpunit/includes/RepoHooksTest.php @@ -11,6 +11,7 @@ use OutputPage; use ParserOutput; use RequestContext; +use SkinTemplate; use stdClass; use Title; use Wikibase\Repo\WikibaseRepo; @@ -53,6 +54,50 @@ return WikibaseRepo::getDefaultInstance()->getSettings(); } + public function onBeforePageDisplayProviderMobile() { + $wikibaseMobile = [ 'wikibase.mobile' ]; + + return [ + 'Mobile entity page' => [ + $wikibaseMobile, + true, + ], + 'Mobile non-entity page' => [ + [], + false + ], + ]; + } + + /** + * @dataProvider onBeforePageDisplayProviderMobile + */ + public function testOnBeforePageDisplayMobile( $expectedModules, $isEntityNamespace ) { + if ( $isEntityNamespace ) { + $namespace = array_values( WikibaseRepo::getDefaultInstance()->getEntityNamespaces() )[0]; + } else { + $namespace = NS_TALK; + } + + $title = $this->getMock( Title::class ); + $title->expects( $this->once() ) + ->method( 'getNamespace' ) + ->willReturn( $namespace ); + + $context = new DerivativeContext( RequestContext::getMain() ); + $context->setTitle( $title ); + + $outputPage = new OutputPage( $context ); + + $skin = $this->getMock( SkinTemplate::class ); + RepoHooks::onBeforePageDisplayMobile( + $outputPage, + $skin + ); + + $this->assertSame( $expectedModules, $outputPage->getModules() ); + } + public function testOnAPIQuerySiteInfoGeneralInfo() { $api = $this->getMockBuilder( ApiQuerySiteinfo::class ) ->disableOriginalConstructor() diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index b61ad7e..b03f473 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -600,77 +600,6 @@ ] }, { - "name": "wikibase/constraints", - "version": "dev-wmf/1.30.0-wmf.10", - "version_normalized": "dev-wmf/1.30.0-wmf.10", - "source": { - "type": "git", - "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseQualityConstraints", - "reference": "9d3322957304b4e8538919fc7af7d3d5ca8f9c19" - }, - "require": { - "php": ">=5.5.9", - "serialization/serialization": "^3.2.1", - "wikibase/data-model": "~4.2|~5.0|~6.0|~7.0", - "wikibase/data-model-serialization": "^2.0.0", - "wikibase/data-model-services": "~2.0|~3.0" - }, - "require-dev": { - "jakub-onderka/php-console-highlighter": "0.3.2", - "jakub-onderka/php-parallel-lint": "0.9.2", - "phpunit/phpunit": "~4.8", - "satooshi/php-coveralls": "master-dev", - "wikibase/wikibase-codesniffer": "^0.1.0" - }, - "time": "2017-07-20T17:32:02+00:00", - "type": "mediawiki-extension", - "installation-source": "source", - "autoload": { - "psr-4": { - "WikibaseQuality\\ConstraintReport\\": "includes/", - "WikibaseQuality\\ConstraintReport\\Api\\": "api/", - "WikibaseQuality\\ConstraintReport\\Specials\\": "specials/", - "WikibaseQuality\\ConstraintReport\\Tests\\": "tests/phpunit/", - "WikibaseQuality\\ConstraintReport\\Maintenance\\": "maintenance/" - }, - "classmap": [ - "WikibaseQualityConstraintsHooks.php", - "maintenance/UpdateConstraintsTable.php" - ] - }, - "scripts": { - "fix": [ - "phpcbf" - ], - "test": [ - "@validate --no-interaction", - "parallel-lint . --exclude vendor", - "phpcs -p -s" - ] - }, - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "BP2014N1" - } - ], - "description": "Extension for WikibaseQuality to manage constraints in Wikibase.", - "homepage": "https://www.mediawiki.org/wiki/WikidataQuality/", - "keywords": [ - "constraint", - "quality", - "trust", - "violation", - "wikibase", - "wikidata" - ], - "support": { - "issues": "https://phabricator.wikimedia.org/project/profile/1202/" - } - }, - { "name": "mediawiki/article-placeholder", "version": "dev-master", "version_normalized": "9999999-dev", @@ -1506,97 +1435,6 @@ ] }, { - "name": "wikibase/wikibase", - "version": "dev-wmf/1.30.0-wmf.10", - "version_normalized": "dev-wmf/1.30.0-wmf.10", - "source": { - "type": "git", - "url": "https://github.com/wikimedia/mediawiki-extensions-Wikibase.git", - "reference": "f0cd38d5bb64efa20eca6d31b889d0a8bf7c9ed5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/f0cd38d5bb64efa20eca6d31b889d0a8bf7c9ed5", - "reference": "f0cd38d5bb64efa20eca6d31b889d0a8bf7c9ed5", - "shasum": "" - }, - "require": { - "data-values/common": "^0.3.0", - "data-values/data-types": "^1.0.0", - "data-values/data-values": "^1.0.0", - "data-values/geo": "^2.0.1", - "data-values/interfaces": "^0.2.0|^0.1.5", - "data-values/javascript": "^0.8.3", - "data-values/number": "^0.8.3", - "data-values/serialization": "^1.2.1", - "data-values/time": "^0.8.4", - "data-values/value-view": "^0.19.2", - "diff/diff": "^2.0.0", - "php": ">=5.5.9", - "wikibase/data-model": "^7.0.0", - "wikibase/data-model-javascript": "^3.0.1", - "wikibase/data-model-serialization": "^2.1.0", - "wikibase/data-model-services": "^3.7.0", - "wikibase/internal-serialization": "^2.2.0", - "wikibase/javascript-api": "^2.2.2", - "wikibase/serialization-javascript": "^2.0.8", - "wikimedia/purtle": "^1.0.3" - }, - "conflict": { - "mediawiki/mediawiki": "<1.25" - }, - "require-dev": { - "jakub-onderka/php-console-highlighter": "0.3.2", - "jakub-onderka/php-parallel-lint": ">=0.3 <0.10", - "wikibase/wikibase-codesniffer": "^0.1.0" - }, - "time": "2017-07-18T10:24:51+00:00", - "type": "mediawiki-extension", - "installation-source": "dist", - "autoload": { - "classmap": [ - "client/WikibaseClient.hooks.php", - "client/tests/phpunit/MockClientStore.php", - "lib/includes/", - "lib/WikibaseLib.hooks.php", - "lib/maintenance/", - "repo/includes/", - "repo/maintenance/", - "repo/Wikibase.hooks.php" - ], - "psr-4": { - "Wikibase\\Client\\": "client/includes", - "Wikibase\\Client\\Tests\\": "client/tests/phpunit/includes", - "Wikibase\\DataAccess\\": "data-access/src", - "Wikibase\\DataAccess\\Tests\\": "data-access/tests/phpunit", - "Wikibase\\Lib\\": "lib/includes", - "Wikibase\\Lib\\Tests\\": "lib/tests/phpunit", - "Wikibase\\Repo\\": "repo/includes", - "Wikibase\\Repo\\Tests\\": "repo/tests/phpunit/includes", - "Wikibase\\View\\": "view/src", - "Wikibase\\View\\Tests\\": "view/tests/phpunit" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "The Wikidata team" - } - ], - "description": "Structured data repository for MediaWiki", - "homepage": "http://wikiba.se", - "keywords": [ - "wikibase", - "wikibaseclient", - "wikibaselib", - "wikibaserepo", - "wikidata" - ] - }, - { "name": "wikibase/wikimedia-badges", "version": "dev-master", "version_normalized": "9999999-dev", @@ -1777,5 +1615,167 @@ "support": { "issues": "https://phabricator.wikimedia.org/project/profile/989/" } + }, + { + "name": "wikibase/wikibase", + "version": "dev-wmf/1.30.0-wmf.10", + "version_normalized": "dev-wmf/1.30.0-wmf.10", + "source": { + "type": "git", + "url": "https://github.com/wikimedia/mediawiki-extensions-Wikibase.git", + "reference": "48684cef3f4fb79d517a247ddea72f2e4883d07b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/48684cef3f4fb79d517a247ddea72f2e4883d07b", + "reference": "48684cef3f4fb79d517a247ddea72f2e4883d07b", + "shasum": "" + }, + "require": { + "data-values/common": "^0.3.0", + "data-values/data-types": "^1.0.0", + "data-values/data-values": "^1.0.0", + "data-values/geo": "^2.0.1", + "data-values/interfaces": "^0.2.0|^0.1.5", + "data-values/javascript": "^0.8.3", + "data-values/number": "^0.8.3", + "data-values/serialization": "^1.2.1", + "data-values/time": "^0.8.4", + "data-values/value-view": "^0.19.2", + "diff/diff": "^2.0.0", + "php": ">=5.5.9", + "wikibase/data-model": "^7.0.0", + "wikibase/data-model-javascript": "^3.0.1", + "wikibase/data-model-serialization": "^2.1.0", + "wikibase/data-model-services": "^3.7.0", + "wikibase/internal-serialization": "^2.2.0", + "wikibase/javascript-api": "^2.2.2", + "wikibase/serialization-javascript": "^2.0.8", + "wikimedia/purtle": "^1.0.3" + }, + "conflict": { + "mediawiki/mediawiki": "<1.25" + }, + "require-dev": { + "jakub-onderka/php-console-highlighter": "0.3.2", + "jakub-onderka/php-parallel-lint": ">=0.3 <0.10", + "wikibase/wikibase-codesniffer": "^0.1.0" + }, + "time": "2017-07-24T00:47:16+00:00", + "type": "mediawiki-extension", + "installation-source": "dist", + "autoload": { + "classmap": [ + "client/WikibaseClient.hooks.php", + "client/tests/phpunit/MockClientStore.php", + "lib/includes/", + "lib/WikibaseLib.hooks.php", + "lib/maintenance/", + "repo/includes/", + "repo/maintenance/", + "repo/Wikibase.hooks.php" + ], + "psr-4": { + "Wikibase\\Client\\": "client/includes", + "Wikibase\\Client\\Tests\\": "client/tests/phpunit/includes", + "Wikibase\\DataAccess\\": "data-access/src", + "Wikibase\\DataAccess\\Tests\\": "data-access/tests/phpunit", + "Wikibase\\Lib\\": "lib/includes", + "Wikibase\\Lib\\Tests\\": "lib/tests/phpunit", + "Wikibase\\Repo\\": "repo/includes", + "Wikibase\\Repo\\Tests\\": "repo/tests/phpunit/includes", + "Wikibase\\View\\": "view/src", + "Wikibase\\View\\Tests\\": "view/tests/phpunit" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "The Wikidata team" + } + ], + "description": "Structured data repository for MediaWiki", + "homepage": "http://wikiba.se", + "keywords": [ + "wikibase", + "wikibaseclient", + "wikibaselib", + "wikibaserepo", + "wikidata" + ] + }, + { + "name": "wikibase/constraints", + "version": "dev-wmf/1.30.0-wmf.10", + "version_normalized": "dev-wmf/1.30.0-wmf.10", + "source": { + "type": "git", + "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseQualityConstraints", + "reference": "c853576b8a173d5dcdf82aade2603e2589595e65" + }, + "require": { + "php": ">=5.5.9", + "serialization/serialization": "^3.2.1", + "wikibase/data-model": "~4.2|~5.0|~6.0|~7.0", + "wikibase/data-model-serialization": "^2.0.0", + "wikibase/data-model-services": "~2.0|~3.0" + }, + "require-dev": { + "jakub-onderka/php-console-highlighter": "0.3.2", + "jakub-onderka/php-parallel-lint": "0.9.2", + "phpunit/phpunit": "~4.8", + "satooshi/php-coveralls": "master-dev", + "wikibase/wikibase-codesniffer": "^0.1.0" + }, + "time": "2017-07-21T11:21:34+00:00", + "type": "mediawiki-extension", + "installation-source": "source", + "autoload": { + "psr-4": { + "WikibaseQuality\\ConstraintReport\\": "includes/", + "WikibaseQuality\\ConstraintReport\\Api\\": "api/", + "WikibaseQuality\\ConstraintReport\\Specials\\": "specials/", + "WikibaseQuality\\ConstraintReport\\Tests\\": "tests/phpunit/", + "WikibaseQuality\\ConstraintReport\\Maintenance\\": "maintenance/" + }, + "classmap": [ + "WikibaseQualityConstraintsHooks.php", + "maintenance/UpdateConstraintsTable.php" + ] + }, + "scripts": { + "fix": [ + "phpcbf" + ], + "test": [ + "@validate --no-interaction", + "parallel-lint . --exclude vendor", + "phpcs -p -s" + ] + }, + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "BP2014N1" + } + ], + "description": "Extension for WikibaseQuality to manage constraints in Wikibase.", + "homepage": "https://www.mediawiki.org/wiki/WikidataQuality/", + "keywords": [ + "constraint", + "quality", + "trust", + "violation", + "wikibase", + "wikidata" + ], + "support": { + "issues": "https://phabricator.wikimedia.org/project/profile/1202/" + } } ] -- To view, visit https://gerrit.wikimedia.org/r/367346 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I220be5806341b6be0c3cf5e7aebfb8833fb67d64 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikidata Gerrit-Branch: wmf/1.30.0-wmf.10 Gerrit-Owner: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com> Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> Gerrit-Reviewer: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits