WikidataBuilder has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/392810 )
Change subject: New Wikidata Build - 2017-11-22T10:00:01+0000 ...................................................................... New Wikidata Build - 2017-11-22T10:00:01+0000 Change-Id: Ie7646f107a8a5696b8d27e0fb56e18d8f728cd84 --- M composer.lock M extensions/Constraints/WikibaseQualityConstraintsHooks.php M extensions/Constraints/api/CheckConstraints.php M extensions/Constraints/composer.json M extensions/Constraints/extension.json M extensions/Constraints/includes/ConstraintCheck/Cache/CachedEntityIds.php M extensions/Constraints/includes/ConstraintCheck/Checker/CommonsLinkChecker.php M extensions/Constraints/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php M extensions/Constraints/includes/ConstraintCheck/Checker/FormatChecker.php M extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php M extensions/Constraints/includes/ConstraintCheck/Helper/ConnectionCheckerHelper.php M extensions/Constraints/includes/ConstraintCheck/Helper/ConstraintParameterParser.php M extensions/Constraints/includes/ConstraintCheck/Helper/SparqlHelper.php M extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php M extensions/Constraints/includes/ConstraintCheck/ItemIdSnakValue.php M extensions/Constraints/includes/ConstraintRepository.php M extensions/Constraints/sql/create_wbqc_constraints.sql M extensions/Constraints/tests/phpunit/Api/CheckConstraintsTest.php D extensions/Constraints/tests/phpunit/Checker/RangeChecker/P1.json D extensions/Constraints/tests/phpunit/Checker/RangeChecker/P2.json M extensions/Constraints/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php M extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php M extensions/Constraints/tests/phpunit/ConstraintRepositoryTest.php M extensions/Constraints/tests/phpunit/ConstraintTest.php M extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php M extensions/Constraints/tests/phpunit/Job/UpdateConstraintsTableJobTest.php M extensions/Constraints/tests/phpunit/SparqlHelperMock.php M extensions/Constraints/tests/phpunit/Specials/SpecialConstraintReportTest.php M extensions/Wikibase/repo/includes/Diff/EntityContentDiffView.php M extensions/Wikibase/repo/tests/phpunit/includes/Actions/HistoryEntityActionTest.php M vendor/composer/installed.json 31 files changed, 123 insertions(+), 116 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikidata refs/changes/10/392810/1 diff --git a/composer.lock b/composer.lock index 66786dd..f7ba962 100644 --- a/composer.lock +++ b/composer.lock @@ -855,7 +855,7 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseQualityConstraints", - "reference": "76ce6bbc877d0d5ef799dd5ea62ec45274a49928" + "reference": "1aa44d3f7ef2e7817a41d437cd898fa303bedc4b" }, "require": { "php": ">=5.5.9", @@ -875,8 +875,8 @@ "type": "mediawiki-extension", "scripts": { "fix": [ - "phpcbf", - "minus-x fix ." + "minus-x fix .", + "phpcbf" ], "test": [ "composer validate --no-interaction", @@ -906,7 +906,7 @@ "support": { "issues": "https://phabricator.wikimedia.org/project/profile/1202/" }, - "time": "2017-11-21 09:59:21" + "time": "2017-11-21 17:09:54" }, { "name": "wikibase/data-model", @@ -1228,7 +1228,7 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/Wikibase", - "reference": "78a5b92dfa670ef40238929830199a35dd69b518" + "reference": "165ae7b34412c848d8b123532a25d6ce76b0f646" }, "require": { "composer/installers": ">=1.0.1", @@ -1289,7 +1289,7 @@ "issues": "https://phabricator.wikimedia.org/", "irc": "irc://irc.freenode.net/wikidata" }, - "time": "2017-11-20 21:48:40" + "time": "2017-11-21 12:13:03" }, { "name": "wikibase/wikimedia-badges", diff --git a/extensions/Constraints/WikibaseQualityConstraintsHooks.php b/extensions/Constraints/WikibaseQualityConstraintsHooks.php index 948e281..c04c59c 100644 --- a/extensions/Constraints/WikibaseQualityConstraintsHooks.php +++ b/extensions/Constraints/WikibaseQualityConstraintsHooks.php @@ -19,18 +19,13 @@ */ final class WikibaseQualityConstraintsHooks { - public static function onExtensionRegistration() { - // Define database table names - define( 'CONSTRAINT_TABLE', 'wbqc_constraints' ); - } - /** * @param DatabaseUpdater $updater * * @return bool */ public static function onCreateSchema( DatabaseUpdater $updater ) { - $updater->addExtensionTable( CONSTRAINT_TABLE, __DIR__ . '/sql/create_wbqc_constraints.sql' ); + $updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/sql/create_wbqc_constraints.sql' ); return true; } @@ -43,6 +38,7 @@ if ( MediaWikiServices::getInstance()->getMainConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && self::isPropertyStatementsChange( $change ) ) { + /** @var EntityChange $change */ $title = Title::newMainPage(); $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; JobQueueGroup::singleton()->push( diff --git a/extensions/Constraints/api/CheckConstraints.php b/extensions/Constraints/api/CheckConstraints.php index 798bb17..5f3f1cc 100644 --- a/extensions/Constraints/api/CheckConstraints.php +++ b/extensions/Constraints/api/CheckConstraints.php @@ -14,7 +14,6 @@ use Wikibase\DataModel\Entity\EntityIdParsingException; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Services\EntityId\EntityIdFormatter; -use Wikibase\DataModel\Services\Statement\StatementGuidParser; use Wikibase\DataModel\Services\Statement\StatementGuidValidator; use Wikibase\Lib\SnakFormatter; use Wikibase\Lib\Store\EntityTitleLookup; @@ -52,11 +51,6 @@ * @var StatementGuidValidator */ private $statementGuidValidator; - - /** - * @var StatementGuidParser - */ - private $statementGuidParser; /** * @var DelegatingConstraintChecker @@ -122,7 +116,6 @@ $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup ); $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup ); - $statementGuidParser = $repo->getStatementGuidParser(); $constraintParameterRenderer = new ConstraintParameterRenderer( $entityIdHtmlLinkFormatter, $valueFormatter ); $config = MediaWikiServices::getInstance()->getMainConfig(); $titleParser = MediaWikiServices::getInstance()->getTitleParser(); @@ -130,7 +123,7 @@ $constraintReportFactory = new ConstraintReportFactory( $repo->getEntityLookup(), $repo->getPropertyDataTypeLookup(), - $statementGuidParser, + $repo->getStatementGuidParser(), $config, $constraintParameterRenderer, new ConstraintParameterParser( @@ -144,13 +137,19 @@ $unitConverter ); - return new CheckConstraints( $main, $name, $prefix, $repo->getEntityIdParser(), - $repo->getStatementGuidValidator(), $statementGuidParser, $constraintReportFactory->getConstraintChecker(), + return new CheckConstraints( + $main, + $name, + $prefix, + $repo->getEntityIdParser(), + $repo->getStatementGuidValidator(), + $constraintReportFactory->getConstraintChecker(), $constraintParameterRenderer, $repo->getApiHelperFactory( RequestContext::getMain() ), $repo->getEntityTitleLookup(), $entityIdLabelFormatter, - $config ); + $config + ); } /** @@ -159,7 +158,6 @@ * @param string $prefix * @param EntityIdParser $entityIdParser * @param StatementGuidValidator $statementGuidValidator - * @param StatementGuidParser $statementGuidParser * @param DelegatingConstraintChecker $delegatingConstraintChecker * @param ConstraintParameterRenderer $constraintParameterRenderer * @param ApiHelperFactory $apiHelperFactory @@ -169,7 +167,6 @@ */ public function __construct( ApiMain $main, $name, $prefix = '', EntityIdParser $entityIdParser, StatementGuidValidator $statementGuidValidator, - StatementGuidParser $statementGuidParser, DelegatingConstraintChecker $delegatingConstraintChecker, ConstraintParameterRenderer $constraintParameterRenderer, ApiHelperFactory $apiHelperFactory, @@ -186,7 +183,6 @@ $this->entityIdParser = $entityIdParser; $this->statementGuidValidator = $statementGuidValidator; - $this->statementGuidParser = $statementGuidParser; $this->delegatingConstraintChecker = $delegatingConstraintChecker; $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); @@ -344,12 +340,10 @@ if ( $checkResult instanceof NullResult ) { $result = null; } else { - $entityId = $checkResult->getEntityId()->getSerialization(); $constraintId = $checkResult->getConstraint()->getConstraintId(); $typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId(); $title = $this->entityTitleLookup->getTitleForId( $checkResult->getContext()->getSnak()->getPropertyId() ); - $statementGuid = $this->statementGuidParser->parse( $constraintId ); $typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) ); // TODO link to the statement when possible (T169224) $link = $title->getFullUrl() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ); diff --git a/extensions/Constraints/composer.json b/extensions/Constraints/composer.json index dde6cb6..5c38849 100644 --- a/extensions/Constraints/composer.json +++ b/extensions/Constraints/composer.json @@ -37,8 +37,8 @@ }, "scripts": { "fix": [ - "phpcbf", - "minus-x fix ." + "minus-x fix .", + "phpcbf" ], "test": [ "composer validate --no-interaction", diff --git a/extensions/Constraints/extension.json b/extensions/Constraints/extension.json index d9ddb69..e4bba12 100644 --- a/extensions/Constraints/extension.json +++ b/extensions/Constraints/extension.json @@ -7,7 +7,6 @@ "version": "1.0.0", "license-name": "GPL-2.0+", "type": "wikibase", - "callback": "WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onExtensionRegistration", "MessagesDirs": { "WikibaseQualityConstraints": [ "i18n" diff --git a/extensions/Constraints/includes/ConstraintCheck/Cache/CachedEntityIds.php b/extensions/Constraints/includes/ConstraintCheck/Cache/CachedEntityIds.php index 9f02d4a..ae783b3 100644 --- a/extensions/Constraints/includes/ConstraintCheck/Cache/CachedEntityIds.php +++ b/extensions/Constraints/includes/ConstraintCheck/Cache/CachedEntityIds.php @@ -2,8 +2,6 @@ namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Cache; -use Wikibase\DataModel\Entity\EntityId; - /** * A list of entity IDs, along with information whether and how they were cached. * @@ -13,7 +11,8 @@ class CachedEntityIds extends CachedArray { /** - * @return (EntityId|null)[] The entity IDs. + * @return array List of EntityId objects. Can contain one or more null values to mark spots + * that should have been EntityIds too, but could not due to errors. */ public function getArray() { return parent::getArray(); diff --git a/extensions/Constraints/includes/ConstraintCheck/Checker/CommonsLinkChecker.php b/extensions/Constraints/includes/ConstraintCheck/Checker/CommonsLinkChecker.php index ea9a575..7e2aa5a 100644 --- a/extensions/Constraints/includes/ConstraintCheck/Checker/CommonsLinkChecker.php +++ b/extensions/Constraints/includes/ConstraintCheck/Checker/CommonsLinkChecker.php @@ -56,6 +56,7 @@ * All namespaces not known to this function will be looked up by the TitleParser. * * @param string $namespace + * * @return array first element is the namespace number (default namespace for TitleParser), * second element is a string to prepend to the title before giving it to the TitleParser */ @@ -193,6 +194,7 @@ * * @param string $value * @param string $namespace + * * @return bool */ private function valueIncludesNamespace( $value, $namespace ) { diff --git a/extensions/Constraints/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php b/extensions/Constraints/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php index 6f73afb..3f48e92 100644 --- a/extensions/Constraints/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php +++ b/extensions/Constraints/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php @@ -4,6 +4,7 @@ use Config; use DataValues\QuantityValue; +use Wikibase\DataModel\Entity\PropertyId; use Wikibase\DataModel\Snak\PropertyValueSnak; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; @@ -60,6 +61,12 @@ $this->config = $config; } + /** + * @param Constraint $constraint + * + * @throws ConstraintParameterException + * @return array [ DataValue|null $min, DataValue|null $max, PropertyId $property, array $parameters ] + */ private function parseConstraintParameters( Constraint $constraint ) { list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter( $constraint->getConstraintParameters(), @@ -86,6 +93,7 @@ * Check whether the endpoints of a range are in years or not. * @param QuantityValue|null $min * @param QuantityValue|null $max + * * @return bool */ private function rangeInYears( $min, $max ) { @@ -119,7 +127,6 @@ } $parameters = []; - $constraintParameters = $constraint->getConstraintParameters(); $snak = $context->getSnak(); @@ -130,6 +137,7 @@ $minuend = $snak->getDataValue(); + /** @var PropertyId $property */ list ( $min, $max, $property, $parameters ) = $this->parseConstraintParameters( $constraint ); // checks only the first occurrence of the referenced property (this constraint implies a single value constraint on that property) diff --git a/extensions/Constraints/includes/ConstraintCheck/Checker/FormatChecker.php b/extensions/Constraints/includes/ConstraintCheck/Checker/FormatChecker.php index 766a73e..b3f845c 100644 --- a/extensions/Constraints/includes/ConstraintCheck/Checker/FormatChecker.php +++ b/extensions/Constraints/includes/ConstraintCheck/Checker/FormatChecker.php @@ -3,6 +3,7 @@ namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Checker; use Config; +use DataValues\MonolingualTextValue; use DataValues\StringValue; use Language; use Wikibase\DataModel\Snak\PropertyValueSnak; @@ -102,6 +103,7 @@ $text = $dataValue->getValue(); break; case 'monolingualtext': + /** @var MonolingualTextValue $dataValue */ $text = $dataValue->getText(); break; default: diff --git a/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php b/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php index 869381f..a68a716 100644 --- a/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php +++ b/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php @@ -6,6 +6,7 @@ use LogicException; use Wikibase\DataModel\Entity\EntityDocument; use Wikibase\DataModel\Entity\PropertyId; +use Wikibase\DataModel\Reference; use Wikibase\DataModel\Services\Lookup\EntityLookup; use Wikibase\DataModel\Services\Statement\StatementGuidParser; use Wikibase\DataModel\Statement\Statement; @@ -451,6 +452,7 @@ ) { $result = []; + /** @var Reference $reference */ foreach ( $statement->getReferences() as $reference ) { foreach ( $reference->getSnaks() as $snak ) { $referenceContext = new ReferenceContext( diff --git a/extensions/Constraints/includes/ConstraintCheck/Helper/ConnectionCheckerHelper.php b/extensions/Constraints/includes/ConstraintCheck/Helper/ConnectionCheckerHelper.php index 6c76569..ffba31c 100644 --- a/extensions/Constraints/includes/ConstraintCheck/Helper/ConnectionCheckerHelper.php +++ b/extensions/Constraints/includes/ConstraintCheck/Helper/ConnectionCheckerHelper.php @@ -51,6 +51,7 @@ EntityId $value ) { $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); + /** @var Statement $statement */ foreach ( $statementListByPropertyId as $statement ) { $snak = $statement->getMainSnak(); if ( $snak->getType() === 'value' ) { @@ -81,6 +82,7 @@ array $values ) { $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); + /** @var Statement $statement */ foreach ( $statementListByPropertyId as $statement ) { $snak = $statement->getMainSnak(); foreach ( $values as $value ) { diff --git a/extensions/Constraints/includes/ConstraintCheck/Helper/ConstraintParameterParser.php b/extensions/Constraints/includes/ConstraintCheck/Helper/ConstraintParameterParser.php index a94aced..ae5c59c 100644 --- a/extensions/Constraints/includes/ConstraintCheck/Helper/ConstraintParameterParser.php +++ b/extensions/Constraints/includes/ConstraintCheck/Helper/ConstraintParameterParser.php @@ -238,6 +238,7 @@ /** * @param array $constraintParameters see {@link \WikibaseQuality\Constraint::getConstraintParameters()} * @param string $constraintTypeItemId used in error messages + * * @throws ConstraintParameterException if the parameter is invalid or missing * @return PropertyId */ @@ -390,7 +391,7 @@ * @param string $unit * @return bool */ - private function exactlyOneQuantityWithUnit( $min, $max, $unit ) { + private function exactlyOneQuantityWithUnit( DataValue $min = null, DataValue $max = null, $unit ) { if ( $min === null || $max === null ) { return false; } @@ -404,6 +405,7 @@ * @param array $constraintParameters see {@link \WikibaseQuality\Constraint::getConstraintParameters()} * @param string $constraintTypeItemId used in error messages * @param string $type 'quantity' or 'time' (can be data type or data value type) + * * @throws ConstraintParameterException if the parameter is invalid or missing * @return DataValue[] a pair of two quantity-type data values, either of which may be null to signify an open range */ @@ -612,6 +614,7 @@ $value = $snak->getDataValue(); $this->requireMonolingualTextParameter( $value, $parameterId ); + /** @var MonolingualTextValue $value */ $code = $value->getLanguageCode(); if ( array_key_exists( $code, $result ) ) { diff --git a/extensions/Constraints/includes/ConstraintCheck/Helper/SparqlHelper.php b/extensions/Constraints/includes/ConstraintCheck/Helper/SparqlHelper.php index 73dc3e7..33d56f6 100644 --- a/extensions/Constraints/includes/ConstraintCheck/Helper/SparqlHelper.php +++ b/extensions/Constraints/includes/ConstraintCheck/Helper/SparqlHelper.php @@ -4,6 +4,7 @@ use Config; use DataValues\DataValue; +use DataValues\MonolingualTextValue; use IBufferingStatsdDataFactory; use InvalidArgumentException; use MapCacheLRU; @@ -13,9 +14,9 @@ use Wikibase\DataModel\Entity\EntityId; use Wikibase\DataModel\Entity\EntityIdParser; use Wikibase\DataModel\Entity\EntityIdParsingException; +use Wikibase\DataModel\Entity\EntityIdValue; use Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup; use Wikibase\DataModel\Snak\PropertyValueSnak; -use Wikibase\DataModel\Snak\Snak; use Wikibase\DataModel\Statement\Statement; use Wikibase\Rdf\RdfVocabulary; use WikibaseQuality\ConstraintReport\ConstraintCheck\Cache\CachedBool; @@ -111,6 +112,7 @@ * @param string $id entity ID serialization of the entity to check * @param string[] $classes entity ID serializations of the expected types * @param boolean $withInstance true for “instance” relation, false for “subclass” relation + * * @return CachedBool * @throws SparqlHelperException if the query times out or some other error occurs */ @@ -158,6 +160,7 @@ /** * @param Statement $statement * @param boolean $ignoreDeprecatedStatements Whether to ignore deprecated statements or not. + * * @return CachedEntityIds * @throws SparqlHelperException if the query times out or some other error occurs */ @@ -199,6 +202,7 @@ * @param PropertyValueSnak $snak * @param string $type Context::TYPE_QUALIFIER or Context::TYPE_REFERENCE * @param boolean $ignoreDeprecatedStatements Whether to ignore deprecated statements or not. + * * @return CachedEntityIds * @throws SparqlHelperException if the query times out or some other error occurs */ @@ -252,7 +256,9 @@ /** * Return SPARQL code for a string literal with $text as content. + * * @param string $text + * * @return string */ private function stringLiteral( $text ) { @@ -263,6 +269,7 @@ * Extract and parse entity IDs from the ?otherEntity column of a SPARQL query result. * * @param CachedQueryResults $results + * * @return CachedEntityIds */ private function getOtherEntities( CachedQueryResults $results ) { @@ -292,6 +299,7 @@ * * @param string $dataType * @param DataValue $dataValue + * * @return array the literal or IRI as a string in SPARQL syntax, * and a boolean indicating whether it refers to a full value node or not */ @@ -319,8 +327,10 @@ return [ '<' . $url . '>', false ]; case 'wikibase-item': case 'wikibase-property': + /** @var EntityIdValue $dataValue */ return [ 'wd:' . $dataValue->getEntityId()->getSerialization(), false ]; case 'monolingualtext': + /** @var MonolingualTextValue $dataValue */ $lang = $dataValue->getLanguageCode(); if ( !preg_match( '/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang ) ) { // not a valid language tag for SPARQL (see SPARQL spec, production 145 LANGTAG) @@ -341,6 +351,7 @@ /** * @param string $text * @param string $regex + * * @return boolean * @throws SparqlHelperException if the query times out or some other error occurs * @throws ConstraintParameterException if the $regex is invalid @@ -414,6 +425,7 @@ * * @param string $text * @param string $regex + * * @return boolean * @throws SparqlHelperException if the query times out or some other error occurs * @throws ConstraintParameterException if the $regex is invalid @@ -447,6 +459,7 @@ * Check whether the text content of an error response indicates a query timeout. * * @param string $responseContent + * * @return boolean */ public function isTimeout( $responseContent ) { @@ -464,6 +477,7 @@ * or a boolean indicating whether the response was cached or not. * * @param array $responseHeaders see MWHttpRequest::getResponseHeaders() + * * @return integer|boolean the max-age (in seconds) * or a plain boolean if no max-age can be determined */ diff --git a/extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php b/extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php index 39bba1d..dcf1415 100644 --- a/extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php +++ b/extensions/Constraints/includes/ConstraintCheck/Helper/TypeCheckerHelper.php @@ -125,10 +125,8 @@ * * @param EntityId $comparativeClass * @param string[] $classesToCheck - * @param int &$entitiesChecked * * @return CachedBool - * * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs */ public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) { @@ -163,7 +161,6 @@ * @param string[] $classesToCheck * * @return CachedBool - * * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs */ public function hasClassInRelation( StatementList $statements, $relationId, array $classesToCheck ) { diff --git a/extensions/Constraints/includes/ConstraintCheck/ItemIdSnakValue.php b/extensions/Constraints/includes/ConstraintCheck/ItemIdSnakValue.php index 27571bf..117dca7 100644 --- a/extensions/Constraints/includes/ConstraintCheck/ItemIdSnakValue.php +++ b/extensions/Constraints/includes/ConstraintCheck/ItemIdSnakValue.php @@ -3,6 +3,7 @@ namespace WikibaseQuality\ConstraintReport\ConstraintCheck; use DomainException; +use InvalidArgumentException; use Wikibase\DataModel\Entity\EntityIdValue; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Snak\PropertyNoValueSnak; @@ -22,10 +23,13 @@ * @var ItemId? */ private $itemId = null; + /** * @var bool */ + private $some = false; + /** * @var bool */ @@ -71,6 +75,9 @@ /** * Get an {@link ItemIdSnakValue} that matches the given snak. * + * @param Snak $snak + * + * @throws InvalidArgumentException * @return self */ public static function fromSnak( Snak $snak ) { diff --git a/extensions/Constraints/includes/ConstraintRepository.php b/extensions/Constraints/includes/ConstraintRepository.php index f06bcc6..d8e4c8a 100644 --- a/extensions/Constraints/includes/ConstraintRepository.php +++ b/extensions/Constraints/includes/ConstraintRepository.php @@ -24,7 +24,7 @@ $db = wfGetDB( DB_REPLICA ); $results = $db->select( - CONSTRAINT_TABLE, + 'wbqc_constraints', '*', [ 'pid' => $propertyId->getNumericId() ] ); @@ -62,7 +62,7 @@ ); $db = wfGetDB( DB_MASTER ); - return $db->insert( CONSTRAINT_TABLE, $accumulator ); + return $db->insert( 'wbqc_constraints', $accumulator ); } /** @@ -89,7 +89,7 @@ public function deleteWhereConstraintIdIsUuid() { $db = wfGetDB( DB_MASTER ); $db->delete( - CONSTRAINT_TABLE, + 'wbqc_constraints', // WHERE constraint_guid LIKE ________-____-____-____-____________ 'constraint_guid ' . $db->buildLike( $this->uuidPattern( $db->anyChar() ) ) ); @@ -99,12 +99,14 @@ * Delete all constraints for the property ID where the constraint ID is a statement ID * (an entity ID, a '$' separator, and a UUID). * + * @param PropertyId $propertyId + * * @throws DBUnexpectedError */ public function deleteForPropertyWhereConstraintIdIsStatementId( PropertyId $propertyId ) { $db = wfGetDB( DB_MASTER ); $db->delete( - CONSTRAINT_TABLE, + 'wbqc_constraints', [ 'pid' => $propertyId->getNumericId(), // AND constraint_guid LIKE %$________-____-____-____-____________ @@ -125,12 +127,12 @@ } $db = wfGetDB( DB_MASTER ); if ( $db->getType() === 'sqlite' ) { - $db->delete( CONSTRAINT_TABLE, '*' ); + $db->delete( 'wbqc_constraints', '*' ); } else { do { $db->commit( __METHOD__, 'flush' ); wfGetLBFactory()->waitForReplication(); - $table = $db->tableName( CONSTRAINT_TABLE ); + $table = $db->tableName( 'wbqc_constraints' ); $db->query( sprintf( 'DELETE FROM %s LIMIT %d', $table, $batchSize ) ); } while ( $db->affectedRows() > 0 ); } diff --git a/extensions/Constraints/sql/create_wbqc_constraints.sql b/extensions/Constraints/sql/create_wbqc_constraints.sql index 969cbab..cab1538 100644 --- a/extensions/Constraints/sql/create_wbqc_constraints.sql +++ b/extensions/Constraints/sql/create_wbqc_constraints.sql @@ -1,9 +1,8 @@ CREATE TABLE IF NOT EXISTS /*_*/wbqc_constraints ( - constraint_guid VARBINARY(63) PRIMARY KEY, - pid INT(11) NOT NULL, - constraint_type_qid VARBINARY(25) NOT NULL, - constraint_parameters TEXT DEFAULT NULL + constraint_guid varbinary(63) PRIMARY KEY, + pid int(11) NOT NULL, + constraint_type_qid varbinary(25) NOT NULL, + constraint_parameters text DEFAULT NULL ) /*$wgDBTableOptions*/; -CREATE INDEX /*i*/wbqc_constraints_pid_index -ON /*_*/wbqc_constraints (pid); +CREATE INDEX /*i*/wbqc_constraints_pid_index ON /*_*/wbqc_constraints (pid); diff --git a/extensions/Constraints/tests/phpunit/Api/CheckConstraintsTest.php b/extensions/Constraints/tests/phpunit/Api/CheckConstraintsTest.php index 6f2d070..586962c 100644 --- a/extensions/Constraints/tests/phpunit/Api/CheckConstraintsTest.php +++ b/extensions/Constraints/tests/phpunit/Api/CheckConstraintsTest.php @@ -142,7 +142,6 @@ '', $entityIdParser, new StatementGuidValidator( $entityIdParser ), - $repo->getStatementGuidParser(), $constraintChecker, $constraintParameterRenderer, $repo->getApiHelperFactory( RequestContext::getMain() ), diff --git a/extensions/Constraints/tests/phpunit/Checker/RangeChecker/P1.json b/extensions/Constraints/tests/phpunit/Checker/RangeChecker/P1.json deleted file mode 100644 index c5c32ad..0000000 --- a/extensions/Constraints/tests/phpunit/Checker/RangeChecker/P1.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": "P1", - "type": "property", - "datatype": "time" -} diff --git a/extensions/Constraints/tests/phpunit/Checker/RangeChecker/P2.json b/extensions/Constraints/tests/phpunit/Checker/RangeChecker/P2.json deleted file mode 100644 index 13ce8a6..0000000 --- a/extensions/Constraints/tests/phpunit/Checker/RangeChecker/P2.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": "P1", - "type": "property", - "datatype": "quantity" -} diff --git a/extensions/Constraints/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php b/extensions/Constraints/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php index 46ffc63..df3cf8b 100644 --- a/extensions/Constraints/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php +++ b/extensions/Constraints/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php @@ -3,7 +3,7 @@ namespace WikibaseQuality\ConstraintReport\Test\RangeChecker; use Wikibase\DataModel\Entity\EntityDocument; -use Wikibase\DataModel\Services\Lookup\EntityRetrievingDataTypeLookup; +use Wikibase\DataModel\Services\Lookup\InMemoryDataTypeLookup; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\DecimalValue; use DataValues\QuantityValue; @@ -24,7 +24,6 @@ use WikibaseQuality\ConstraintReport\Tests\ConstraintParameters; use WikibaseQuality\ConstraintReport\Tests\Fake\FakeSnakContext; use WikibaseQuality\ConstraintReport\Tests\ResultAssertions; -use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; /** * @covers \WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\RangeChecker @@ -42,11 +41,6 @@ use ConstraintParameters, ResultAssertions; /** - * @var JsonFileEntityLookup - */ - private $lookup; - - /** * @var TimeValue */ private $timeValue; @@ -58,14 +52,16 @@ protected function setUp() { parent::setUp(); - $this->lookup = new JsonFileEntityLookup( __DIR__ ); $this->timeValue = new TimeValue( '+00000001970-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); $rangeCheckerHelper = new RangeCheckerHelper( $this->getDefaultConfig(), new UnitConverter( new CSVUnitStorage( __DIR__ . '/units.csv' ), '' ) ); + $dataTypeLookup = new InMemoryDataTypeLookup(); + $dataTypeLookup->setDataTypeForProperty( new PropertyId( 'P1' ), 'time' ); + $dataTypeLookup->setDataTypeForProperty( new PropertyId( 'P2' ), 'quantity' ); $this->checker = new RangeChecker( - new EntityRetrievingDataTypeLookup( $this->lookup ), + $dataTypeLookup, $this->getConstraintParameterParser(), $rangeCheckerHelper, $this->getConstraintParameterRenderer() diff --git a/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php b/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php index c48e9b2..356a8d2 100644 --- a/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php +++ b/extensions/Constraints/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php @@ -52,6 +52,7 @@ /** * @param EntityLookup $lookup The backing lookup of the mock (defaults to JsonFileEntityLookup). + * * @return EntityLookup Expects that getEntity is called * exactly WBQualityConstraintsTypeCheckMaxEntities times. */ @@ -72,6 +73,7 @@ /** * @param boolean $return * @param array|null $arguments + * * @return SparqlHelper expects that {@link SparqlHelper::hasType} * is called exactly once and returns $return. */ diff --git a/extensions/Constraints/tests/phpunit/ConstraintRepositoryTest.php b/extensions/Constraints/tests/phpunit/ConstraintRepositoryTest.php index 3971342..bc6d157 100644 --- a/extensions/Constraints/tests/phpunit/ConstraintRepositoryTest.php +++ b/extensions/Constraints/tests/phpunit/ConstraintRepositoryTest.php @@ -40,8 +40,8 @@ } public function testQueryConstraintsForPropertyBrokenParameters() { - $this->db->delete( CONSTRAINT_TABLE, '*' ); - $this->db->insert( CONSTRAINT_TABLE, [ + $this->db->delete( 'wbqc_constraints', '*' ); + $this->db->insert( 'wbqc_constraints', [ [ 'constraint_guid' => 'P3$514751bb-1656-4d2d-a386-b0f0a69e02ed', 'pid' => 3, @@ -68,7 +68,7 @@ $repo->insertBatch( $constraints ); $this->assertSelect( - CONSTRAINT_TABLE, + 'wbqc_constraints', [ 'constraint_guid', 'pid', @@ -112,7 +112,7 @@ } public function testInsertBatchTooLongParameters() { - $this->db->delete( CONSTRAINT_TABLE, '*' ); + $this->db->delete( 'wbqc_constraints', '*' ); $constraintParameters = [ 'known_exception' => [] ]; for ( $i = 0; $i < 10000; $i++ ) { @@ -138,7 +138,7 @@ ] ); $this->assertSelect( - CONSTRAINT_TABLE, + 'wbqc_constraints', [ 'constraint_guid', 'pid', @@ -164,7 +164,7 @@ $repo->deleteAll(); $this->assertSelect( - CONSTRAINT_TABLE, + 'wbqc_constraints', 'COUNT(constraint_guid)', [], [ @@ -174,8 +174,8 @@ } public function insertTestData() { - $this->db->delete( CONSTRAINT_TABLE, '*' ); - $this->db->insert( CONSTRAINT_TABLE, [ + $this->db->delete( 'wbqc_constraints', '*' ); + $this->db->insert( 'wbqc_constraints', [ [ 'constraint_guid' => '1', 'pid' => 1, diff --git a/extensions/Constraints/tests/phpunit/ConstraintTest.php b/extensions/Constraints/tests/phpunit/ConstraintTest.php index 50b4ade..79104b5 100644 --- a/extensions/Constraints/tests/phpunit/ConstraintTest.php +++ b/extensions/Constraints/tests/phpunit/ConstraintTest.php @@ -31,8 +31,8 @@ } public function addDBData() { - $this->db->delete( CONSTRAINT_TABLE, '*' ); - $this->db->insert( CONSTRAINT_TABLE, [ + $this->db->delete( 'wbqc_constraints', '*' ); + $this->db->insert( 'wbqc_constraints', [ [ 'constraint_guid' => '1', 'pid' => 1, diff --git a/extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php b/extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php index a137413..854fdc2 100644 --- a/extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php +++ b/extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php @@ -102,7 +102,7 @@ $this->constraintChecker = $factory->getConstraintChecker(); // specify database tables used by this test - $this->tablesUsed[ ] = CONSTRAINT_TABLE; + $this->tablesUsed[] = 'wbqc_constraints'; } /** @@ -330,8 +330,8 @@ } ) ); - $this->db->delete( CONSTRAINT_TABLE, '*' ); - $this->db->insert( CONSTRAINT_TABLE, $constraints ); + $this->db->delete( 'wbqc_constraints', '*' ); + $this->db->insert( 'wbqc_constraints', $constraints ); } public function testCheckOnEntityId() { diff --git a/extensions/Constraints/tests/phpunit/Job/UpdateConstraintsTableJobTest.php b/extensions/Constraints/tests/phpunit/Job/UpdateConstraintsTableJobTest.php index 2bdb823..7dcb89b 100644 --- a/extensions/Constraints/tests/phpunit/Job/UpdateConstraintsTableJobTest.php +++ b/extensions/Constraints/tests/phpunit/Job/UpdateConstraintsTableJobTest.php @@ -41,12 +41,12 @@ protected function setUp() { parent::setUp(); - $this->tablesUsed[] = CONSTRAINT_TABLE; + $this->tablesUsed[] = 'wbqc_constraints'; } public function addDBData() { - $this->db->delete( CONSTRAINT_TABLE, '*' ); - $this->db->insert( CONSTRAINT_TABLE, [ + $this->db->delete( 'wbqc_constraints', '*' ); + $this->db->insert( 'wbqc_constraints', [ // a constraint imported from a template (UUID) [ 'constraint_guid' => 'afbbe0c2-2bc4-47b6-958c-a318a53814ac', @@ -211,7 +211,7 @@ ); $this->assertSelect( - CONSTRAINT_TABLE, + 'wbqc_constraints', [ 'constraint_guid', 'pid', @@ -266,7 +266,7 @@ $job->run(); $this->assertSelect( - CONSTRAINT_TABLE, + 'wbqc_constraints', [ 'constraint_guid', 'pid', diff --git a/extensions/Constraints/tests/phpunit/SparqlHelperMock.php b/extensions/Constraints/tests/phpunit/SparqlHelperMock.php index a05c4bf..79db83a 100644 --- a/extensions/Constraints/tests/phpunit/SparqlHelperMock.php +++ b/extensions/Constraints/tests/phpunit/SparqlHelperMock.php @@ -18,6 +18,7 @@ /** * @param Statement $expectedStatement * @param (EntityId|null)[] $result + * * @return SparqlHelper */ private function getSparqlHelperMockFindEntities( diff --git a/extensions/Constraints/tests/phpunit/Specials/SpecialConstraintReportTest.php b/extensions/Constraints/tests/phpunit/Specials/SpecialConstraintReportTest.php index f1cd809..52930fb 100644 --- a/extensions/Constraints/tests/phpunit/Specials/SpecialConstraintReportTest.php +++ b/extensions/Constraints/tests/phpunit/Specials/SpecialConstraintReportTest.php @@ -68,7 +68,7 @@ protected function setUp() { parent::setUp(); - $this->tablesUsed[ ] = CONSTRAINT_TABLE; + $this->tablesUsed[] = 'wbqc_constraints'; } protected function newSpecialPage() { @@ -143,13 +143,10 @@ } // Truncate table - $this->db->delete( - CONSTRAINT_TABLE, - '*' - ); + $this->db->delete( 'wbqc_constraints', '*' ); $this->db->insert( - CONSTRAINT_TABLE, + 'wbqc_constraints', [ [ 'constraint_guid' => '1', diff --git a/extensions/Wikibase/repo/includes/Diff/EntityContentDiffView.php b/extensions/Wikibase/repo/includes/Diff/EntityContentDiffView.php index a8bd1ba..2e5a774 100644 --- a/extensions/Wikibase/repo/includes/Diff/EntityContentDiffView.php +++ b/extensions/Wikibase/repo/includes/Diff/EntityContentDiffView.php @@ -158,18 +158,14 @@ } /** - * Returns the cache key for diff body text or content. - * - * @return string + * @inheritDoc */ - protected function getDiffBodyCacheKey() { - return wfMemcKey( - 'diff', - 'version', self::DIFF_VERSION, - 'oldid', $this->getOldid(), - 'newid', $this->getNewid(), - 'lang', $this->getLanguage()->getCode() - ); + protected function getDiffBodyCacheKeyParams() { + $parent = parent::getDiffBodyCacheKeyParams(); + $code = $this->getLanguage()->getCode(); + $parent[] = "lang-{$code}"; + + return $parent; } } diff --git a/extensions/Wikibase/repo/tests/phpunit/includes/Actions/HistoryEntityActionTest.php b/extensions/Wikibase/repo/tests/phpunit/includes/Actions/HistoryEntityActionTest.php index 7d946bf..c1d4c3f 100644 --- a/extensions/Wikibase/repo/tests/phpunit/includes/Actions/HistoryEntityActionTest.php +++ b/extensions/Wikibase/repo/tests/phpunit/includes/Actions/HistoryEntityActionTest.php @@ -62,9 +62,6 @@ ->disableOriginalConstructor() ->getMock(); - $output->method( 'getLanguage' ) - ->willReturn( Language::factory( self::DUMMY_LANGUAGE ) ); - return $output; } @@ -94,6 +91,9 @@ $context->method( 'getOutput' ) ->willReturn( $output ); + $context->method( 'getLanguage' ) + ->willReturn( Language::factory( self::DUMMY_LANGUAGE ) ); + $output->expects( $this->once() ) ->method( 'getContext' ) ->willReturn( $context ); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 25325ed..2362117 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1298,7 +1298,7 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/Wikibase", - "reference": "78a5b92dfa670ef40238929830199a35dd69b518" + "reference": "165ae7b34412c848d8b123532a25d6ce76b0f646" }, "require": { "composer/installers": ">=1.0.1", @@ -1327,7 +1327,7 @@ "mediawiki/minus-x": "0.1.0", "wikibase/wikibase-codesniffer": "^0.2.0" }, - "time": "2017-11-20 21:48:40", + "time": "2017-11-21 12:13:03", "type": "mediawiki-extension", "installation-source": "source", "scripts": { @@ -1433,7 +1433,7 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseQualityConstraints", - "reference": "76ce6bbc877d0d5ef799dd5ea62ec45274a49928" + "reference": "1aa44d3f7ef2e7817a41d437cd898fa303bedc4b" }, "require": { "php": ">=5.5.9", @@ -1450,13 +1450,13 @@ "satooshi/php-coveralls": "master-dev", "wikibase/wikibase-codesniffer": "^0.2.0" }, - "time": "2017-11-21 09:59:21", + "time": "2017-11-21 17:09:54", "type": "mediawiki-extension", "installation-source": "source", "scripts": { "fix": [ - "phpcbf", - "minus-x fix ." + "minus-x fix .", + "phpcbf" ], "test": [ "composer validate --no-interaction", -- To view, visit https://gerrit.wikimedia.org/r/392810 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie7646f107a8a5696b8d27e0fb56e18d8f728cd84 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikidata Gerrit-Branch: master Gerrit-Owner: WikidataBuilder <wikidata-servi...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits