[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add tests for two uncovered CheckResult methods

2018-01-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406059 )

Change subject: Add tests for two uncovered CheckResult methods
..

Add tests for two uncovered CheckResult methods

Change-Id: I6a38d5068b0149d6e98eaf370855cc13b905
---
M tests/phpunit/Result/CheckResultTest.php
1 file changed, 22 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/59/406059/1

diff --git a/tests/phpunit/Result/CheckResultTest.php 
b/tests/phpunit/Result/CheckResultTest.php
index 0c4d8fa..9566952 100644
--- a/tests/phpunit/Result/CheckResultTest.php
+++ b/tests/phpunit/Result/CheckResultTest.php
@@ -65,4 +65,26 @@
$checkResult->getDataValue();
}
 
+   public function testAddParameter() {
+   $context = new FakeSnakContext( new PropertyNoValueSnak( new 
PropertyId( 'P1' ) ) );
+   $constraint = new Constraint( '', new PropertyId( 'P1' ), 'Q1', 
[] );
+   $checkResult = new CheckResult( $context, $constraint );
+
+   $this->assertSame( [], $checkResult->getParameters() );
+
+   $checkResult->addParameter( 'constraint_status', 'mandatory' );
+   $this->assertSame( [ 'constraint_status' => [ 'mandatory' ] ], 
$checkResult->getParameters() );
+   }
+
+   public function testSetStatus() {
+   $context = new FakeSnakContext( new PropertyNoValueSnak( new 
PropertyId( 'P1' ) ) );
+   $constraint = new Constraint( '', new PropertyId( 'P1' ), 'Q1', 
[] );
+   $checkResult = new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_VIOLATION );
+
+   $this->assertSame( CheckResult::STATUS_VIOLATION, 
$checkResult->getStatus() );
+
+   $checkResult->setStatus( CheckResult::STATUS_WARNING );
+   $this->assertSame( CheckResult::STATUS_WARNING, 
$checkResult->getStatus() );
+   }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/406059
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a38d5068b0149d6e98eaf370855cc13b905
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Split up and test CheckConstraints::newFromGlobalState

2018-01-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406050 )

Change subject: Split up and test CheckConstraints::newFromGlobalState
..

Split up and test CheckConstraints::newFromGlobalState

CheckConstraints::newFromGlobalState was one giant method that
initialized the dependency injection for everything else. This commit
splits it up into several methods and adds tests for all of them. I’ll
be the first to admit that this still isn’t great, and that the tests
don’t do very much, but at least we’ll now get test failures if one of
the classes instantiated here gains a parameter, which previously would
only be detected by manual tests.

Bug: T183373
Change-Id: Ie075eade0f9155128898564874bea9f38a86f443
---
M src/Api/CheckConstraints.php
M tests/phpunit/Api/CheckConstraintsTest.php
2 files changed, 221 insertions(+), 72 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/50/406050/1

diff --git a/src/Api/CheckConstraints.php b/src/Api/CheckConstraints.php
index 46b5303..6d092ba 100644
--- a/src/Api/CheckConstraints.php
+++ b/src/Api/CheckConstraints.php
@@ -4,9 +4,11 @@
 
 use ApiBase;
 use ApiMain;
+use Config;
 use IBufferingStatsdDataFactory;
 use MediaWiki\MediaWikiServices;
 use RequestContext;
+use TitleParser;
 use ValueFormatters\FormatterOptions;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\EntityIdParser;
@@ -19,6 +21,7 @@
 use Wikibase\Repo\Api\ResultBuilder;
 use Wikibase\Repo\EntityIdLabelFormatterFactory;
 use Wikibase\Repo\WikibaseRepo;
+use 
WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker;
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
@@ -75,32 +78,91 @@
 * @param string $prefix
 *
 * @return self
+*
+* @codeCoverageIgnore hard to test and only delegates to other methods
 */
public static function newFromGlobalState( ApiMain $main, $name, 
$prefix = '' ) {
-   $repo = WikibaseRepo::getDefaultInstance();
+   return self::getCheckConstraints(
+   MediaWikiServices::getInstance(),
+   WikibaseRepo::getDefaultInstance(),
+   $main,
+   $name,
+   $prefix
+   );
+   }
 
+   public static function getCheckConstraints(
+   MediaWikiServices $services,
+   WikibaseRepo $repo,
+   ApiMain $main,
+   $name,
+   $prefix
+   ) {
+   $config = $services->getMainConfig();
+   $dataFactory = $services->getStatsdDataFactory();
+   $titleParser = $services->getTitleParser();
+
+   $constraintParameterRenderer = 
self::getConstraintParameterRenderer(
+   $config,
+   $repo
+   );
+   $constraintReportFactory = self::getConstraintReportFactory(
+   $config,
+   $dataFactory,
+   $titleParser,
+   $repo,
+   $constraintParameterRenderer
+   );
+   $resultsBuilder = self::getResultsBuilder(
+   $config,
+   $dataFactory,
+   $repo,
+   $constraintParameterRenderer,
+   $constraintReportFactory->getConstraintChecker()
+   );
+
+   return new CheckConstraints(
+   $main,
+   $name,
+   $prefix,
+   $repo->getEntityIdParser(),
+   $repo->getStatementGuidValidator(),
+   $repo->getApiHelperFactory( RequestContext::getMain() ),
+   $resultsBuilder,
+   $dataFactory
+   );
+   }
+
+   public static function getConstraintParameterRenderer(
+   Config $config,
+   WikibaseRepo $repo
+   ) {
$language = $repo->getUserLanguage();
-   $formatterOptions = new FormatterOptions();
-   $formatterOptions->setOption( SnakFormatter::OPT_LANG, 
$language->getCode() );
-   $valueFormatterFactory = $repo->getValueFormatterFactory();
-   $valueFormatter = $valueFormatterFactory->getValueFormatter( 
SnakFormatter::FORMAT_HTML, $formatterOptions );
-
-   $languageFallbackLabelDescriptionLookupFactory = 
$repo->getLanguageFallbackLabelDescriptionLookupFactory();
-   $labelDescriptionLookup = 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Change namespace from …\Test to …\Tests

2018-01-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406043 )

Change subject: Change namespace from …\Test to …\Tests
..

Change namespace from …\Test to …\Tests

Both \WikibaseQuality\ConstraintReport\Test and
\WikibaseQuality\ConstraintReport\Tests were in use; the plural form
seems to be the standard in Wikibase, so let’s settle on that.

Change-Id: I721ea0db2164f2e1db706f7f7c6bc690e029c516
---
M tests/phpunit/Cache/CachedArrayTest.php
M tests/phpunit/Cache/CachedBoolTest.php
M tests/phpunit/Cache/CachedCheckConstraintsResponseTest.php
M tests/phpunit/Cache/CachedEntityIdsTest.php
M tests/phpunit/Cache/CachedQueryResultsTest.php
M tests/phpunit/Cache/CachingMetadataTest.php
M tests/phpunit/Cache/DependencyMetadataTest.php
M tests/phpunit/Cache/MetadataTest.php
M tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
M tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php
M tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php
M tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php
M tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php
M tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php
M tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php
M tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php
M tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php
M tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php
M tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php
M tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php
M tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php
M tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php
M tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
M tests/phpunit/Checker/ReferenceCheckerTest.php
M tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
M tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php
M tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
M tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
M tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php
M tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php
M tests/phpunit/Checker/ValueCountChecker/ValueCountCheckerHelperTest.php
M tests/phpunit/Checker/ValueOnlyCheckerTest.php
M tests/phpunit/ConstraintReportFactoryTest.php
M tests/phpunit/Context/MainSnakContextTest.php
M tests/phpunit/Context/QualifierContextTest.php
M tests/phpunit/Context/ReferenceContextTest.php
M tests/phpunit/DelegatingConstraintCheckerTest.php
M tests/phpunit/Helper/ConstraintParameterParserTest.php
M tests/phpunit/Helper/LoggingHelperTest.php
M tests/phpunit/Helper/SparqlHelperTest.php
M tests/phpunit/Result/CheckResultTest.php
41 files changed, 41 insertions(+), 41 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/43/406043/1

diff --git a/tests/phpunit/Cache/CachedArrayTest.php 
b/tests/phpunit/Cache/CachedArrayTest.php
index d635bf8..0469b49 100644
--- a/tests/phpunit/Cache/CachedArrayTest.php
+++ b/tests/phpunit/Cache/CachedArrayTest.php
@@ -1,6 +1,6 @@
 https://gerrit.wikimedia.org/r/406043
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I721ea0db2164f2e1db706f7f7c6bc690e029c516
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add tests for ItemIdSnakValue

2018-01-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406041 )

Change subject: Add tests for ItemIdSnakValue
..

Add tests for ItemIdSnakValue

Change-Id: Ic3e84dfe44983a80499049472e3b62047223f7c9
---
M src/ConstraintCheck/ItemIdSnakValue.php
A tests/phpunit/ItemIdSnakValueTest.php
2 files changed, 166 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/41/406041/1

diff --git a/src/ConstraintCheck/ItemIdSnakValue.php 
b/src/ConstraintCheck/ItemIdSnakValue.php
index 977dbb1..706e27f 100644
--- a/src/ConstraintCheck/ItemIdSnakValue.php
+++ b/src/ConstraintCheck/ItemIdSnakValue.php
@@ -130,6 +130,7 @@
 * Get the item ID contained in this {@link ItemIdSnakValue}.
 * Only valid if {@link isValue} is true.
 *
+* @throws DomainException if this value does not contain an item ID
 * @return ItemId
 */
public function getItemId() {
diff --git a/tests/phpunit/ItemIdSnakValueTest.php 
b/tests/phpunit/ItemIdSnakValueTest.php
new file mode 100644
index 000..fda55a1
--- /dev/null
+++ b/tests/phpunit/ItemIdSnakValueTest.php
@@ -0,0 +1,165 @@
+assertTrue( $value->isValue() );
+   $this->assertFalse( $value->isSomeValue() );
+   $this->assertFalse( $value->isNoValue() );
+   $this->assertSame( $itemId, $value->getItemId() );
+   }
+
+   public function testSomeValue() {
+   $value = ItemIdSnakValue::someValue();
+
+   $this->assertFalse( $value->isValue() );
+   $this->assertTrue( $value->isSomeValue() );
+   $this->assertFalse( $value->isNoValue() );
+
+   $this->setExpectedException( DomainException::class );
+   $value->getItemId();
+   }
+
+   public function testNoValue() {
+   $value = ItemIdSnakValue::noValue();
+
+   $this->assertFalse( $value->isValue() );
+   $this->assertFalse( $value->isSomeValue() );
+   $this->assertTrue( $value->isNoValue() );
+
+   $this->setExpectedException( DomainException::class );
+   $value->getItemId();
+   }
+
+   public function testFromSnak_ItemId() {
+   $itemId = new ItemId( 'Q1' );
+   $snak = new PropertyValueSnak(
+   new PropertyId( 'P100' ),
+   new EntityIdValue( $itemId )
+   );
+
+   $value = ItemIdSnakValue::fromSnak( $snak );
+
+   $this->assertTrue( $value->isValue() );
+   $this->assertSame( $itemId, $value->getItemId() );
+   }
+
+   public function testFromSnak_PropertyId() {
+   $propertyId = new PropertyId( 'P1' );
+   $snak = new PropertyValueSnak(
+   new PropertyId( 'P100' ),
+   new EntityIdValue( $propertyId )
+   );
+
+   $this->setExpectedException( InvalidArgumentException::class );
+   $value = ItemIdSnakValue::fromSnak( $snak );
+   }
+
+   public function testFromSnak_String() {
+   $snak = new PropertyValueSnak(
+   new PropertyId( 'P100' ),
+   new StringValue( 'Q1' )
+   );
+
+   $this->setExpectedException( InvalidArgumentException::class );
+   $value = ItemIdSnakValue::fromSnak( $snak );
+   }
+
+   public function testFromSnak_SomeValue() {
+   $snak = new PropertySomeValueSnak( new PropertyId( 'P100' ) );
+
+   $value = ItemIdSnakValue::fromSnak( $snak );
+
+   $this->assertTrue( $value->isSomeValue() );
+   }
+
+   public function testFromSnak_NoValue() {
+   $snak = new PropertyNoValueSnak( new PropertyId( 'P100' ) );
+
+   $value = ItemIdSnakValue::fromSnak( $snak );
+
+   $this->assertTrue( $value->isNoValue() );
+   }
+
+   public function testMatchesSnak_ItemId() {
+   $itemId = new ItemId( 'Q1' );
+   $snak = new PropertyValueSnak(
+   new PropertyId( 'P100' ),
+   new EntityIdValue( $itemId )
+   );
+
+   $this->assertTrue( ItemIdSnakValue::fromItemId( $itemId 
)->matchesSnak( $snak ) );
+   $this->assertFalse( ItemIdSnakValue::someValue()->matchesSnak( 
$snak ) );
+   $this->assertFalse( ItemIdSnakValue::noValue()->matchesSnak( 
$snak ) );
+   }
+
+   public function testMatchesSnak_PropertyId() {
+   $itemId = new ItemId( 'Q1' );
+   $propertyId = new PropertyId( 'P1' );
+   $snak = new PropertyValueSnak(
+   new PropertyId( 'P100' ),
+   new EntityIdValue( $propertyId )
+

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add tests for maintenance script

2018-01-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406037 )

Change subject: Add tests for maintenance script
..

Add tests for maintenance script

Change-Id: I66b8b4642827134fc9e63e2bb0c3eba54135b3ad
Depends-On: I61970403f9c371d3798f34fd48c70bc72f0c7eda
---
A tests/phpunit/Maintenance/ImportConstraintStatementsTest.php
1 file changed, 89 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/37/406037/1

diff --git a/tests/phpunit/Maintenance/ImportConstraintStatementsTest.php 
b/tests/phpunit/Maintenance/ImportConstraintStatementsTest.php
new file mode 100644
index 000..e0936fd
--- /dev/null
+++ b/tests/phpunit/Maintenance/ImportConstraintStatementsTest.php
@@ -0,0 +1,89 @@
+maintenance->setConfig( new HashConfig( [
+   
'WBQualityConstraintsEnableConstraintsImportFromStatements' => false,
+   ] ) );
+
+   $this->maintenance->execute();
+
+   $this->expectOutputString( 'Constraint statements are not 
enabled. Aborting.' );
+   }
+
+   public function testNoProperties() {
+   $this->maintenance->propertyInfoLookup = new 
MockPropertyInfoLookup( [] );
+   $this->maintenance->newUpdateConstraintsTableJob = function () {
+   $this->fail( 'newUpdateConstraintsTableJob should not 
be called' );
+   };
+
+   $this->maintenance->execute();
+
+   $this->expectOutputString( '' );
+   }
+
+   public function testTwoProperties() {
+   $this->maintenance->propertyInfoLookup = new 
MockPropertyInfoLookup( [
+   'P1' => [],
+   'P3' => [],
+   ] );
+   $call = 0;
+   $this->maintenance->newUpdateConstraintsTableJob = function ( 
$propertyIdSerialization ) use ( &$call ) {
+   $mock = $this->getMockBuilder( 
UpdateConstraintsTableJob::class )
+   ->disableOriginalConstructor()
+   ->setMethods( [ 'run' ] )
+   ->getMock();
+   $mock->expects( $this->once() )
+   ->method( 'run' )
+   ->with();
+   switch ( ++$call ) {
+   case 1:
+   $this->assertSame( 'P1', 
$propertyIdSerialization );
+   return $mock;
+   case 2:
+   $this->assertSame( 'P3', 
$propertyIdSerialization );
+   return $mock;
+   default:
+   $this->fail( 
'newUpdateConstraintsTableJob should only be called twice' );
+   return $mock; // unreachable but just 
in case
+   }
+   };
+
+   $this->maintenance->execute();
+
+   $this->expectOutputRegex( '/^' .
+   'Importing constraint statements for +P1... done in 
+\d+\.\d+ ms.\n' .
+   'Importing constraint statements for +P3... done in 
+\d+\.\d+ ms.\n' .
+   '$/' );
+   $this->assertSame( 2, $call, 'newUpdateConstraintsTableJob 
should have been called twice' );
+   }
+
+   public function testDefaultNewUpdateConstraintsTableJob() {
+   $job = call_user_func( 
$this->maintenance->newUpdateConstraintsTableJob, 'P1234' );
+
+   $this->assertInstanceOf( UpdateConstraintsTableJob::class, $job 
);
+   $params = $job->getParams();
+   $this->assertArrayHasKey( 'propertyId', $params );
+   $this->assertSame( 'P1234', $params['propertyId'] );
+   }
+
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/406037
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I66b8b4642827134fc9e63e2bb0c3eba54135b3ad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Make maintenance script testable

2018-01-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406036 )

Change subject: Make maintenance script testable
..

Make maintenance script testable

Use Maintenance::getConfig(), which has a corresponding setter which
tests can use, instead of getting the config from the services directly.
Move code to get the PropertyInfoLookup, and to instantiate the
UpdateConstraintsTableJob, into the constructor, where it is stored in
private member variables which tests can then later override (using
TestingAccessWrapper to get around the access restrictions). And to make
sure we can actually find the class in the tests, register its
containing directory in the autoload namespaces.

Also removes the use of Maintenance::error()’s deprecated $die
parameter. There is a fatalError() function we could use instead, but in
that case we could completely terminate the tests, which isn’t what we
want. Instead, simply return from execute().

Change-Id: I57f5a102f542db0b59347ec82fe85277ffb95560
---
M extension.json
M maintenance/ImportConstraintStatements.php
2 files changed, 28 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/36/406036/1

diff --git a/extension.json b/extension.json
index bc3d7c8..e60e04d 100644
--- a/extension.json
+++ b/extension.json
@@ -422,6 +422,7 @@
},
"AutoloadNamespaces": {
"WikibaseQuality\\ConstraintReport\\": "src/",
+   "WikibaseQuality\\ConstraintReport\\Maintenance\\": 
"maintenance/",
"WikibaseQuality\\ConstraintReport\\Tests\\": "tests/phpunit/"
},
"manifest_version": 2
diff --git a/maintenance/ImportConstraintStatements.php 
b/maintenance/ImportConstraintStatements.php
index 2a17564..f0d640c 100644
--- a/maintenance/ImportConstraintStatements.php
+++ b/maintenance/ImportConstraintStatements.php
@@ -4,14 +4,16 @@
 
 use Maintenance;
 use Title;
-use MediaWiki\MediaWikiServices;
+use Wikibase\Lib\Store\PropertyInfoLookup;
 use WikibaseQuality\ConstraintReport\UpdateConstraintsTableJob;
 use Wikibase\Repo\WikibaseRepo;
 
+// @codeCoverageIgnoreStart
 $basePath = getenv( "MW_INSTALL_PATH" ) !== false
? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
 
 require_once $basePath . "/maintenance/Maintenance.php";
+// @codeCoverageIgnoreEnd
 
 /**
  * Runs {@link UpdateConstraintsTableJob} once for every property.
@@ -20,22 +22,41 @@
  */
 class ImportConstraintStatements extends Maintenance {
 
+   /**
+* @var PropertyInfoLookup
+*/
+   private $propertyInfoLookup;
+
+   /**
+* @var callable
+* @return UpdateConstraintsTableJob
+*/
+   private $newUpdateConstraintsTableJob;
+
public function __construct() {
parent::__construct();
+   $repo = WikibaseRepo::getDefaultInstance();
+   $this->propertyInfoLookup = 
$repo->getStore()->getPropertyInfoLookup();
+   $this->newUpdateConstraintsTableJob = function ( 
$propertyIdSerialization ) {
+   return UpdateConstraintsTableJob::newFromGlobalState(
+   Title::newMainPage(),
+   [ 'propertyId' => $propertyIdSerialization ]
+   );
+   };
 
$this->addDescription( 'Imports property constraints from 
statements on properties' );
}
 
public function execute() {
-   if ( !MediaWikiServices::getInstance()->getMainConfig()->get( 
'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
-   $this->error( 'Constraint statements are not enabled. 
Aborting.', 1 );
+   if ( !$this->getConfig()->get( 
'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
+   $this->error( 'Constraint statements are not enabled. 
Aborting.' );
+   return;
}
 
-   $propertyInfoLookup = 
WikibaseRepo::getDefaultInstance()->getStore()->getPropertyInfoLookup();
-   foreach ( $propertyInfoLookup->getAllPropertyInfo() as 
$propertyIdSerialization => $info ) {
+   foreach ( $this->propertyInfoLookup->getAllPropertyInfo() as 
$propertyIdSerialization => $info ) {
$this->output( sprintf( 'Importing constraint 
statements for % 6s... ', $propertyIdSerialization ), $propertyIdSerialization 
);
$startTime = microtime( true );
-   $job = UpdateConstraintsTableJob::newFromGlobalState( 
Title::newMainPage(), [ 'propertyId' => $propertyIdSerialization ] );
+   $job = call_user_func( 
$this->newUpdateConstraintsTableJob, $propertyIdSerialization );
$job->run();
$endTime = microtime( 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Don’t write to stderr when testing

2018-01-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406035 )

Change subject: Don’t write to stderr when testing
..

Don’t write to stderr when testing

This change makes it possible to test error() messages with
expectOutputString() or expectOutputRegex().

Change-Id: I61970403f9c371d3798f34fd48c70bc72f0c7eda
---
M maintenance/Maintenance.php
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/35/406035/1

diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php
index 5adbee5..69284ac 100644
--- a/maintenance/Maintenance.php
+++ b/maintenance/Maintenance.php
@@ -414,7 +414,10 @@
$this->fatalError( $err, intval( $die ) );
}
$this->outputChanneled( false );
-   if ( PHP_SAPI == 'cli' || PHP_SAPI == 'phpdbg' ) {
+   if (
+   ( PHP_SAPI == 'cli' || PHP_SAPI == 'phpdbg' ) &&
+   !defined( 'MW_PHPUNIT_TEST' )
+   ) {
fwrite( STDERR, $err . "\n" );
} else {
print $err;

-- 
To view, visit https://gerrit.wikimedia.org/r/406035
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I61970403f9c371d3798f34fd48c70bc72f0c7eda
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add missing Maintenance import

2018-01-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406034 )

Change subject: Add missing Maintenance import
..

Add missing Maintenance import

Without this import, the @var Maintenance comment on $maintenance
doesn’t refer to the right class.

Change-Id: I2b5efa422f3e9d50f2132658b04ea2814af61954
---
M tests/phpunit/maintenance/MaintenanceBaseTestCase.php
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/34/406034/1

diff --git a/tests/phpunit/maintenance/MaintenanceBaseTestCase.php 
b/tests/phpunit/maintenance/MaintenanceBaseTestCase.php
index 9d73a51..bdcf7e5 100644
--- a/tests/phpunit/maintenance/MaintenanceBaseTestCase.php
+++ b/tests/phpunit/maintenance/MaintenanceBaseTestCase.php
@@ -2,6 +2,7 @@
 
 namespace MediaWiki\Tests\Maintenance;
 
+use Maintenance;
 use MediaWikiTestCase;
 use Wikimedia\TestingAccessWrapper;
 

-- 
To view, visit https://gerrit.wikimedia.org/r/406034
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b5efa422f3e9d50f2132658b04ea2814af61954
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityExternalValidation[master]: Update Coveralls URLs

2018-01-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406024 )

Change subject: Update Coveralls URLs
..

Update Coveralls URLs

See WikibaseQualityConstraints commit d5c47c137f (change I64bc71d98e).
(Coveralls isn’t currently enabled for this project, but updating the
URLs doesn’t hurt, either.)

Also fixes the missing trailing newline.

Change-Id: I33b8798c8a4957d33648b18de5930eb1790f19a9
---
M README.md
1 file changed, 3 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityExternalValidation
 refs/changes/24/406024/1

diff --git a/README.md b/README.md
index d8ff63b..e7311f4 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
 # Wikibase Quality External Validation
 [![Build 
Status](https://travis-ci.org/wikimedia/mediawiki-extensions-WikibaseQualityExternalValidation.svg?branch=master)]
 
(https://travis-ci.org/wikimedia/mediawiki-extensions-WikibaseQualityExternalValidation)
-[![Coverage 
Status](https://coveralls.io/repos/wikimedia/mediawiki-extensions-WikibaseQualityExternalValidation/badge.svg)]
-(https://coveralls.io/r/wikimedia/mediawiki-extensions-WikibaseQualityExternalValidation)
+[![Coverage 
Status](https://coveralls.io/repos/github/wikimedia/mediawiki-extensions-WikibaseQualityExternalValidation/badge.svg)]
+(https://coveralls.io/github/wikimedia/mediawiki-extensions-WikibaseQualityExternalValidation)
 [![Scrutinizer Code 
Quality](https://scrutinizer-ci.com/g/wikimedia/mediawiki-extensions-WikibaseQualityExternalValidation/badges/quality-score.png?b=master)]
 
(https://scrutinizer-ci.com/g/wikimedia/mediawiki-extensions-WikibaseQualityExternalValidation/?branch=master)
 
@@ -53,4 +53,4 @@
 * Last but not least, you need to fill the tables that contain external data - 
for that you need the
 [dump converter script](https://github.com/WikidataQuality/DumpConverter).  
 Follow the instruction in the README to create a tar file (that contains a 
number of csv files).  
-Run `php maintenance/runScript.php 
extensions/ExternalValidation/maintenance/UpdateExternalData.php --tar-file 
`.
\ No newline at end of file
+Run `php maintenance/runScript.php 
extensions/ExternalValidation/maintenance/UpdateExternalData.php --tar-file 
`.

-- 
To view, visit https://gerrit.wikimedia.org/r/406024
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I33b8798c8a4957d33648b18de5930eb1790f19a9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityExternalValidation
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Update Coveralls URLs

2018-01-23 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405916 )

Change subject: Update Coveralls URLs
..

Update Coveralls URLs

Change-Id: I64bc71d98ea5a36aa5a7e5932a80731bbec3334e
---
M README.md
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/16/405916/1

diff --git a/README.md b/README.md
index 4b39354..3545455 100644
--- a/README.md
+++ b/README.md
@@ -8,8 +8,8 @@
 
 [travis-badge]: 
https://travis-ci.org/wikimedia/mediawiki-extensions-WikibaseQualityConstraints.svg?branch=master
 [travis]: 
https://travis-ci.org/wikimedia/mediawiki-extensions-WikibaseQualityConstraints
-[coveralls-badge]: 
https://coveralls.io/repos/wikimedia/mediawiki-extensions-WikibaseQualityConstraints/badge.svg
-[coveralls]: 
https://coveralls.io/r/wikimedia/mediawiki-extensions-WikibaseQualityConstraints
+[coveralls-badge]: 
https://coveralls.io/repos/github/wikimedia/mediawiki-extensions-WikibaseQualityConstraints/badge.svg
+[coveralls]: 
https://coveralls.io/github/wikimedia/mediawiki-extensions-WikibaseQualityConstraints
 [scrutinizer-badge]: 
https://scrutinizer-ci.com/g/wikimedia/mediawiki-extensions-WikibaseQualityConstraints/badges/quality-score.png?b=master
 [scrutinizer]: 
https://scrutinizer-ci.com/g/wikimedia/mediawiki-extensions-WikibaseQualityConstraints/?branch=master
 [wbq]: https://github.com/wikimedia/mediawiki-extensions-WikibaseQuality.git

-- 
To view, visit https://gerrit.wikimedia.org/r/405916
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64bc71d98ea5a36aa5a7e5932a80731bbec3334e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add notification for #wikidata-feed on IRC

2018-01-23 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405915 )

Change subject: Add notification for #wikidata-feed on IRC
..

Add notification for #wikidata-feed on IRC

If the Travis build fails, or becomes successful again, post a message
in #wikidata-feed. Copied from change I220b6653e7.

Change-Id: Ifee21b2a6aafa9f9bcd74ec5bb427f6fb5c9415d
---
M .travis.yml
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/15/405915/1

diff --git a/.travis.yml b/.travis.yml
index d2c00af..333a25f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,4 +28,11 @@
   - bash ./build/travis/after_script.sh
 
 notifications:
+  irc:
+channels:
+  - "chat.freenode.net#wikidata-feed"
+on_success: change
+on_failure: always
+template:
+  - "%{repository}/%{branch}/%{commit} : %{author} %{message} %{build_url}"
   slack: wikidataquality:6RzuL6LCKzoPupOKuNUhpCSt

-- 
To view, visit https://gerrit.wikimedia.org/r/405915
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifee21b2a6aafa9f9bcd74ec5bb427f6fb5c9415d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] wikibase/property-suggester-scripts[master]: Report of travis status

2018-01-23 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/405911 )

Change subject: Report of travis status
..


Report of travis status

Change-Id: I220b6653e79de3ac082323bcfa06428fa4e4f38e
---
M .travis.yml
1 file changed, 14 insertions(+), 0 deletions(-)

Approvals:
  Lucas Werkmeister (WMDE): Verified; Looks good to me, approved



diff --git a/.travis.yml b/.travis.yml
index b490bbe..002a4ff 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,3 +14,17 @@
 
 after_success:
 - codecov
+
+notifications:
+email:
+recipients:
+- ladsgr...@gmail.com
+on_success: change
+on_failure: always
+irc:
+channels:
+- "chat.freenode.net#wikidata-feed"
+on_success: change
+on_failure: always
+template:
+- "%{repository}/%{branch}/%{commit} : %{author} %{message} 
%{build_url}"

-- 
To view, visit https://gerrit.wikimedia.org/r/405911
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I220b6653e79de3ac082323bcfa06428fa4e4f38e
Gerrit-PatchSet: 1
Gerrit-Project: wikibase/property-suggester-scripts
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup 
Gerrit-Reviewer: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Don’t load gadget when not in edit mode

2018-01-23 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405904 )

Change subject: Don’t load gadget when not in edit mode
..

Don’t load gadget when not in edit mode

If Wikibase is not in edit mode – for example, because we’re on a diff
page, or on an older revision – don’t show constraint reports either.

(Note that wbIsEditView is a page-wide property, independent of user
permissions: if a registered user lacks permissions to edit a protected
page, it still makes sense to show them constraint violations, since
they can at least alert others to them on talk pages or project chat.)

Bug: T184623

Change-Id: Ic169e8e34ae2a291f24b17c6fab680af161be6e7
---
M modules/gadget-skip.js
M modules/gadget.js
M src/WikibaseQualityConstraintsHooks.php
3 files changed, 6 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/04/405904/1

diff --git a/modules/gadget-skip.js b/modules/gadget-skip.js
index 3921674..cdc2b58 100644
--- a/modules/gadget-skip.js
+++ b/modules/gadget-skip.js
@@ -1 +1 @@
-return !mw.config.exists( 'wbEntityId' ) || mw.config.get( 'wgMFMode' );
+return !mw.config.exists( 'wbEntityId' ) || mw.config.get( 'wgMFMode' ) || 
!mw.config.get( 'wbIsEditView' );
diff --git a/modules/gadget.js b/modules/gadget.js
index da4d542..0983a7d 100644
--- a/modules/gadget.js
+++ b/modules/gadget.js
@@ -291,8 +291,8 @@
 
entityId = mw.config.get( 'wbEntityId' );
 
-   if ( entityId === null || mw.config.get( 'wgMFMode' ) ) {
-   // no entity or mobile frontend, skip
+   if ( entityId === null || mw.config.get( 'wgMFMode' ) || 
!mw.config.get( 'wbIsEditView' ) ) {
+   // no entity, mobile frontend, or not editing (diff, oldid, …) 
– skip
return;
}
 
diff --git a/src/WikibaseQualityConstraintsHooks.php 
b/src/WikibaseQualityConstraintsHooks.php
index 1dd1de7..71f32af 100644
--- a/src/WikibaseQualityConstraintsHooks.php
+++ b/src/WikibaseQualityConstraintsHooks.php
@@ -132,6 +132,9 @@
if ( !$out->getUser()->isLoggedIn() ) {
return;
}
+   if ( !$out->getJsConfigVars()['wbIsEditView'] ) {
+   return;
+   }
 
if ( self::isGadgetEnabledForUserName( 
$out->getUser()->getName(), time() ) ) {
$out->addModules( 'wikibase.quality.constraints.gadget' 
);

-- 
To view, visit https://gerrit.wikimedia.org/r/405904
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic169e8e34ae2a291f24b17c6fab680af161be6e7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Don’t use NewStatement to build standalone snaks

2018-01-23 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405897 )

Change subject: Don’t use NewStatement to build standalone snaks
..

Don’t use NewStatement to build standalone snaks

Using NewStatement::…->build()->getMainSnak() just to construct a Snak
is a cute trick, sure, but it’s actually longer than just constructing
the PropertyId and Snak objects directly :)

Bug: T168240
Change-Id: I67bcadf917073b7619bd90cdbfe0e3cb6a06ae1f
---
M tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
M tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php
M tests/phpunit/Context/QualifierContextTest.php
M tests/phpunit/Context/ReferenceContextTest.php
4 files changed, 43 insertions(+), 36 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/97/405897/1

diff --git a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php 
b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
index 683b37d..0b71096 100644
--- a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
+++ b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
@@ -2,7 +2,10 @@
 
 namespace WikibaseQuality\ConstraintReport\Test\ValueCountChecker;
 
+use Wikibase\DataModel\Entity\PropertyId;
 use Wikibase\DataModel\Reference;
+use Wikibase\DataModel\Snak\PropertyNoValueSnak;
+use Wikibase\DataModel\Snak\PropertySomeValueSnak;
 use Wikibase\Repo\Tests\NewItem;
 use Wikibase\Repo\Tests\NewStatement;
 use WikibaseQuality\ConstraintReport\Constraint;
@@ -78,8 +81,8 @@
}
 
public function testMultiValueConstraint_One_Qualifier() {
-   $qualifier1 = NewStatement::noValueFor( 'P1' 
)->build()->getMainSnak();
-   $qualifier2 = NewStatement::noValueFor( 'P2' 
)->build()->getMainSnak();
+   $qualifier1 = new PropertyNoValueSnak( new PropertyId( 'P1' ) );
+   $qualifier2 = new PropertyNoValueSnak( new PropertyId( 'P2' ) );
$statement = NewStatement::someValueFor( 'P10' )->build();
$statement->getQualifiers()->addSnak( $qualifier1 );
$statement->getQualifiers()->addSnak( $qualifier2 );
@@ -94,8 +97,8 @@
}
 
public function testMultiValueConstraint_Two_Reference() {
-   $referenceSnak1 = NewStatement::noValueFor( 'P1' 
)->build()->getMainSnak();
-   $referenceSnak2 = NewStatement::someValueFor( 'P1' 
)->build()->getMainSnak();
+   $referenceSnak1 = new PropertyNoValueSnak( new PropertyId( 'P1' 
) );
+   $referenceSnak2 = new PropertySomeValueSnak( new PropertyId( 
'P1' ) );
$reference = new Reference( [ $referenceSnak1, $referenceSnak2 
] );
$statement = NewStatement::someValueFor( 'P10' )->build();
$statement->getReferences()->addReference( $reference );
diff --git a/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php 
b/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php
index 6afd45d..4a0e53c 100644
--- a/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php
+++ b/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php
@@ -2,7 +2,10 @@
 
 namespace WikibaseQuality\ConstraintReport\Test\ValueCountChecker;
 
+use Wikibase\DataModel\Entity\PropertyId;
 use Wikibase\DataModel\Reference;
+use Wikibase\DataModel\Snak\PropertyNoValueSnak;
+use Wikibase\DataModel\Snak\PropertySomeValueSnak;
 use Wikibase\Repo\Tests\NewItem;
 use Wikibase\Repo\Tests\NewStatement;
 use WikibaseQuality\ConstraintReport\Constraint;
@@ -78,8 +81,8 @@
}
 
public function testSingleValueConstraint_One_Qualifier() {
-   $qualifier1 = NewStatement::noValueFor( 'P1' 
)->build()->getMainSnak();
-   $qualifier2 = NewStatement::noValueFor( 'P2' 
)->build()->getMainSnak();
+   $qualifier1 = new PropertyNoValueSnak( new PropertyId( 'P1' ) );
+   $qualifier2 = new PropertyNoValueSnak( new PropertyId( 'P2' ) );
$statement = NewStatement::someValueFor( 'P10' )->build();
$statement->getQualifiers()->addSnak( $qualifier1 );
$statement->getQualifiers()->addSnak( $qualifier2 );
@@ -94,8 +97,8 @@
}
 
public function testSingleValueConstraint_Two_Reference() {
-   $referenceSnak1 = NewStatement::noValueFor( 'P1' 
)->build()->getMainSnak();
-   $referenceSnak2 = NewStatement::someValueFor( 'P1' 
)->build()->getMainSnak();
+   $referenceSnak1 = new PropertyNoValueSnak( new PropertyId( 'P1' 
) );
+   $referenceSnak2 = new PropertySomeValueSnak( new PropertyId( 
'P1' ) );
$reference = new Reference( [ $referenceSnak1, $referenceSnak2 
] );
$statement = NewStatement::someValueFor( 'P10' 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Expand ReferenceContextTest::testGetSnakGroup

2018-01-23 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405893 )

Change subject: Expand ReferenceContextTest::testGetSnakGroup
..

Expand ReferenceContextTest::testGetSnakGroup

This expands the test for ReferenceContext::getSnakGroup() to make sure
that the function doesn’t look at qualifiers of the statement, or any
any part of completely unrelated other statements. Previously, we only
checked that the function didn’t look at other references.

Bug: T168240
Change-Id: Idc7b6d44e10c4b0b9471f915474cd4d136daa4dc
---
M tests/phpunit/Context/ReferenceContextTest.php
1 file changed, 16 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/93/405893/1

diff --git a/tests/phpunit/Context/ReferenceContextTest.php 
b/tests/phpunit/Context/ReferenceContextTest.php
index 5d9ec29..2d25500 100644
--- a/tests/phpunit/Context/ReferenceContextTest.php
+++ b/tests/phpunit/Context/ReferenceContextTest.php
@@ -6,6 +6,8 @@
 use Wikibase\DataModel\Reference;
 use Wikibase\DataModel\ReferenceList;
 use Wikibase\DataModel\Snak\PropertyNoValueSnak;
+use Wikibase\DataModel\Snak\PropertySomeValueSnak;
+use Wikibase\DataModel\Snak\SnakList;
 use Wikibase\DataModel\Statement\Statement;
 use Wikibase\Repo\Tests\NewItem;
 use Wikibase\Repo\Tests\NewStatement;
@@ -85,17 +87,26 @@
public function testGetSnakGroup() {
$referenceSnak1 = NewStatement::noValueFor( 'P100' 
)->build()->getMainSnak();
$referenceSnak2 = NewStatement::someValueFor( 'P200' 
)->build()->getMainSnak();
+   $referenceSnak3 = NewStatement::noValueFor( 'P300' 
)->build()->getMainSnak();
+   $referenceSnak4 = NewStatement::someValueFor( 'P400' 
)->build()->getMainSnak();
$reference1 = new Reference( [ $referenceSnak1, $referenceSnak2 
] );
-   $reference2 = new Reference( [ new PropertyNoValueSnak( new 
PropertyId( 'P300' ) ) ] );
-   $statement = new Statement(
+   $reference2 = new Reference( [ $referenceSnak3 ] );
+   $reference3 = new Reference( [ $referenceSnak4 ] );
+   $statement1 = new Statement(
new PropertyNoValueSnak( new PropertyId( 'P1' ) ),
-   null,
+   /* qualifiers = */ new SnakList( [ $referenceSnak3 ] ),
new ReferenceList( [ $reference1, $reference2 ] )
);
+   $statement2 = new Statement(
+   new PropertySomeValueSnak( new PropertyId( 'P2' ) ),
+   null,
+   new ReferenceList( [ $reference2, $reference3 ] )
+   );
$entity = NewItem::withId( 'Q1' )
-   ->andStatement( $statement )
+   ->andStatement( $statement1 )
+   ->andStatement( $statement2 )
->build();
-   $context = new ReferenceContext( $entity, $statement, 
$reference1, $referenceSnak1 );
+   $context = new ReferenceContext( $entity, $statement1, 
$reference1, $referenceSnak1 );
 
$snakGroup = $context->getSnakGroup();
 

-- 
To view, visit https://gerrit.wikimedia.org/r/405893
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc7b6d44e10c4b0b9471f915474cd4d136daa4dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQuality[master]: Remove redundant @package tags

2018-01-23 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405866 )

Change subject: Remove redundant @package tags
..

Remove redundant @package tags

See WikibaseQualityConstraints commit 0d5c5e7156 (change Ib0a0cb771d).

Change-Id: I09576b8a1a73d9d0aa7536441e206e32b8f15cd9
---
M includes/Html/HtmlTableBuilder.php
M includes/Html/HtmlTableCellBuilder.php
M includes/Html/HtmlTableHeaderBuilder.php
3 files changed, 0 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQuality 
refs/changes/66/405866/1

diff --git a/includes/Html/HtmlTableBuilder.php 
b/includes/Html/HtmlTableBuilder.php
index c1009ad..d6aa1a6 100644
--- a/includes/Html/HtmlTableBuilder.php
+++ b/includes/Html/HtmlTableBuilder.php
@@ -7,7 +7,6 @@
 use Wikimedia\Assert\Assert;
 
 /**
- * @package WikibaseQuality\Html
  * @author BP2014N1
  * @license GNU GPL v2+
  */
diff --git a/includes/Html/HtmlTableCellBuilder.php 
b/includes/Html/HtmlTableCellBuilder.php
index 96ccdf7..574c68d 100644
--- a/includes/Html/HtmlTableCellBuilder.php
+++ b/includes/Html/HtmlTableCellBuilder.php
@@ -7,7 +7,6 @@
 use Wikimedia\Assert\Assert;
 
 /**
- * @package WikibaseQuality\Html
  * @author BP2014N1
  * @license GNU GPL v2+
  */
diff --git a/includes/Html/HtmlTableHeaderBuilder.php 
b/includes/Html/HtmlTableHeaderBuilder.php
index ffbb931..2c0ad75 100644
--- a/includes/Html/HtmlTableHeaderBuilder.php
+++ b/includes/Html/HtmlTableHeaderBuilder.php
@@ -7,7 +7,6 @@
 use Wikimedia\Assert\Assert;
 
 /**
- * @package WikibaseQuality\Html
  * @author BP2014N1
  * @license GNU GPL v2+
  */

-- 
To view, visit https://gerrit.wikimedia.org/r/405866
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I09576b8a1a73d9d0aa7536441e206e32b8f15cd9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQuality
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Update php-coveralls

2018-01-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405731 )

Change subject: Update php-coveralls
..

Update php-coveralls

There are two things going on here. Firstly, the binary was renamed from
coveralls to php-coveralls, which we need to account for in our Travis
script. However, this binary cannot actually be found in the
satooshi/php-coveralls package – composer prints a warning about that.
I’m not sure what the php-coveralls folks have done here, but in any
event, using the new package name php-coveralls/php-coveralls seems to
fix the problem (it was apparently renamed at some point as well).

Change-Id: I7ee5100d447176acbeeae3c50af5c304ef688e55
---
M build/travis/after_script.sh
M composer.json
2 files changed, 2 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/31/405731/1

diff --git a/build/travis/after_script.sh b/build/travis/after_script.sh
index 1b74a26..a37904a 100755
--- a/build/travis/after_script.sh
+++ b/build/travis/after_script.sh
@@ -2,4 +2,4 @@
 
 cd ../wiki/extensions/WikibaseQualityConstraints
 
-php vendor/bin/coveralls -v
+php vendor/bin/php-coveralls -v
diff --git a/composer.json b/composer.json
index c836b1d..d5bf7b2 100644
--- a/composer.json
+++ b/composer.json
@@ -31,7 +31,7 @@
"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",
+   "php-coveralls/php-coveralls": "master-dev",
"wikibase/wikibase-codesniffer": "^0.2.0",
"mediawiki/minus-x": "0.2.1"
},

-- 
To view, visit https://gerrit.wikimedia.org/r/405731
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ee5100d447176acbeeae3c50af5c304ef688e55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[wmf/1.31.0-wmf.17]: Add missing DISTINCT to SPARQL query

2018-01-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405728 )

Change subject: Add missing DISTINCT to SPARQL query
..

Add missing DISTINCT to SPARQL query

Bug: T184705
Change-Id: Ie76949e4b85e9529b5b721691e5e6e5b8c46d319
(cherry picked from commit e6e6d4f34422c921e0c4246534fb315b69d433ad)
---
M src/ConstraintCheck/Helper/SparqlHelper.php
M tests/phpunit/Helper/SparqlHelperTest.php
2 files changed, 4 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/28/405728/1

diff --git a/src/ConstraintCheck/Helper/SparqlHelper.php 
b/src/ConstraintCheck/Helper/SparqlHelper.php
index 3855258..db7dc49 100644
--- a/src/ConstraintCheck/Helper/SparqlHelper.php
+++ b/src/ConstraintCheck/Helper/SparqlHelper.php
@@ -179,7 +179,7 @@
}
 
$query = <

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Use list() without space before the parenthesis

2018-01-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405726 )

Change subject: Use list() without space before the parenthesis
..

Use list() without space before the parenthesis

The `list ()` variant will be forbidden once the underlying MediaWiki
ruleset is updated to 0.11.1 (part of wmde/WikibaseCodeSniffer#18,
expected to become wikibase/wikibase-codesniffer 0.3.0).

Change-Id: Id79298185cba92f66220ad0738552f478e7ca4a1
---
M src/ConstraintCheck/Checker/CommonsLinkChecker.php
M src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
M src/ConstraintCheck/Helper/SparqlHelper.php
3 files changed, 3 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/26/405726/1

diff --git a/src/ConstraintCheck/Checker/CommonsLinkChecker.php 
b/src/ConstraintCheck/Checker/CommonsLinkChecker.php
index 928e257..c091c23 100644
--- a/src/ConstraintCheck/Checker/CommonsLinkChecker.php
+++ b/src/ConstraintCheck/Checker/CommonsLinkChecker.php
@@ -146,7 +146,7 @@
if ( !$this->commonsLinkIsWellFormed( $commonsLink ) ) {
throw new MalformedTitleException( 
'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // 
caught below
}
-   list ( $defaultNamespace, $prefix ) = 
$this->getCommonsNamespace( $namespace );
+   list( $defaultNamespace, $prefix ) = 
$this->getCommonsNamespace( $namespace );
$title = $this->titleParser->parseTitle( $prefix . 
$commonsLink, $defaultNamespace );
if ( $this->pageExists( $title ) ) {
$message = '';
diff --git a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 
b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
index f516bbd..d1c74ca 100644
--- a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
+++ b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
@@ -159,7 +159,7 @@
$minuend = $snak->getDataValue();
 
/** @var PropertyId $property */
-   list ( $min, $max, $property, $parameters ) = 
$this->parseConstraintParameters( $constraint );
+   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)
/** @var Statement $otherStatement */
diff --git a/src/ConstraintCheck/Helper/SparqlHelper.php 
b/src/ConstraintCheck/Helper/SparqlHelper.php
index 54bf3f7..86e851b 100644
--- a/src/ConstraintCheck/Helper/SparqlHelper.php
+++ b/src/ConstraintCheck/Helper/SparqlHelper.php
@@ -220,7 +220,7 @@
$dataType = 
$this->propertyDataTypeLookup->getDataTypeIdForProperty(
$snak->getPropertyId()
);
-   list ( $value, $isFullValue ) = $this->getRdfLiteral( 
$dataType, $dataValue );
+   list( $value, $isFullValue ) = $this->getRdfLiteral( $dataType, 
$dataValue );
if ( $isFullValue ) {
$prefix .= 'v';
}

-- 
To view, visit https://gerrit.wikimedia.org/r/405726
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id79298185cba92f66220ad0738552f478e7ca4a1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Rename @dataProvider methods to provide…()

2018-01-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405724 )

Change subject: Rename @dataProvider methods to provide…()
..

Rename @dataProvider methods to provide…()

According to MediaWiki guidelines [1], the name of a data provider
should begin with “provide”. Previously, we used several styles
inconsistently in this extension (mostly “get…Provider”). This commit
brings them all in line with the MediaWiki guidelines. In my opinion,
this sometimes makes the tests more readable as well, since the method
name now documents what it actually provides, not just what the test
method to which it belongs is called.

[1]: https://www.mediawiki.org/wiki/Special:PermanentLink/2678449#Data_providers

Bug: T168240
Change-Id: I51f476ff74cf2abd4934f2568268b429f0c39651
---
M tests/phpunit/Cache/CachingMetadataTest.php
M tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php
M tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php
M tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
M tests/phpunit/Checker/ReferenceCheckerTest.php
M tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
M tests/phpunit/Checker/ValueOnlyCheckerTest.php
M tests/phpunit/Helper/LoggingHelperTest.php
M tests/phpunit/Helper/SparqlHelperTest.php
M tests/phpunit/Specials/SpecialConstraintReportTest.php
M tests/phpunit/WikibaseQualityConstraintsHooksTest.php
11 files changed, 32 insertions(+), 32 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/24/405724/1

diff --git a/tests/phpunit/Cache/CachingMetadataTest.php 
b/tests/phpunit/Cache/CachingMetadataTest.php
index 7d35290..8fee5dd 100644
--- a/tests/phpunit/Cache/CachingMetadataTest.php
+++ b/tests/phpunit/Cache/CachingMetadataTest.php
@@ -118,7 +118,7 @@
}
 
/**
-* @dataProvider arrayRoundTripProvider
+* @dataProvider provideCachingMetadata
 */
public function testOfArray_RoundTrip( CachingMetadata $cm ) {
$array = $cm->toArray();
@@ -127,7 +127,7 @@
$this->assertEquals( $cm, $cm_ );
}
 
-   public function arrayRoundTripProvider() {
+   public function provideCachingMetadata() {
return [
[ CachingMetadata::fresh() ],
[ CachingMetadata::ofMaximumAgeInSeconds( 52 ) ],
diff --git a/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php 
b/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php
index 0d6796b..4cdc91b 100644
--- a/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php
+++ b/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php
@@ -37,7 +37,7 @@
/**
 * @param string $type context type
 * @param string|null $messageKey key of violation message, or null if 
compliance is expected
-* @dataProvider contextTypes
+* @dataProvider provideContextTypes
 */
public function testQualifierConstraint( $type, $messageKey ) {
$context = $this->getMock( Context::class );
@@ -54,7 +54,7 @@
}
}
 
-   public function contextTypes() {
+   public function provideContextTypes() {
return [
[ Context::TYPE_STATEMENT, 
'wbqc-violation-message-qualifier' ],
[ Context::TYPE_QUALIFIER, null ],
diff --git a/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php 
b/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php
index 32053bf..67caac5 100644
--- a/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php
+++ b/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php
@@ -41,7 +41,7 @@
}
 
/**
-* @dataProvider getComparisonProvider
+* @dataProvider provideComparisons
 */
public function testGetComparison( $expected, DataValue $lhs, DataValue 
$rhs ) {
$this->assertContains( $expected, [ -1, 0, 1 ], '$expected must 
be -1, 0, or 1' );
@@ -60,7 +60,7 @@
}
}
 
-   public function getComparisonProvider() {
+   public function provideComparisons() {
$cases = [
[ -1, $this->getTimeValue( 1970 ), $this->getTimeValue( 
1971 ) ],
[ 0, $this->getTimeValue( 1970 ), $this->getTimeValue( 
1970 ) ],
@@ -80,7 +80,7 @@
}
 
/**
-* @dataProvider getDifferenceProvider
+* @dataProvider provideDifferences
 */
public function testGetDifference( $expected, DataValue $minuend, 
DataValue $subtrahend ) {
$rangeCheckHelper = $this->getRangeCheckerHelper();
@@ -89,7 +89,7 @@
$this->assertSame( (float)$expected, $actual );
}
 
-   public function getDifferenceProvider() {
+   public function 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add tests for ConstraintParameterRenderer

2018-01-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405721 )

Change subject: Add tests for ConstraintParameterRenderer
..

Add tests for ConstraintParameterRenderer

This adds tests for all the methods of ConstraintParameterRenderer which
are called by constraint checkers or ConstraintParameterParser. On the
other hand, the formatValue and formatParameters methods are only used
for the special page (and by the API if the “detail” and “detailHTML”
fields are included), and might be removed completely depending on the
outcome of T185091.

Bug: T169121
Change-Id: Ifb48530ac0fe26ec1866a8c766c7198a5853d9bc
---
A tests/phpunit/ConstraintParameterRendererTest.php
1 file changed, 654 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/21/405721/1

diff --git a/tests/phpunit/ConstraintParameterRendererTest.php 
b/tests/phpunit/ConstraintParameterRendererTest.php
new file mode 100644
index 000..0bd1edc
--- /dev/null
+++ b/tests/phpunit/ConstraintParameterRendererTest.php
@@ -0,0 +1,654 @@
+assertSame( $value, $formatted );
+   }
+
+   public function testFormatByRole_Subject() {
+   $role = Role::SUBJECT;
+   $value = 'foo assertSame(
+   ''. $value . 
'',
+   $formatted
+   );
+   }
+
+   public function testFormatDataValue() {
+   $role = Role::OBJECT;
+   $value = new StringValue( 'a test string' );
+   $valueFormatter = $this->getMock( ValueFormatter::class );
+   $valueFormatter->expects( $this->once() )
+   ->method( 'format' )
+   ->with( $value )
+   ->willReturn( 'a test 
string' );
+   $constraintParameterRenderer = new ConstraintParameterRenderer(
+   new PlainEntityIdFormatter(),
+   $valueFormatter,
+   $this->getDefaultConfig()
+   );
+
+   $formatted = $constraintParameterRenderer->formatDataValue( 
$value, $role );
+
+   $this->assertSame(
+   '' .
+   'a test 
string' .
+   '',
+   $formatted
+   );
+   }
+
+   public function testFormatEntityId() {
+   $role = Role::PREDICATE;
+   $value = new PropertyId( 'P1234' );
+   $entityIdFormatter = $this->getMock( EntityIdFormatter::class );
+   $entityIdFormatter->expects( $this->once() )
+   ->method( 'formatEntityId' )
+   ->with( $value )
+   ->willReturn( 'some 
property' );
+   $constraintParameterRenderer = new ConstraintParameterRenderer(
+   $entityIdFormatter,
+   new StringFormatter(),
+   $this->getDefaultConfig()
+   );
+
+   $formatted = $constraintParameterRenderer->formatEntityId( 
$value, $role );
+
+   $this->assertSame(
+   '' .
+   'some 
property' .
+   '',
+   $formatted
+   );
+   }
+
+   public function testFormatPropertyId_PropertyId() {
+   $value = new PropertyId( 'P1234' );
+   $constraintParameterRenderer = $this->getMockBuilder( 
ConstraintParameterRenderer::class )
+   ->disableOriginalConstructor()
+   ->setMethods( [ 'formatEntityId' ] )
+   ->getMock();
+   $constraintParameterRenderer->expects( $this->once() )
+   ->method( 'formatEntityId' )
+   ->with( $value )
+   ->willReturn( 'some property' );
+
+   $formatted = $constraintParameterRenderer->formatPropertyId( 
$value );
+
+   $this->assertSame( 'some property', $formatted );
+   }
+
+   public function testFormatPropertyId_PropertyIdSerialization() {
+   $value = 'P1234';
+   $constraintParameterRenderer = $this->getMockBuilder( 
ConstraintParameterRenderer::class )
+   ->disableOriginalConstructor()
+   ->setMethods( [ 'formatEntityId' ] )
+   ->getMock();
+   $constraintParameterRenderer->expects( $this->once() )
+   ->method( 'formatEntityId' )
+   ->willReturnCallback( function ( PropertyId $propertyId 
) use ( $value ) {
+   $this->assertSame( $value, 
$propertyId->getSerialization() );
+   return 'some property';
+   } );
+
+   

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Check “difference within range” on qualifiers and references

2018-01-19 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405293 )

Change subject: Check “difference within range” on qualifiers and references
..

Check “difference within range” on qualifiers and references

To implement this, we can simply use Context::getSiblingSnaks(), since
the semantics of that method are to ignore deprecated statements, just
like DiffWithinRangeChecker also used to do.

Unfortunately, a lot of changes in the tests are necessary:
getSiblingSnaks() does not include the current snak, and in the case of
MainSnakContext, this is achieved by removing statements with the same
GUID – so all the test cases have to be adjusted to assign some GUID to
the statements they create, otherwise too many statements are removed.

Two new tests are also added, one for qualifiers and one for references.

Bug: T175565
Change-Id: I21c4b0ec82baf461b38aca0022db3fbf70ebb651
---
M src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
M tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php
2 files changed, 168 insertions(+), 57 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/93/405293/1

diff --git a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 
b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
index f516bbd..e7cd7d5 100644
--- a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
+++ b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
@@ -67,9 +67,8 @@
public function getSupportedContextTypes() {
return [
Context::TYPE_STATEMENT => 
CheckResult::STATUS_COMPLIANCE,
-   // TODO T175565
-   Context::TYPE_QUALIFIER => CheckResult::STATUS_TODO,
-   Context::TYPE_REFERENCE => CheckResult::STATUS_TODO,
+   Context::TYPE_QUALIFIER => 
CheckResult::STATUS_COMPLIANCE,
+   Context::TYPE_REFERENCE => 
CheckResult::STATUS_COMPLIANCE,
];
}
 
@@ -79,9 +78,8 @@
public function getDefaultContextTypes() {
return [
Context::TYPE_STATEMENT,
-   // TODO T175565
-   // Context::TYPE_QUALIFIER,
-   // Context::TYPE_REFERENCE,
+   Context::TYPE_QUALIFIER,
+   Context::TYPE_REFERENCE,
];
}
 
@@ -162,19 +160,15 @@
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)
-   /** @var Statement $otherStatement */
-   foreach ( $context->getEntity()->getStatements() as 
$otherStatement ) {
-   $otherMainSnak = $otherStatement->getMainSnak();
-
+   foreach ( $context->getSiblingSnaks() as $otherSnak ) {
if (
-   !$property->equals( 
$otherStatement->getPropertyId() ) ||
-   $otherStatement->getRank() === 
Statement::RANK_DEPRECATED ||
-   !$otherMainSnak instanceof PropertyValueSnak
+   !$property->equals( $otherSnak->getPropertyId() 
) ||
+   !$otherSnak instanceof PropertyValueSnak
) {
continue;
}
 
-   $subtrahend = $otherMainSnak->getDataValue();
+   $subtrahend = $otherSnak->getDataValue();
if ( $subtrahend->getType() === $minuend->getType() ) {
$diff = $this->rangeInYears( $min, $max ) ?

$this->rangeCheckerHelper->getDifferenceInYears( $minuend, $subtrahend ) :
@@ -189,7 +183,7 @@
$message->rawParams(

$this->constraintParameterRenderer->formatEntityId( 
$context->getSnak()->getPropertyId(), Role::PREDICATE ),

$this->constraintParameterRenderer->formatDataValue( $minuend, Role::OBJECT ),
-   
$this->constraintParameterRenderer->formatEntityId( 
$otherStatement->getPropertyId(), Role::PREDICATE ),
+   
$this->constraintParameterRenderer->formatEntityId( 
$otherSnak->getPropertyId(), Role::PREDICATE ),

$this->constraintParameterRenderer->formatDataValue( $subtrahend, Role::OBJECT )
);
if ( $min !== null 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Support qualifier and reference in value count checkers

2018-01-19 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405282 )

Change subject: Support qualifier and reference in value count checkers
..

Support qualifier and reference in value count checkers

On the part of the checkers, this just means declaring support for the
'qualifier' and 'reference' context types – all the actual work is done
by the getSiblingSnaks() implementations and the
ValueCountCheckerHelper. For the tests, I added just one test for
qualifiers and one for references (instead of having tests with one and
two snaks for each context), since I think it’s unlikely that extra
tests would uncover any more faults (both the getSiblingSnaks()
implementations and ValueCountCheckerHelper already have more tests
elsewhere).

Change-Id: Id1ef2d371a479f9520c0b135abc0abc01169de09
---
M src/ConstraintCheck/Checker/MultiValueChecker.php
M src/ConstraintCheck/Checker/SingleValueChecker.php
M tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
M tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php
4 files changed, 70 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/82/405282/1

diff --git a/src/ConstraintCheck/Checker/MultiValueChecker.php 
b/src/ConstraintCheck/Checker/MultiValueChecker.php
index 7014060..c76301d 100644
--- a/src/ConstraintCheck/Checker/MultiValueChecker.php
+++ b/src/ConstraintCheck/Checker/MultiValueChecker.php
@@ -30,9 +30,8 @@
public function getSupportedContextTypes() {
return [
Context::TYPE_STATEMENT => 
CheckResult::STATUS_COMPLIANCE,
-   // TODO T175566
-   Context::TYPE_QUALIFIER => CheckResult::STATUS_TODO,
-   Context::TYPE_REFERENCE => CheckResult::STATUS_TODO,
+   Context::TYPE_QUALIFIER => 
CheckResult::STATUS_COMPLIANCE,
+   Context::TYPE_REFERENCE => 
CheckResult::STATUS_COMPLIANCE,
];
}
 
diff --git a/src/ConstraintCheck/Checker/SingleValueChecker.php 
b/src/ConstraintCheck/Checker/SingleValueChecker.php
index dcf26fc..0ad2661 100644
--- a/src/ConstraintCheck/Checker/SingleValueChecker.php
+++ b/src/ConstraintCheck/Checker/SingleValueChecker.php
@@ -30,9 +30,8 @@
public function getSupportedContextTypes() {
return [
Context::TYPE_STATEMENT => 
CheckResult::STATUS_COMPLIANCE,
-   // TODO T175566
-   Context::TYPE_QUALIFIER => CheckResult::STATUS_TODO,
-   Context::TYPE_REFERENCE => CheckResult::STATUS_TODO,
+   Context::TYPE_QUALIFIER => 
CheckResult::STATUS_COMPLIANCE,
+   Context::TYPE_REFERENCE => 
CheckResult::STATUS_COMPLIANCE,
];
}
 
diff --git a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php 
b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
index 962ddf7..cfdd52d 100644
--- a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
+++ b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
@@ -2,11 +2,14 @@
 
 namespace WikibaseQuality\ConstraintReport\Test\ValueCountChecker;
 
+use Wikibase\DataModel\Reference;
 use Wikibase\Repo\Tests\NewItem;
 use Wikibase\Repo\Tests\NewStatement;
 use WikibaseQuality\ConstraintReport\Constraint;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MultiValueChecker;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Context\MainSnakContext;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Context\QualifierContext;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Context\ReferenceContext;
 use WikibaseQuality\ConstraintReport\Tests\ResultAssertions;
 
 /**
@@ -74,6 +77,36 @@
$this->assertViolation( $checkResult, 
'wbqc-violation-message-multi-value' );
}
 
+   public function testMultiValueConstraint_One_Qualifier() {
+   $qualifier1 = NewStatement::noValueFor( 'P1' 
)->build()->getMainSnak();
+   $qualifier2 = NewStatement::noValueFor( 'P2' 
)->build()->getMainSnak();
+   $statement = NewStatement::someValueFor( 'P10' )->build();
+   $statement->getQualifiers()->addSnak( $qualifier1 );
+   $statement->getQualifiers()->addSnak( $qualifier2 );
+   $item = NewItem::withStatement( $statement )
+   ->andStatement( NewStatement::someValueFor( 'P1' ) )
+   ->build();
+   $context = new QualifierContext( $item, $statement, $qualifier1 
);
+
+   $checkResult = $this->checker->checkConstraint( $context, 
$this->constraint );
+
+   $this->assertViolation( $checkResult, 
'wbqc-violation-message-multi-value' );
+   }
+
+   

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Rewrite ValueCountCheckerHelper

2018-01-18 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405033 )

Change subject: Rewrite ValueCountCheckerHelper
..

Rewrite ValueCountCheckerHelper

ValueCountCheckerHelper now receives a Snak[] instead of a
StatementList, and also receives the property ID to look for instead of
returning an array of the counts of all properties. SingleValueChecker
and MultiValueChecker are adjusted accordingly and pass the sibling
snaks of the context into ValueCountCheckerHelper.

This does not yet provide proper support for checking those constraints
on qualifiers and references, since the checkers declare to not support
those types yet. getSupportedContextTypes will be adjusted in a separate
commit which will also add tests for checking these constraints on
qualifiers and references.

Bug: T175566
Change-Id: I301400edd29b0a10ffc131fd5a20bf6e3b193852
---
M src/ConstraintCheck/Checker/MultiValueChecker.php
M src/ConstraintCheck/Checker/SingleValueChecker.php
M src/ConstraintCheck/Helper/ValueCountCheckerHelper.php
M tests/phpunit/Checker/ValueCountChecker/ValueCountCheckerHelperTest.php
4 files changed, 44 insertions(+), 50 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/33/405033/1

diff --git a/src/ConstraintCheck/Checker/MultiValueChecker.php 
b/src/ConstraintCheck/Checker/MultiValueChecker.php
index 6f200d4..7014060 100644
--- a/src/ConstraintCheck/Checker/MultiValueChecker.php
+++ b/src/ConstraintCheck/Checker/MultiValueChecker.php
@@ -64,9 +64,12 @@
 
$parameters = [];
 
-   $propertyCountArray = 
$this->valueCountCheckerHelper->getPropertyCount( 
$context->getEntity()->getStatements() );
+   $propertyCount = 
$this->valueCountCheckerHelper->getPropertyCount(
+   $context->getSiblingSnaks(),
+   $propertyId
+   ) + 1; // the sibling snaks do not include the context’s own 
snak
 
-   if ( $propertyCountArray[$propertyId->getSerialization()] <= 1 
) {
+   if ( $propertyCount <= 1 ) {
$message = wfMessage( 
"wbqc-violation-message-multi-value" )->escaped();
$status = CheckResult::STATUS_VIOLATION;
} else {
diff --git a/src/ConstraintCheck/Checker/SingleValueChecker.php 
b/src/ConstraintCheck/Checker/SingleValueChecker.php
index 5218b78..dcf26fc 100644
--- a/src/ConstraintCheck/Checker/SingleValueChecker.php
+++ b/src/ConstraintCheck/Checker/SingleValueChecker.php
@@ -64,9 +64,12 @@
 
$parameters = [];
 
-   $propertyCountArray = 
$this->valueCountCheckerHelper->getPropertyCount( 
$context->getEntity()->getStatements() );
+   $propertyCount = 
$this->valueCountCheckerHelper->getPropertyCount(
+   $context->getSiblingSnaks(),
+   $propertyId
+   ) + 1; // the sibling snaks do not include the context’s own 
snak
 
-   if ( $propertyCountArray[$propertyId->getSerialization()] > 1 ) 
{
+   if ( $propertyCount > 1 ) {
$message = wfMessage( 
"wbqc-violation-message-single-value" )->escaped();
$status = CheckResult::STATUS_VIOLATION;
} else {
diff --git a/src/ConstraintCheck/Helper/ValueCountCheckerHelper.php 
b/src/ConstraintCheck/Helper/ValueCountCheckerHelper.php
index 849e770..f9b675c 100644
--- a/src/ConstraintCheck/Helper/ValueCountCheckerHelper.php
+++ b/src/ConstraintCheck/Helper/ValueCountCheckerHelper.php
@@ -2,43 +2,31 @@
 
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Helper;
 
-use Wikibase\DataModel\Statement\Statement;
-use Wikibase\DataModel\Statement\StatementList;
+use Wikibase\DataModel\Entity\PropertyId;
+use Wikibase\DataModel\Snak\Snak;
 
 /**
  * Class for helper functions for value count checkers.
  *
- * @author BP2014N1
+ * @author Lucas Werkmeister
  * @license GNU GPL v2+
  */
 class ValueCountCheckerHelper {
 
/**
-* @var int[]
-*/
-   private $propertyCount;
-
-   /**
-* @param StatementList $statements
+* Count the number of snaks with the given property ID.
 *
-* @return int[]
+* @param Snak[] $snaks
+* @param PropertyId $propertyId
+* @return int
 */
-   public function getPropertyCount( StatementList $statements ) {
-   if ( !isset( $this->propertyCount ) ) {
-   $this->propertyCount = [];
-
-   /** @var Statement $statement */
-   foreach ( $statements as $statement ) {
-   $counter = $statement->getRank() === 
Statement::RANK_DEPRECATED ? 0 : 1;
-   if ( array_key_exists( 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Rewrite ValueCountChecker tests

2018-01-18 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405032 )

Change subject: Rewrite ValueCountChecker tests
..

Rewrite ValueCountChecker tests

The tests for SingleValueChecker and MultiValueChecker used to load
entities from JSON files and then additionally construct the Statement
for the context independently of them, which was risky because the
constructed Statement was not entirely equivalent to the deserialized
one (its GUID was never set). Since this pattern breaks with the
upcoming changes to ValueCountCheckerHelper (change TODO, for T175566),
rewrite the tests to use NewItem and NewStatement instead.

And on that opportunity, also do some other cleanups: most importantly,
create the mock Constraint object in the constructor, since we never
passed anything other than [] into the constraint parameters anyways
(and there was also a typo on the mocked method name – the real method
name is getConstraintParameters, plural), and also skip the mocking of
methods (never called anyways).

Note: Q1.json and Q6.json are used by UniqueValueCheckerTest and
therefore can’t be deleted yet.

Bug: T168240
Change-Id: I0fced666d5e49d7c7cada49eab19bff972214c9b
---
M tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
D tests/phpunit/Checker/ValueCountChecker/Q2.json
D tests/phpunit/Checker/ValueCountChecker/Q3.json
D tests/phpunit/Checker/ValueCountChecker/Q4.json
D tests/phpunit/Checker/ValueCountChecker/Q5.json
M tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php
6 files changed, 64 insertions(+), 326 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/32/405032/1

diff --git a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php 
b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
index ea18498..ea41c31 100644
--- a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
+++ b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php
@@ -20,7 +20,7 @@
  *
  * @group WikibaseQualityConstraints
  *
- * @author BP2014N1
+ * @author Lucas Werkmeister
  * @license GNU GPL v2+
  */
 class MultiValueCheckerTest extends \MediaWikiTestCase {
@@ -28,97 +28,75 @@
use ResultAssertions;
 
/**
-* @var PropertyId
+* @var Constraint
 */
-   private $multiPropertyId;
+   private $constraint;
 
/**
 * @var MultiValueChecker
 */
private $checker;
 
-   /**
-* @var JsonFileEntityLookup
-*/
-   private $lookup;
-
protected function setUp() {
parent::setUp();
 
-   $this->multiPropertyId = new PropertyId( 'P161' );
+   $this->constraint = $this->getMockBuilder( Constraint::class )
+   ->disableOriginalConstructor()
+   ->getMock();
$this->checker = new MultiValueChecker();
-   $this->lookup = new JsonFileEntityLookup( __DIR__ );
}
 
-   public function testMultiValueConstraintOne() {
-   $entity = $this->lookup->getEntity( new ItemId( 'Q4' ) );
-   $statement = new Statement( new PropertyValueSnak( 
$this->multiPropertyId, new EntityIdValue( new ItemId( 'Q207' ) ) ) );
-   $constraint = $this->getConstraintMock( [] );
+   public function testMultiValueConstraint_One() {
+   $statement = NewStatement::noValueFor( 'P1' 
)->withSomeGuid()->build();
+   $item = NewItem::withStatement( $statement )->build();
+   $context = new MainSnakContext( $item, $statement );
 
-   $checkResult = $this->checker->checkConstraint( new 
MainSnakContext( $entity, $statement ), $constraint );
+   $checkResult = $this->checker->checkConstraint( $context, 
$this->constraint );
 
$this->assertViolation( $checkResult, 
'wbqc-violation-message-multi-value' );
}
 
-   public function testMultiValueConstraintTwo() {
-   $entity = $this->lookup->getEntity( new ItemId( 'Q5' ) );
-   $statement = new Statement( new PropertyValueSnak( 
$this->multiPropertyId, new EntityIdValue( new ItemId( 'Q207' ) ) ) );
-   $constraint = $this->getConstraintMock( [] );
+   public function testMultiValueConstraint_Two() {
+   $statement1 = NewStatement::noValueFor( 'P1' 
)->withSomeGuid()->build();
+   $statement2 = NewStatement::noValueFor( 'P1' 
)->withSomeGuid()->build();
+   $item = NewItem::withStatement( $statement1 )->andStatement( 
$statement2 )->build();
+   $context = new MainSnakContext( $item, $statement1 );
 
-   $checkResult = $this->checker->checkConstraint( new 
MainSnakContext( $entity, $statement ), $constraint );
+   $checkResult = 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add Context::getSiblingSnaks method

2018-01-18 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404994 )

Change subject: Add Context::getSiblingSnaks method
..

Add Context::getSiblingSnaks method

The “sibling snaks” concept could be used by several checkers, but for
now, we will start with the “single value” and “multiple values”
checkers. This is also why we copy the ValueCountCheckerHelper semantics
of ignoring deprecated statements in MainSnakContext (though we might
make this configurable with a method parameter later).

Bug: T185209
Change-Id: I6b926bfe4791b2351c16143b478e06980f03b8f7
---
M src/ConstraintCheck/Context/Context.php
M src/ConstraintCheck/Context/MainSnakContext.php
M src/ConstraintCheck/Context/QualifierContext.php
M src/ConstraintCheck/Context/ReferenceContext.php
M tests/phpunit/Context/MainSnakContextTest.php
M tests/phpunit/Context/QualifierContextTest.php
M tests/phpunit/Context/ReferenceContextTest.php
M tests/phpunit/Fake/FakeSnakContext.php
8 files changed, 108 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/94/404994/1

diff --git a/src/ConstraintCheck/Context/Context.php 
b/src/ConstraintCheck/Context/Context.php
index 07d590b..82c0d37 100644
--- a/src/ConstraintCheck/Context/Context.php
+++ b/src/ConstraintCheck/Context/Context.php
@@ -75,6 +75,17 @@
public function getSnakStatement();
 
/**
+* The other snaks in the list of snaks that the snak being checked 
resides in.
+* For a statement context, this is the main snaks of other 
(non-deprecated) statements;
+* for a qualifier context, the other qualifiers of the same statement;
+* and for a reference context, the other snaks of the same reference.
+*
+* @return Snak[] not a SnakList because for a statement context,
+* the returned value might contain the same snak several times.
+*/
+   public function getSiblingSnaks();
+
+   /**
 * Store the check result serialization $result
 * at the appropriate location for this context in $container.
 *
diff --git a/src/ConstraintCheck/Context/MainSnakContext.php 
b/src/ConstraintCheck/Context/MainSnakContext.php
index 2970753..fb14a4d 100644
--- a/src/ConstraintCheck/Context/MainSnakContext.php
+++ b/src/ConstraintCheck/Context/MainSnakContext.php
@@ -4,6 +4,8 @@
 
 use Wikibase\DataModel\Entity\EntityDocument;
 use Wikibase\DataModel\Statement\Statement;
+use Wikibase\DataModel\Statement\StatementList;
+use Wikibase\DataModel\Statement\StatementListProvider;
 
 /**
  * A constraint check context for the main snak of a statement.
@@ -41,6 +43,15 @@
return $this->statement;
}
 
+   public function getSiblingSnaks() {
+   /** @var StatementList $statements */
+   $statements = clone $this->entity->getStatements();
+   $statements->removeStatementsWithGuid( 
$this->statement->getGuid() );
+   return $statements
+   ->getByRank( [ Statement::RANK_NORMAL, 
Statement::RANK_PREFERRED ] )
+   ->getMainSnaks();
+   }
+
protected function ( array &$container ) {
$statementArray = &$this->getStatementArray(
$container,
diff --git a/src/ConstraintCheck/Context/QualifierContext.php 
b/src/ConstraintCheck/Context/QualifierContext.php
index 3f8fc0b..4bb66e6 100644
--- a/src/ConstraintCheck/Context/QualifierContext.php
+++ b/src/ConstraintCheck/Context/QualifierContext.php
@@ -31,6 +31,12 @@
return self::TYPE_QUALIFIER;
}
 
+   public function getSiblingSnaks() {
+   $snaks = clone $this->statement->getQualifiers();
+   $snaks->removeSnak( $this->snak );
+   return array_values( $snaks->getArrayCopy() );
+   }
+
protected function ( array &$container ) {
$statementArray = &$this->getStatementArray(
$container,
diff --git a/src/ConstraintCheck/Context/ReferenceContext.php 
b/src/ConstraintCheck/Context/ReferenceContext.php
index d0ba238..f83cc17 100644
--- a/src/ConstraintCheck/Context/ReferenceContext.php
+++ b/src/ConstraintCheck/Context/ReferenceContext.php
@@ -39,6 +39,12 @@
return self::TYPE_REFERENCE;
}
 
+   public function getSiblingSnaks() {
+   $snaks = clone $this->reference->getSnaks();
+   $snaks->removeSnak( $this->snak );
+   return array_values( $snaks->getArrayCopy() );
+   }
+
protected function ( array &$container ) {
$statementArray = &$this->getStatementArray(
$container,
diff --git a/tests/phpunit/Context/MainSnakContextTest.php 
b/tests/phpunit/Context/MainSnakContextTest.php
index dc77a12..16227ab 100644
--- 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQuality[master]: Use Wikimedia\Assert and type hints

2018-01-18 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404975 )

Change subject: Use Wikimedia\Assert and type hints
..

Use Wikimedia\Assert and type hints

This reduces the verbosity of some error handling code, and since parts
of that error handling code were untested, also increases test coverage.

Change-Id: Idc984d31e27d61bc625663c9db1c1a804fe385ef
---
M includes/Html/HtmlTableBuilder.php
M includes/Html/HtmlTableCellBuilder.php
M includes/Html/HtmlTableHeaderBuilder.php
M tests/phpunit/Html/HtmlTableBuilderTest.php
M tests/phpunit/Html/HtmlTableCellBuilderTest.php
M tests/phpunit/Html/HtmlTableHeaderBuilderTest.php
6 files changed, 24 insertions(+), 42 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQuality 
refs/changes/75/404975/1

diff --git a/includes/Html/HtmlTableBuilder.php 
b/includes/Html/HtmlTableBuilder.php
index 6bb7a0d..8a9a98e 100644
--- a/includes/Html/HtmlTableBuilder.php
+++ b/includes/Html/HtmlTableBuilder.php
@@ -4,6 +4,7 @@
 
 use InvalidArgumentException;
 use Html;
+use Wikimedia\Assert\Assert;
 
 /**
  * @package WikibaseQuality\Html
@@ -31,16 +32,8 @@
 
/**
 * @param array $headers
-*
-* @throws InvalidArgumentException
 */
-   public function __construct( $headers ) {
-   if ( !is_array( $headers ) ) {
-   throw new InvalidArgumentException(
-   '$headers must be an array of strings or 
HtmlTableHeader elements.'
-   );
-   }
-
+   public function __construct( array $headers ) {
foreach ( $headers as $header ) {
$this->addHeader( $header );
}
@@ -52,14 +45,10 @@
 * @throws InvalidArgumentException
 */
private function addHeader( $header ) {
+   Assert::parameterType( 
'string|\WikibaseQuality\Html\HtmlTableHeaderBuilder', $header, '$header' );
+
if ( is_string( $header ) ) {
$header = new HtmlTableHeaderBuilder( $header );
-   }
-
-   if ( !( $header instanceof HtmlTableHeaderBuilder ) ) {
-   throw new InvalidArgumentException(
-   'Each element in $headers must be a string or 
an HtmlTableHeader'
-   );
}
 
$this->headers[] = $header;
diff --git a/includes/Html/HtmlTableCellBuilder.php 
b/includes/Html/HtmlTableCellBuilder.php
index d49a056..691c39d 100644
--- a/includes/Html/HtmlTableCellBuilder.php
+++ b/includes/Html/HtmlTableCellBuilder.php
@@ -2,8 +2,9 @@
 
 namespace WikibaseQuality\Html;
 
-use InvalidArgumentException;
 use Html;
+use Wikimedia\Assert\Assert;
+use Wikimedia\Assert\ParameterTypeException;
 
 /**
  * @package WikibaseQuality\Html
@@ -36,16 +37,11 @@
 * @param array $attributes
 * @param bool $isRawContent
 *
-* @throws InvalidArgumentException
+* @throws ParameterTypeException
 */
public function __construct( $content, array $attributes = [], 
$isRawContent = false ) {
-   // Check parameters
-   if ( !is_string( $content ) ) {
-   throw new InvalidArgumentException( '$content must be 
string.' );
-   }
-   if ( !is_bool( $isRawContent ) ) {
-   throw new InvalidArgumentException( '$isRawContent must 
be boolean.' );
-   }
+   Assert::parameterType( 'string', $content, '$content' );
+   Assert::parameterType( 'boolean', $isRawContent, 
'$isRawContent' );
 
$this->content = $content;
$this->attributes = $attributes;
diff --git a/includes/Html/HtmlTableHeaderBuilder.php 
b/includes/Html/HtmlTableHeaderBuilder.php
index c1e03ed..15c906c 100644
--- a/includes/Html/HtmlTableHeaderBuilder.php
+++ b/includes/Html/HtmlTableHeaderBuilder.php
@@ -2,8 +2,9 @@
 
 namespace WikibaseQuality\Html;
 
-use InvalidArgumentException;
 use Html;
+use Wikimedia\Assert\Assert;
+use Wikimedia\Assert\ParameterTypeException;
 
 /**
  * @package WikibaseQuality\Html
@@ -38,18 +39,12 @@
 * @param bool $isSortable
 * @param bool $isRawContent
 *
-* @throws InvalidArgumentException
+* @throws ParameterTypeException
 */
public function __construct( $content, $isSortable = false, 
$isRawContent = false ) {
-   if ( !is_string( $content ) ) {
-   throw new InvalidArgumentException( '$content must be 
string.' );
-   }
-   if ( !is_bool( $isSortable ) ) {
-   throw new InvalidArgumentException( '$isSortable must 
be boolean.' );
-   }
-   if ( !is_bool( $isRawContent ) ) {
-   

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Fix test class name

2018-01-17 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404714 )

Change subject: Fix test class name
..

Fix test class name

Change-Id: I5d3a31a7c4894f42b16a01e70739b16a0f776892
---
M tests/phpunit/Job/UpdateConstraintsTableJobTest.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/14/404714/1

diff --git a/tests/phpunit/Job/UpdateConstraintsTableJobTest.php 
b/tests/phpunit/Job/UpdateConstraintsTableJobTest.php
index a13b551..054d3c3 100644
--- a/tests/phpunit/Job/UpdateConstraintsTableJobTest.php
+++ b/tests/phpunit/Job/UpdateConstraintsTableJobTest.php
@@ -34,7 +34,7 @@
  * @author Lucas Werkmeister
  * @license GNU GPL v2+
  */
-class UpdateConstraintsTableTest extends MediaWikiTestCase {
+class UpdateConstraintsTableJobTest extends MediaWikiTestCase {
 
use DefaultConfig;
 

-- 
To view, visit https://gerrit.wikimedia.org/r/404714
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d3a31a7c4894f42b16a01e70739b16a0f776892
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Use InMemoryEntityLookup instead of JsonFileEntityLookup

2018-01-17 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404715 )

Change subject: Use InMemoryEntityLookup instead of JsonFileEntityLookup
..

Use InMemoryEntityLookup instead of JsonFileEntityLookup

Bug: T168240
Change-Id: I649302db640f3ba55d013d5391b6048e1647e3d1
---
D tests/phpunit/Job/P2.json
M tests/phpunit/Job/UpdateConstraintsTableJobTest.php
2 files changed, 18 insertions(+), 36 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/15/404715/1

diff --git a/tests/phpunit/Job/P2.json b/tests/phpunit/Job/P2.json
deleted file mode 100644
index 22ee7e0..000
--- a/tests/phpunit/Job/P2.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
-  "id": "P2",
-  "type": "property",
-  "datatype": "wikibase-item",
-  "aliases": {},
-  "labels": {
-"en": {
-  "language": "en",
-  "value": "my property"
-}
-  },
-  "claims": {
-"P2302": [
-  {
-"id": "P2$484b7eaf-e86c-4f25-91dc-7ae19f8be8de",
-"mainsnak": {
-  "snaktype": "value",
-  "property": "P2302",
-  "datatype": "wikibase-item",
-  "datavalue": {
-"value": {
-  "entity-type": "item",
-  "numeric-id": 19474404,
-  "id": "Q19474404"
-},
-"type": "wikibase-entityid"
-  }
-},
-"type": "statement",
-"rank": "normal"
-  }
-]
-  }
-}
diff --git a/tests/phpunit/Job/UpdateConstraintsTableJobTest.php 
b/tests/phpunit/Job/UpdateConstraintsTableJobTest.php
index 054d3c3..2ad3a3d 100644
--- a/tests/phpunit/Job/UpdateConstraintsTableJobTest.php
+++ b/tests/phpunit/Job/UpdateConstraintsTableJobTest.php
@@ -21,7 +21,6 @@
 use WikibaseQuality\ConstraintReport\ConstraintRepository;
 use WikibaseQuality\ConstraintReport\Tests\DefaultConfig;
 use WikibaseQuality\ConstraintReport\UpdateConstraintsTableJob;
-use WikibaseQuality\Tests\Helper\JsonFileEntityLookup;
 use Wikibase\Repo\WikibaseRepo;
 
 /**
@@ -312,13 +311,30 @@
}
 
public function testRun() {
+   $config = $this->getDefaultConfig();
+   $propertyConstraintId = $config->get( 
'WBQualityConstraintsPropertyConstraintId' );
+   $singleValueConstraintId = $config->get( 
'WBQualityConstraintsSingleValueConstraintId' );
+   $property = new Property(
+   new PropertyId( 'P2' ),
+   null,
+   'wikibase-item',
+   new StatementList(
+   NewStatement::forProperty( 
$propertyConstraintId )
+   ->withValue( new ItemId( 
$singleValueConstraintId ) )
+   ->withGuid( 
'P2$484b7eaf-e86c-4f25-91dc-7ae19f8be8de' )
+   ->build()
+   )
+   );
+   $entityLookup = new InMemoryEntityLookup();
+   $entityLookup->addEntity( $property );
+
$job = new UpdateConstraintsTableJob(
Title::newFromText( 'constraintsTableUpdate' ),
[],
'P2',
$this->getDefaultConfig(),
new ConstraintRepository(),
-   new JsonFileEntityLookup( __DIR__ ),
+   $entityLookup,

WikibaseRepo::getDefaultInstance()->getBaseDataModelSerializerFactory()->newSnakSerializer()
);
 

-- 
To view, visit https://gerrit.wikimedia.org/r/404715
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I649302db640f3ba55d013d5391b6048e1647e3d1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add support for parsing “instance or subclass of” relation

2018-01-17 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404710 )

Change subject: Add support for parsing “instance or subclass of” relation
..

Add support for parsing “instance or subclass of” relation

“instance or subclass of” is a new value for the “relation” parameter,
in addition to the existing “instance of” and “subclass of” values.  A
new config variable is added for the item ID of the “instance or
subclass of” relation item, ConstraintParameterParser learns to parse it
(returning the string “relationOrSubclass” – without spaces, since it
will be used in an i18n message key), and the ConstraintParameters test
trait learns to produce the parameter from that string.

Bug: T169858
Change-Id: I0d2a663e5f2200e71640942dab1d21d92eb9d5f7
---
M extension.json
M src/ConstraintCheck/Helper/ConstraintParameterParser.php
M tests/phpunit/ConstraintParameters.php
3 files changed, 18 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/10/404710/1

diff --git a/extension.json b/extension.json
index 212c6e3..bc3d7c8 100644
--- a/extension.json
+++ b/extension.json
@@ -334,6 +334,11 @@
"description": "The item ID of the 'subclass of' item, 
which, when used in a 'relation' qualifier of a 'property constraint' statement 
on a property, indicates that the 'type' or 'value type' constraint defined in 
this statement demands a 'subclass' relation.",
"public": true
},
+   "WBQualityConstraintsInstanceOrSubclassOfRelationId": {
+   "value": "Q30208840",
+   "description": "The item ID of the 'instance or 
subclass of' item, which, when used in a 'relation' qualifier of a 'property 
constraint' statement on a property, indicates that the 'type' or 'value type' 
constraint defined in this statement demands a 'instance or subclass' 
relation.",
+   "public": true
+   },
"WBQualityConstraintsPropertyId": {
"value": "P2306",
"description": "The property ID of the 'property' 
property (data type: property), which specifies the property parameter of an 
'inverse', 'item requires claim', 'value requires claim', 'difference within 
range', 'mandatory qualifiers', or 'qualifiers' constraint.",
diff --git a/src/ConstraintCheck/Helper/ConstraintParameterParser.php 
b/src/ConstraintCheck/Helper/ConstraintParameterParser.php
index d9750e3..e760668 100644
--- a/src/ConstraintCheck/Helper/ConstraintParameterParser.php
+++ b/src/ConstraintCheck/Helper/ConstraintParameterParser.php
@@ -176,7 +176,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 string 'instance' or 'subclass'
+* @return string 'instance', 'subclass', or 'instanceOrSubclass'
 */
public function parseRelationParameter( array $constraintParameters, 
$constraintTypeItemId ) {
$this->checkError( $constraintParameters );
@@ -194,17 +194,23 @@
$relationEntityId = $this->parseEntityIdParameter( 
$constraintParameters[$relationId][0], $relationId );
$instanceId = $this->config->get( 
'WBQualityConstraintsInstanceOfRelationId' );
$subclassId = $this->config->get( 
'WBQualityConstraintsSubclassOfRelationId' );
+   $instanceOrSubclassId = $this->config->get( 
'WBQualityConstraintsInstanceOrSubclassOfRelationId' );
switch ( $relationEntityId ) {
case $instanceId:
return 'instance';
case $subclassId:
return 'subclass';
+   case $instanceOrSubclassId:
+   return 'instanceOrSubclass';
default:
throw new ConstraintParameterException(
wfMessage( 
'wbqc-violation-message-parameter-oneof' )
->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $relationId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
-   ->numParams( 2 )
-   ->rawParams( 
$this->constraintParameterRenderer->formatItemIdList( [ $instanceId, 
$subclassId ], Role::CONSTRAINT_PARAMETER_VALUE ) )
+   ->numParams( 3 )
+   ->rawParams( 
$this->constraintParameterRenderer->formatItemIdList(
+

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Remove unused message

2018-01-17 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404708 )

Change subject: Remove unused message
..

Remove unused message

The wbqc-violation-message-type-relation-instance-or-subclass message
has been unused since commit 8bd6518a9c (change I7e98ff5d74) removed
support for constraint parameters imported from constraint templates,
and with T169858 it is about to become inaccurate as well. (If
constraint parameters from a constraint statement specify an invalid
value for the “relation” parameter, the more generic
wbqc-violation-message-parameter-oneof message is used instead.)

Bug: T169858
Change-Id: I92c1d469ab5aa2c909078e4790cb6b5b18bdbf4e
---
M i18n/en.json
M i18n/qqq.json
2 files changed, 0 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/08/404708/1

diff --git a/i18n/en.json b/i18n/en.json
index f10ed45..2327d3e 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -134,7 +134,6 @@
"wbqc-violation-message-range-time-rightopen": "The value for $1 ($2) 
should not be before $3.",
"wbqc-violation-message-single-value": "This property should only 
contain a single value. That is, there should only be one statement using this 
property.",
"wbqc-violation-message-symmetric": "$1 should also have the symmetric 
statement $2 $3.",
-   "wbqc-violation-message-type-relation-instance-or-subclass": "Parameter 
\"relation\" must be either \"instance\" or \"subclass\".",
"wbqc-violation-message-type-instance": "Entities using the $1 property 
should be instances of {{PLURAL:$3|1=$5|2=$5 or $6|one of the following 
classes}} (or of {{PLURAL:$3|1=a subclass of it|2=a subclass of them|one of 
their subclasses}}), but $2 currently {{PLURAL:$3|1=isn't.|2=isn't.|isn't: 
$4}}",
"wbqc-violation-message-type-subclass": "Entities using the $1 property 
should be subclasses of {{PLURAL:$3|1=$5|2=$5 or $6|one of the following 
classes}} (or of {{PLURAL:$3|1=a subclass of it|2=a subclass of them|one of 
their subclasses}}), but $2 currently {{PLURAL:$3|1=isn't.|2=isn't.|isn't: 
$4}}",
"wbqc-violation-message-valueType-instance": "Values of $1 statements 
should be instances of {{PLURAL:$3|1=$5|2=$5 or $6|one of the following 
classes}} (or of {{PLURAL:$3|1=a subclass of it|2=a subclass of them|one of 
their subclasses}}), but $2 currently {{PLURAL:$3|1=isn't.|2=isn't.|isn't: 
$4}}",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 03b0081..8c4484d 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -132,7 +132,6 @@
"wbqc-violation-message-range-time-rightopen": "Message for a violation 
of the “Range” constraint, when the value of a statement is earlier than 
allowed (for a time range with a lower but no upper limit). Parameters:\n* $1 
is the property of the statement.\n* $2 is the value of the statement.\n* $3 is 
the lower bound of the range 
(inclusive).\n{{Related|wbqc-violation-message-range-time-closed}}\n{{Related|wbqc-violation-message-range-quantity-rightopen}}",
"wbqc-violation-message-single-value": "Message for violation of Single 
value constraint. When more than one value exists.",
"wbqc-violation-message-symmetric": "Message for a violation of the 
“Symmetric” constraint, when the symmetric statement of a statement does not 
exist. $1, $2 and $3 contain the expected subject entity, property, and target 
entity of the missing symmetric statement.",
-   "wbqc-violation-message-type-relation-instance-or-subclass": "Message 
for violation of Type/Value type constraint. When relation is neither instance 
nor subclass.",
"wbqc-violation-message-type-instance": "Message for a violation of the 
“Type” constraint, when the subject of a statement should have be an instance 
of a certain type but isn't. $1 is the property of the statement, $2 is the 
subject of the statement, $3 is the number of classes, $4 is an HTML list of 
all classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-type-subclass}}",
"wbqc-violation-message-type-subclass": "Message for a violation of the 
“Type” constraint, when the subject of a statement should have be a subclass of 
a certain type but isn't. $1 is the property of the statement, $2 is the 
subject of the statement, $3 is the number of classes, $4 is an HTML list of 
all classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-type-instance}}",
"wbqc-violation-message-valueType-instance": "Message for a violation 
of the “Value type” constraint, when the value of a statement should have be an 
instance of a certain type but isn't. $1 is the property of the statement, $2 
is the value of the statement, $3 is the number of classes, $4 is an HTML list 
of all classes, and $5, $6 etc. are the individual 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Fix message documentation

2018-01-17 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404709 )

Change subject: Fix message documentation
..

Fix message documentation

“should have be” is not correct English.

Change-Id: Id3f987623ca0cf6c7af3b4c05564d4800a362d30
---
M i18n/qqq.json
1 file changed, 4 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/09/404709/1

diff --git a/i18n/qqq.json b/i18n/qqq.json
index 8c4484d..0fa388a 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -132,10 +132,10 @@
"wbqc-violation-message-range-time-rightopen": "Message for a violation 
of the “Range” constraint, when the value of a statement is earlier than 
allowed (for a time range with a lower but no upper limit). Parameters:\n* $1 
is the property of the statement.\n* $2 is the value of the statement.\n* $3 is 
the lower bound of the range 
(inclusive).\n{{Related|wbqc-violation-message-range-time-closed}}\n{{Related|wbqc-violation-message-range-quantity-rightopen}}",
"wbqc-violation-message-single-value": "Message for violation of Single 
value constraint. When more than one value exists.",
"wbqc-violation-message-symmetric": "Message for a violation of the 
“Symmetric” constraint, when the symmetric statement of a statement does not 
exist. $1, $2 and $3 contain the expected subject entity, property, and target 
entity of the missing symmetric statement.",
-   "wbqc-violation-message-type-instance": "Message for a violation of the 
“Type” constraint, when the subject of a statement should have be an instance 
of a certain type but isn't. $1 is the property of the statement, $2 is the 
subject of the statement, $3 is the number of classes, $4 is an HTML list of 
all classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-type-subclass}}",
-   "wbqc-violation-message-type-subclass": "Message for a violation of the 
“Type” constraint, when the subject of a statement should have be a subclass of 
a certain type but isn't. $1 is the property of the statement, $2 is the 
subject of the statement, $3 is the number of classes, $4 is an HTML list of 
all classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-type-instance}}",
-   "wbqc-violation-message-valueType-instance": "Message for a violation 
of the “Value type” constraint, when the value of a statement should have be an 
instance of a certain type but isn't. $1 is the property of the statement, $2 
is the value of the statement, $3 is the number of classes, $4 is an HTML list 
of all classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-valueType-subclass}}",
-   "wbqc-violation-message-valueType-subclass": "Message for a violation 
of the “Value type” constraint, when the value of a statement should have be a 
subclass of a certain type but isn't. $1 is the property of the statement, $2 
is the value of the statement, $3 is the number of classes, $4 is an HTML list 
of all classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-valueType-instance}}",
+   "wbqc-violation-message-type-instance": "Message for a violation of the 
“Type” constraint, when the subject of a statement should be an instance of a 
certain type but isn't. $1 is the property of the statement, $2 is the subject 
of the statement, $3 is the number of classes, $4 is an HTML list of all 
classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-type-subclass}}",
+   "wbqc-violation-message-type-subclass": "Message for a violation of the 
“Type” constraint, when the subject of a statement should be a subclass of a 
certain type but isn't. $1 is the property of the statement, $2 is the subject 
of the statement, $3 is the number of classes, $4 is an HTML list of all 
classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-type-instance}}",
+   "wbqc-violation-message-valueType-instance": "Message for a violation 
of the “Value type” constraint, when the value of a statement should be an 
instance of a certain type but isn't. $1 is the property of the statement, $2 
is the value of the statement, $3 is the number of classes, $4 is an HTML list 
of all classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-valueType-subclass}}",
+   "wbqc-violation-message-valueType-subclass": "Message for a violation 
of the “Value type” constraint, when the value of a statement should be a 
subclass of a certain type but isn't. $1 is the property of the statement, $2 
is the value of the statement, $3 is the number of classes, $4 is an HTML list 
of all classes, and $5, $6 etc. are the individual 
classes.\n{{Related|wbqc-violation-message-valueType-instance}}",

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add support for “instance or subclass of” relation

2018-01-17 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404711 )

Change subject: Add support for “instance or subclass of” relation
..

Add support for “instance or subclass of” relation

The “instance or subclass of” relation is the union of the “instance of”
and “subclass of” relations: the link from the item to the class can
either be via the “instance of” property or via the “subclass of”
property. After that, as usual, only “subclass of” is processed: the
relation does *not* mean that “instance of” and “subclass of” can be
mixed in the whole hierarchy – only on the first link!

TypeCheckerHelper::hasClassInRelation is changed to accept a list of
relation property IDs instead of a single one, and gains a new helper
function to extract statements of several property IDs from a
StatementList (since StatementList doesn’t have such a function, as far
as I can tell). The two checkers translate the new relation type to a
relation property ID list of both the “instance of” and the “subclass
of” property ID.

Bug: T169858
Change-Id: Iedfe3013a10de0af7f12ea0f6fde7164dbe4f062
---
M i18n/en.json
M i18n/qqq.json
M src/ConstraintCheck/Checker/TypeChecker.php
M src/ConstraintCheck/Checker/ValueTypeChecker.php
M src/ConstraintCheck/Helper/TypeCheckerHelper.php
M tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
M tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php
M tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
8 files changed, 160 insertions(+), 19 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/11/404711/1

diff --git a/i18n/en.json b/i18n/en.json
index 2327d3e..090bdac 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -136,8 +136,10 @@
"wbqc-violation-message-symmetric": "$1 should also have the symmetric 
statement $2 $3.",
"wbqc-violation-message-type-instance": "Entities using the $1 property 
should be instances of {{PLURAL:$3|1=$5|2=$5 or $6|one of the following 
classes}} (or of {{PLURAL:$3|1=a subclass of it|2=a subclass of them|one of 
their subclasses}}), but $2 currently {{PLURAL:$3|1=isn't.|2=isn't.|isn't: 
$4}}",
"wbqc-violation-message-type-subclass": "Entities using the $1 property 
should be subclasses of {{PLURAL:$3|1=$5|2=$5 or $6|one of the following 
classes}} (or of {{PLURAL:$3|1=a subclass of it|2=a subclass of them|one of 
their subclasses}}), but $2 currently {{PLURAL:$3|1=isn't.|2=isn't.|isn't: 
$4}}",
+   "wbqc-violation-message-type-instanceOrSubclass": "Entities using the 
$1 property should be instances or subclasses of {{PLURAL:$3|1=$5|2=$5 or 
$6|one of the following classes}} (or of {{PLURAL:$3|1=a subclass of it|2=a 
subclass of them|one of their subclasses}}), but $2 currently 
{{PLURAL:$3|1=isn't.|2=isn't.|isn't: $4}}",
"wbqc-violation-message-valueType-instance": "Values of $1 statements 
should be instances of {{PLURAL:$3|1=$5|2=$5 or $6|one of the following 
classes}} (or of {{PLURAL:$3|1=a subclass of it|2=a subclass of them|one of 
their subclasses}}), but $2 currently {{PLURAL:$3|1=isn't.|2=isn't.|isn't: 
$4}}",
"wbqc-violation-message-valueType-subclass": "Values of $1 statements 
should be subclasses of {{PLURAL:$3|1=$5|2=$5 or $6|one of the following 
classes}} (or of {{PLURAL:$3|1=a subclass of it|2=a subclass of them|one of 
their subclasses}}), but $2 currently {{PLURAL:$3|1=isn't.|2=isn't.|isn't: 
$4}}",
+   "wbqc-violation-message-valueType-instanceOrSubclass": "Values of $1 
statements should be instances or subclasses of {{PLURAL:$3|1=$5|2=$5 or $6|one 
of the following classes}} (or of {{PLURAL:$3|1=a subclass of it|2=a subclass 
of them|one of their subclasses}}), but $2 currently 
{{PLURAL:$3|1=isn't.|2=isn't.|isn't: $4}}",
"wbqc-violation-message-target-required-claim": "$1 should have 
{{PLURAL:$3|0=a statement $2.|1=a statement $2 $5.|a statement for $2 with one 
of the following values:$4}}",
"wbqc-violation-message-unique-value": "This property's value must not 
be present on any other item, but is also present on {{PLURAL:$1|1=$3.|2=$3 and 
$4.|the following items: $2}}",
"wbqc-violation-message-valueOnly": "This property should only be used 
for the main value of a statement, not for qualifiers or references.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 0fa388a..283dc8d 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -134,8 +134,10 @@
"wbqc-violation-message-symmetric": "Message for a violation of the 
“Symmetric” constraint, when the symmetric statement of a statement does not 
exist. $1, $2 and $3 contain the expected subject entity, property, and target 
entity of the missing symmetric statement.",
"wbqc-violation-message-type-instance": "Message for a violation of the 
“Type” constraint, when the subject of a statement should be an instance of a 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Improve TypeCheckerHelperTest function names

2018-01-17 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404707 )

Change subject: Improve TypeCheckerHelperTest function names
..

Improve TypeCheckerHelperTest function names

Similar to commit 2c47030aa9 (change I2a74c79265), an underscore is
added in the test function name between the name of the function under
test and the details. The name of the function under test is also
sometimes adjusted (“IsSubclass” → “IsSubclassOf”), and the redundant
“Check” prefix is removed everywhere.

Change-Id: I5ddb849bbcc6529d2388d815f654ecd0c8b6bbf5
---
M tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
1 file changed, 10 insertions(+), 10 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/07/404707/1

diff --git a/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php 
b/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
index c3072d7..79df966 100644
--- a/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
+++ b/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
@@ -93,56 +93,56 @@
return $mock;
}
 
-   public function testCheckHasClassInRelationValid() {
+   public function testHasClassInRelation_Valid() {
$statement1 = new Statement( new PropertyValueSnak( new 
PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) );
$statement2 = new Statement( new PropertyValueSnak( new 
PropertyId( 'P31' ), new EntityIdValue( new ItemId( 'Q1' ) ) ) );
$statements = new StatementList( [ $statement1, $statement2 ] );
$this->assertTrue( $this->getHelper()->hasClassInRelation( 
$statements, 'P31', [ 'Q1' ] )->getBool() );
}
 
-   public function testCheckHasClassInRelationInvalid() {
+   public function testHasClassInRelation_Invalid() {
$statement1 = new Statement( new PropertyValueSnak( new 
PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) );
$statement2 = new Statement( new PropertyValueSnak( new 
PropertyId( 'P31' ), new EntityIdValue( new ItemId( 'Q100' ) ) ) );
$statements = new StatementList( [ $statement1, $statement2 ] );
$this->assertFalse( $this->getHelper()->hasClassInRelation( 
$statements, 'P31', [ 'Q1' ] )->getBool() );
}
 
-   public function testCheckHasClassInRelationValidWithIndirection() {
+   public function testHasClassInRelation_ValidWithIndirection() {
$statement1 = new Statement( new PropertyValueSnak( new 
PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) );
$statement2 = new Statement( new PropertyValueSnak( new 
PropertyId( 'P31' ), new EntityIdValue( new ItemId( 'Q5' ) ) ) );
$statements = new StatementList( [ $statement1, $statement2 ] );
$this->assertTrue( $this->getHelper()->hasClassInRelation( 
$statements, 'P31', [ 'Q4' ] )->getBool() );
}
 
-   public function testCheckIsSubclassOfValidWithIndirection() {
+   public function testIsSubclassOf_ValidWithIndirection() {
$this->assertTrue( 
$this->getHelper()->isSubclassOfWithSparqlFallback( new ItemId( 'Q6' ), [ 
'Q100', 'Q101' ] )->getBool() );
}
 
-   public function testCheckIsSubclassOfInvalid() {
+   public function testIsSubclassOf_Invalid() {
$this->assertFalse( 
$this->getHelper()->isSubclassOfWithSparqlFallback( new ItemId( 'Q6' ), [ 
'Q200', 'Q201' ] )->getBool() );
}
 
-   public function testCheckIsSubclassCyclic() {
+   public function testIsSubclassOf_Cyclic() {
$helper = $this->getHelper( $this->getMaxEntitiesLookup() );
$this->assertFalse( $helper->isSubclassOfWithSparqlFallback( 
new ItemId( 'Q7' ), [ 'Q100', 'Q101' ] )->getBool() );
}
 
-   public function testCheckIsSubclassCyclicWide() {
+   public function testIsSubclassOf_CyclicWide() {
$helper = $this->getHelper( $this->getMaxEntitiesLookup() );
$this->assertFalse( $helper->isSubclassOfWithSparqlFallback( 
new ItemId( 'Q9' ), [ 'Q100', 'Q101' ] )->getBool() );
}
 
-   public function testCheckIsSubclassCyclicWideWithSparqlTrue() {
+   public function testIsSubclassOf_CyclicWideWithSparqlTrue() {
$helper = $this->getHelper( $this->getMaxEntitiesLookup(), 
$this->getSparqlHelper( true ) );
$this->assertTrue( $helper->isSubclassOfWithSparqlFallback( new 
ItemId( 'Q9' ), [ 'Q100', 'Q101' ] )->getBool() );
}
 
-   public function testCheckIsSubclassCyclicWideWithSparqlFalse() {
+   public function testIsSubclassOf_CyclicWideWithSparqlFalse() {
$helper = $this->getHelper( $this->getMaxEntitiesLookup(), 
$this->getSparqlHelper( false ) );
   

[MediaWiki-commits] [Gerrit] wikidata...gui[master]: Disable no-descending-specificity stylelint rule

2018-01-16 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404508 )

Change subject: Disable no-descending-specificity stylelint rule
..

Disable no-descending-specificity stylelint rule

The rule is sometimes hard to satisfy, especially given our mixture of
styling by ID and styling by class (which have different specificity).
Perhaps we can reintroduce it at some point, but for now, I8447b28c0d
introduces a case of descending specificity that I can’t think of a good
way to resolve, so I’m disabling the rule.

Change-Id: I96313c6bc311b2defc762ab6b8f4665dacd47817
---
M .stylelintrc
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/08/404508/1

diff --git a/.stylelintrc b/.stylelintrc
index f475e7f..677a7a6 100644
--- a/.stylelintrc
+++ b/.stylelintrc
@@ -4,6 +4,7 @@
"color-named": null,
"declaration-no-important": null,
"declaration-property-value-blacklist": null,
+   "no-descending-specificity": null,
"selector-no-id": null
}
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/404508
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I96313c6bc311b2defc762ab6b8f4665dacd47817
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Remove useless select from SPARQL query

2018-01-16 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404476 )

Change subject: Remove useless select from SPARQL query
..

Remove useless select from SPARQL query

We don’t use ?entity, so there’s no need to include it in the SELECT.

Change-Id: Ie2063797d7d26eb570ba4d544d4ad555a72ae33f
---
M src/ConstraintCheck/Helper/SparqlHelper.php
M tests/phpunit/Helper/SparqlHelperTest.php
2 files changed, 2 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/76/404476/1

diff --git a/src/ConstraintCheck/Helper/SparqlHelper.php 
b/src/ConstraintCheck/Helper/SparqlHelper.php
index 3855258..42d98c9 100644
--- a/src/ConstraintCheck/Helper/SparqlHelper.php
+++ b/src/ConstraintCheck/Helper/SparqlHelper.php
@@ -237,7 +237,7 @@
}
 
$query = <

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add missing DISTINCT to SPARQL query

2018-01-16 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404477 )

Change subject: Add missing DISTINCT to SPARQL query
..

Add missing DISTINCT to SPARQL query

Bug: T184705
Change-Id: Ie76949e4b85e9529b5b721691e5e6e5b8c46d319
---
M src/ConstraintCheck/Helper/SparqlHelper.php
M tests/phpunit/Helper/SparqlHelperTest.php
2 files changed, 4 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/77/404477/1

diff --git a/src/ConstraintCheck/Helper/SparqlHelper.php 
b/src/ConstraintCheck/Helper/SparqlHelper.php
index 42d98c9..54bf3f7 100644
--- a/src/ConstraintCheck/Helper/SparqlHelper.php
+++ b/src/ConstraintCheck/Helper/SparqlHelper.php
@@ -179,7 +179,7 @@
}
 
$query = <

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Fix status parameter documentation

2018-01-15 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404326 )

Change subject: Fix status parameter documentation
..

Fix status parameter documentation

Originally, I had planned to support caching for requests with e. g.
only the violation|warning statuses as well. However, while implementing
this, I realized that removing results from the response array structure
is not trivial, and so I changed my mind and we now only cache results
for requests which specify exactly the right three statuses.
Unfortunately, I failed to update the commit message to account for
this change.

Bug: T183927
Change-Id: Id81382c35aa5cac5a995432673727bc53bff9eec
---
M i18n/en.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/26/404326/1

diff --git a/i18n/en.json b/i18n/en.json
index 7bb971a..f10ed45 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -54,7 +54,7 @@
"apihelp-wbcheckconstraints-param-id": "ID list of the entities to get 
the data from. Separate values with '|' or alternative.",
"apihelp-wbcheckconstraints-param-claimid": "GUID list identifying a 
claim to check a constraint report.  Separate values with '|'.",
"apihelp-wbcheckconstraints-param-constraintid": "Optional filter to 
return only the constraints that have the specified constraint ID.",
-   "apihelp-wbcheckconstraints-param-status": "Optional filter to return 
only check results with the selected statuses.\n\nNote that only results for 
the 'violation', 'warning' and 'bad-parameters' statuses are cached, so any 
request that is not limited to only those statuses (or a subset of them) does 
not benefit from caching.",
+   "apihelp-wbcheckconstraints-param-status": "Optional filter to return 
only check results with the selected statuses.\n\nNote that only results for 
the 'violation', 'warning' and 'bad-parameters' statuses are cached, so only 
requests that are limited to exactly those statuses benefit from caching.",
"apihelp-wbcheckconstraints-paramvalue-status-compliance": "The 
statement satisfies the constraint.",
"apihelp-wbcheckconstraints-paramvalue-status-violation": "The 
statement violates the constraint.",
"apihelp-wbcheckconstraints-paramvalue-status-exception": "The subject 
entity of the statement is a known exception to the constraint.",

-- 
To view, visit https://gerrit.wikimedia.org/r/404326
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id81382c35aa5cac5a995432673727bc53bff9eec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add status parameter to gadget’s API requests

2018-01-15 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404322 )

Change subject: Add status parameter to gadget’s API requests
..

Add status parameter to gadget’s API requests

Only with this parameter does the gadget benefit from server-side
caching, otherwise it requests lots of results which we don’t cache and
which therefore require a full constraint check.

(Note: for the check of an individual statement, we don’t cache results
either, but specifying the status at least reduces the response size.)

Bug: T183927
Change-Id: I7457566fdf4181719473dfc84e3ff872b49b3d4b
---
M modules/gadget.js
1 file changed, 6 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/22/404322/1

diff --git a/modules/gadget.js b/modules/gadget.js
index b368d6e..da4d542 100644
--- a/modules/gadget.js
+++ b/modules/gadget.js
@@ -1,7 +1,8 @@
 ( function( mw, wb, $, OO ) {
'use strict';
 
-   var entityId;
+   var entityId,
+   cachedStatuses = 'violation|warning|bad-parameters';
 
function buildPopup( $content, $container, icon, iconTitleMessageKey, 
flags /* = '' */ ) {
var widget = new OO.ui.PopupButtonWidget( {
@@ -311,7 +312,8 @@
format: 'json',
formatversion: 2,
uselang: lang,
-   id: entityId
+   id: entityId,
+   status: cachedStatuses
} ).then( function( data ) {
$( '.wikibase-statementgroupview 
.wikibase-statementview' )
.each( function () { addReportsToStatement( 
data.wbcheckconstraints[ entityId ], $( this ) ); } );
@@ -337,7 +339,8 @@
format: 'json',
formatversion: 2,
uselang: lang,
-   claimid: statementId
+   claimid: statementId,
+   status: cachedStatuses
} ).then( function( data ) {
var statementClass = 'wikibase-statement-' + 
statementId.replace( /\$/, '\\$$' );
$( '.wikibase-statementgroupview 
.wikibase-statementview.' + statementClass )

-- 
To view, visit https://gerrit.wikimedia.org/r/404322
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7457566fdf4181719473dfc84e3ff872b49b3d4b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add $statuses parameter to ResultsBuilder::getResults

2018-01-12 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403966 )

Change subject: Add $statuses parameter to ResultsBuilder::getResults
..

Add $statuses parameter to ResultsBuilder::getResults

This parameter filters the check results represented in the final result
to only those listed in the $statuses. CheckingResultsBuilder implements
this filtering, and CachingResultsBuilder caches only those results
where the $statuses are exactly those three statuses which are also
displayed in the gadget.

Bug: T183927
Change-Id: I3ff5f8d6b0a16a4aa2417b0f1e03b8634376a6dd
---
M src/Api/CachingResultsBuilder.php
M src/Api/CheckingResultsBuilder.php
M src/Api/ResultsBuilder.php
M tests/phpunit/Api/CachingResultsBuilderTest.php
M tests/phpunit/Api/CheckingResultsBuilderTest.php
5 files changed, 276 insertions(+), 37 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/66/403966/1

diff --git a/src/Api/CachingResultsBuilder.php 
b/src/Api/CachingResultsBuilder.php
index 00b788a..fc98fc6 100644
--- a/src/Api/CachingResultsBuilder.php
+++ b/src/Api/CachingResultsBuilder.php
@@ -11,6 +11,7 @@
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Cache\CachingMetadata;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Cache\DependencyMetadata;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Cache\Metadata;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 
 /**
  * A wrapper around another ResultsBuilder that caches results in a 
ResultsCache.
@@ -76,6 +77,15 @@
private $microtime = 'microtime';
 
/**
+* TODO: In PHP 5.6, make this a public class constant instead,
+* and also use it in CheckConstraints::getAllowedParams()
+* and in some of the tests.
+*
+* @var string[]
+*/
+   private $cachedStatuses;
+
+   /**
 * @param ResultsBuilder $resultsBuilder The ResultsBuilder that cache 
misses are delegated to.
 * @param ResultsCache $cache The cache where results can be stored.
 * @param WikiPageEntityMetaDataAccessor 
$wikiPageEntityMetaDataAccessor Used to get the latest revision ID.
@@ -101,22 +111,30 @@
$this->ttlInSeconds = $ttlInSeconds;
$this->possiblyStaleConstraintTypes = 
$possiblyStaleConstraintTypes;
$this->dataFactory = $dataFactory;
+
+   $this->cachedStatuses = [
+   CheckResult::STATUS_VIOLATION,
+   CheckResult::STATUS_WARNING,
+   CheckResult::STATUS_BAD_PARAMETERS,
+   ];
}
 
/**
 * @param EntityId[] $entityIds
 * @param string[] $claimIds
 * @param string[]|null $constraintIds
+* @param string[] $statuses
 * @return CachedCheckConstraintsResponse
 */
public function getResults(
array $entityIds,
array $claimIds,
-   array $constraintIds = null
+   array $constraintIds = null,
+   array $statuses
) {
$results = [];
$metadatas = [];
-   if ( $this->canUseStoredResults( $entityIds, $claimIds, 
$constraintIds ) ) {
+   if ( $this->canUseStoredResults( $entityIds, $claimIds, 
$constraintIds, $statuses ) ) {
$storedEntityIds = [];
foreach ( $entityIds as $entityId ) {
$storedResults = $this->getStoredResults( 
$entityId );
@@ -136,7 +154,7 @@

'wikibase.quality.constraints.cache.entity.miss',
count( $entityIds )
);
-   $response = $this->getAndStoreResults( $entityIds, 
$claimIds, $constraintIds );
+   $response = $this->getAndStoreResults( $entityIds, 
$claimIds, $constraintIds, $statuses );
$results += $response->getArray();
$metadatas[] = $response->getMetadata();
}
@@ -147,37 +165,58 @@
}
 
/**
-* We can only use cached constraint results if full constraint check 
results were requested:
+* We can only use cached constraint results
+* if exactly the problematic results of a full constraint check were 
requested:
 * constraint checks for the full entity (not just individual 
statements),
-* and without restricting the set of constraints to check.
+* without restricting the set of constraints to check,
+* and with exactly the 'violation', 'warning' and 'bad-parameters' 
statuses.
+*
+* (In theory, we could also use results for requests
+* that asked for a subset of these result statuses,
+* but removing the 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add status parameter to CheckConstraints

2018-01-12 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403967 )

Change subject: Add status parameter to CheckConstraints
..

Add status parameter to CheckConstraints

This new parameter of the wbcheckconstraints API corresponds to the
$statuses parameter of ResultsBuilder and filters the returned check
results. For now, the default value is '*' (all statuses) to preserve
compatibility, but we plan to change it to just the three statuses for
which results are also cached in the future.

Bug: T183927
Change-Id: I69885a05734956722f939e8a71d1490afc8182ab
---
M i18n/en.json
M i18n/qqq.json
M src/Api/CheckConstraints.php
M src/ConstraintCheck/Result/CheckResult.php
M tests/phpunit/Api/CheckConstraintsTest.php
5 files changed, 89 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/67/403967/1

diff --git a/i18n/en.json b/i18n/en.json
index 2271b21..7bb971a 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -54,6 +54,15 @@
"apihelp-wbcheckconstraints-param-id": "ID list of the entities to get 
the data from. Separate values with '|' or alternative.",
"apihelp-wbcheckconstraints-param-claimid": "GUID list identifying a 
claim to check a constraint report.  Separate values with '|'.",
"apihelp-wbcheckconstraints-param-constraintid": "Optional filter to 
return only the constraints that have the specified constraint ID.",
+   "apihelp-wbcheckconstraints-param-status": "Optional filter to return 
only check results with the selected statuses.\n\nNote that only results for 
the 'violation', 'warning' and 'bad-parameters' statuses are cached, so any 
request that is not limited to only those statuses (or a subset of them) does 
not benefit from caching.",
+   "apihelp-wbcheckconstraints-paramvalue-status-compliance": "The 
statement satisfies the constraint.",
+   "apihelp-wbcheckconstraints-paramvalue-status-violation": "The 
statement violates the constraint.",
+   "apihelp-wbcheckconstraints-paramvalue-status-exception": "The subject 
entity of the statement is a known exception to the constraint.",
+   "apihelp-wbcheckconstraints-paramvalue-status-todo": "The constraint is 
not implemented.",
+   "apihelp-wbcheckconstraints-paramvalue-status-bad-parameters": "The 
constraint parameters are broken.",
+   "apihelp-wbcheckconstraints-paramvalue-status-deprecated": "The 
constraint has not been checked because the statement is deprecated.",
+   "apihelp-wbcheckconstraints-paramvalue-status-warning": "The statement 
violates the constraint, but the constraint is not mandatory.",
+   "apihelp-wbcheckconstraints-paramvalue-status-not-in-scope": "The 
constraint is not checked on this kind of snak (main snak, qualifier or 
reference), so the constraint check is skipped.",
"apihelp-wbcheckconstraintparameters-summary": "Checks the constraint 
parameters of constraint statements.",
"apihelp-wbcheckconstraintparameters-extended-description": "Either or 
both of the property and constraintid parameters may be 
specified; all constraints selected by either parameter will be checked.",
"apihelp-wbcheckconstraintparameters-param-propertyid": "List of 
property IDs to check. All constraint statements of these properties will be 
checked.\n\nIf this parameter is specified, it must be nonempty.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 657ebab..004758d 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -55,6 +55,15 @@
"apihelp-wbcheckconstraints-param-id": 
"{{doc-apihelp-param|wbcheckconstraints|id}}",
"apihelp-wbcheckconstraints-param-claimid": 
"{{doc-apihelp-param|wbcheckconstraints|claimid}}",
"apihelp-wbcheckconstraints-param-constraintid": 
"{{doc-apihelp-param|wbcheckconstraints|constraintid}}",
+   "apihelp-wbcheckconstraints-param-status": 
"{{doc-apihelp-param|wbcheckconstraints|status}}",
+   "apihelp-wbcheckconstraints-paramvalue-status-compliance": 
"{{doc-apihelp-paramvalue|wbcheckconstraints|status|compliance}}",
+   "apihelp-wbcheckconstraints-paramvalue-status-violation": 
"{{doc-apihelp-paramvalue|wbcheckconstraints|status|violation}}",
+   "apihelp-wbcheckconstraints-paramvalue-status-exception": 
"{{doc-apihelp-paramvalue|wbcheckconstraints|status|exception}}",
+   "apihelp-wbcheckconstraints-paramvalue-status-todo": 
"{{doc-apihelp-paramvalue|wbcheckconstraints|status|todo}}",
+   "apihelp-wbcheckconstraints-paramvalue-status-bad-parameters": 
"{{doc-apihelp-paramvalue|wbcheckconstraints|status|bad-parameters}}",
+   "apihelp-wbcheckconstraints-paramvalue-status-deprecated": 
"{{doc-apihelp-paramvalue|wbcheckconstraints|status|deprecated}}",
+   "apihelp-wbcheckconstraints-paramvalue-status-warning": 
"{{doc-apihelp-paramvalue|wbcheckconstraints|status|warning}}",
+   

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add missing period in API parameter documentation

2018-01-12 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403965 )

Change subject: Add missing period in API parameter documentation
..

Add missing period in API parameter documentation

Change-Id: I521d4c2ffae0cd257c0e254e2b3308fd2f5126eb
---
M i18n/en.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/65/403965/1

diff --git a/i18n/en.json b/i18n/en.json
index 8c65861..2271b21 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -53,7 +53,7 @@
"apihelp-wbcheckconstraints-summary": "Performs constraint checks on 
any entity you want and returns the result.",
"apihelp-wbcheckconstraints-param-id": "ID list of the entities to get 
the data from. Separate values with '|' or alternative.",
"apihelp-wbcheckconstraints-param-claimid": "GUID list identifying a 
claim to check a constraint report.  Separate values with '|'.",
-   "apihelp-wbcheckconstraints-param-constraintid": "Optional filter to 
return only the constraints that have the specified constraint ID",
+   "apihelp-wbcheckconstraints-param-constraintid": "Optional filter to 
return only the constraints that have the specified constraint ID.",
"apihelp-wbcheckconstraintparameters-summary": "Checks the constraint 
parameters of constraint statements.",
"apihelp-wbcheckconstraintparameters-extended-description": "Either or 
both of the property and constraintid parameters may be 
specified; all constraints selected by either parameter will be checked.",
"apihelp-wbcheckconstraintparameters-param-propertyid": "List of 
property IDs to check. All constraint statements of these properties will be 
checked.\n\nIf this parameter is specified, it must be nonempty.",

-- 
To view, visit https://gerrit.wikimedia.org/r/403965
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I521d4c2ffae0cd257c0e254e2b3308fd2f5126eb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Reformat CheckConstraints::getAllowedParams

2018-01-12 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403964 )

Change subject: Reformat CheckConstraints::getAllowedParams
..

Reformat CheckConstraints::getAllowedParams

Fix the strange double indentation, and while we’re at it, also add
trailing commas to make future diffs prettier.

Change-Id: Ie131aa140a54d37d901c7b683100fc0d3959258f
---
M src/Api/CheckConstraints.php
1 file changed, 12 insertions(+), 12 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/64/403964/1

diff --git a/src/Api/CheckConstraints.php b/src/Api/CheckConstraints.php
index bcee76f..5f0676f 100644
--- a/src/Api/CheckConstraints.php
+++ b/src/Api/CheckConstraints.php
@@ -290,18 +290,18 @@
 */
public function getAllowedParams() {
return [
-   self::PARAM_ID => [
-   ApiBase::PARAM_TYPE => 'string',
-   ApiBase::PARAM_ISMULTI => true
-   ],
-   self::PARAM_CLAIM_ID => [
-   ApiBase::PARAM_TYPE => 'string',
-   ApiBase::PARAM_ISMULTI => true
-   ],
-   self::PARAM_CONSTRAINT_ID => [
-   ApiBase::PARAM_TYPE => 'string',
-   ApiBase::PARAM_ISMULTI => true
-   ]
+   self::PARAM_ID => [
+   ApiBase::PARAM_TYPE => 'string',
+   ApiBase::PARAM_ISMULTI => true,
+   ],
+   self::PARAM_CLAIM_ID => [
+   ApiBase::PARAM_TYPE => 'string',
+   ApiBase::PARAM_ISMULTI => true,
+   ],
+   self::PARAM_CONSTRAINT_ID => [
+   ApiBase::PARAM_TYPE => 'string',
+   ApiBase::PARAM_ISMULTI => true,
+   ],
];
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/403964
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie131aa140a54d37d901c7b683100fc0d3959258f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: Remove $wgWBQualityConstraintsIncludeDetailInApi setting

2018-01-12 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403939 )

Change subject: Remove $wgWBQualityConstraintsIncludeDetailInApi setting
..

Remove $wgWBQualityConstraintsIncludeDetailInApi setting

With WikibaseQualityConstraints commit 41c26ca1ef (change I1d8460aa27),
the default value of the option was changed to false, so we no longer
need to explicitly set it to that.

This reverts commit e4c63ff9cd (change I32d679cd5c).

Bug: T180614
Change-Id: If8f9a0289edb47d4528f1a086630c2a0cf077fc4
Depends-On: I1d8460aa277b45f3872d5cde82c31277af278592
---
M wmf-config/Wikibase-production.php
1 file changed, 0 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/39/403939/1

diff --git a/wmf-config/Wikibase-production.php 
b/wmf-config/Wikibase-production.php
index 65fe6d0..8e7b216 100644
--- a/wmf-config/Wikibase-production.php
+++ b/wmf-config/Wikibase-production.php
@@ -169,8 +169,6 @@
'the Creative Commons CC0 License; text in the other namespaces 
is available under ' .
'the Creative Commons Attribution-ShareAlike License; 
additional terms may apply.';
$wgRightsUrl = 'creativecommons.org/licenses/by-sa/3.0';
-
-   $wgWBQualityConstraintsIncludeDetailInApi = false; // T180614
 }
 
 if ( $wmgUseWikibaseClient ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/403939
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If8f9a0289edb47d4528f1a086630c2a0cf077fc4
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Gradually enable constraints gadget for all users

2018-01-12 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403920 )

Change subject: Gradually enable constraints gadget for all users
..

Gradually enable constraints gadget for all users

Starting 2018-02-28, we enable the constraints gadget for more and more
users (selected by the first character of their user name), until by
2018-04-04 it’s enabled for all (logged in) users.

Bug: T184069
Change-Id: I6265d4557809926e7f031dd76e6dc60e187d2cff
---
M extension.json
M src/WikibaseQualityConstraintsHooks.php
M tests/phpunit/WikibaseQualityConstraintsHooksTest.php
3 files changed, 103 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/20/403920/1

diff --git a/extension.json b/extension.json
index 7e5c26b..661e407 100644
--- a/extension.json
+++ b/extension.json
@@ -21,7 +21,8 @@
"Hooks": {
"LoadExtensionSchemaUpdates": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onCreateSchema",
"WikibaseChangeNotification": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onWikibaseChange",
-   "ArticlePurge": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onArticlePurge"
+   "ArticlePurge": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onArticlePurge",
+   "BeforePageDisplay": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onBeforePageDisplay"
},
"SpecialPages": {
"ConstraintReport": 
"WikibaseQuality\\ConstraintReport\\Specials\\SpecialConstraintReport::newFromGlobalState"
diff --git a/src/WikibaseQualityConstraintsHooks.php 
b/src/WikibaseQualityConstraintsHooks.php
index e24a3c8..1dd1de7 100644
--- a/src/WikibaseQualityConstraintsHooks.php
+++ b/src/WikibaseQualityConstraintsHooks.php
@@ -7,6 +7,8 @@
 use JobQueueGroup;
 use JobSpecification;
 use MediaWiki\MediaWikiServices;
+use OutputPage;
+use Skin;
 use Title;
 use Wikibase\Change;
 use Wikibase\DataModel\Entity\PropertyId;
@@ -81,4 +83,59 @@
}
}
 
+   /**
+* @param string $userName
+* @param int $timestamp UTC timestamp (seconds since the Epoch)
+* @return bool
+*/
+   public static function isGadgetEnabledForUserName( $userName, 
$timestamp ) {
+   $initial = $userName[0];
+
+   if ( $initial === 'Z' ) {
+   $firstWeek = 0;
+   } elseif ( $initial >= 'W' && $initial < 'Z' ) {
+   $firstWeek = 1;
+   } elseif ( $initial >= 'T' && $initial < 'W' ) {
+   $firstWeek = 2;
+   } elseif ( $initial >= 'N' && $initial < 'T' ) {
+   $firstWeek = 3;
+   } elseif ( $initial >= 'E' && $initial < 'N' ) {
+   $firstWeek = 4;
+   } else {
+   $firstWeek = 5;
+   }
+
+   $threshold = gmmktime(
+   0, // hour
+   0, // minute
+   0, // second
+   3, // month; overflows to 3 or 4 depending on day
+   $firstWeek * 7 + 1, // day
+   2018 // year
+   );
+
+   return $timestamp >= $threshold;
+   }
+
+   public static function onBeforePageDisplay( OutputPage &$out, Skin 
&$skin ) {
+   $repo = WikibaseRepo::getDefaultInstance();
+
+   $lookup = $repo->getEntityNamespaceLookup();
+   $title = $out->getTitle();
+   if ( $title === null ) {
+   return;
+   }
+
+   if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) {
+   return;
+   }
+   if ( !$out->getUser()->isLoggedIn() ) {
+   return;
+   }
+
+   if ( self::isGadgetEnabledForUserName( 
$out->getUser()->getName(), time() ) ) {
+   $out->addModules( 'wikibase.quality.constraints.gadget' 
);
+   }
+   }
+
 }
diff --git a/tests/phpunit/WikibaseQualityConstraintsHooksTest.php 
b/tests/phpunit/WikibaseQualityConstraintsHooksTest.php
index 4df2606..9c3c6d4 100644
--- a/tests/phpunit/WikibaseQualityConstraintsHooksTest.php
+++ b/tests/phpunit/WikibaseQualityConstraintsHooksTest.php
@@ -104,4 +104,48 @@
yield 'property-copy-constraint' => [ $change, true ];
}
 
+   /**
+* @dataProvider isGadgetEnabledForUserNameProvider
+* @param string $userName
+* @param int $timestamp
+* @param bool $expected
+*/
+   public function testIsGadgetEnabledForUserName( $userName, $timestamp, 
$expected ) {
+   

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Don’t hide default [Expand] link

2018-01-11 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403736 )

Change subject: Don’t hide default [Expand] link
..

Don’t hide default [Expand] link

Wikibase’s fancy icon on collapsibles no longer applies to us as of
I6713bdf4c4, so if we hide MediaWiki’s link we see nothing at all.
Perhaps we can restore the prettier Wikibase version at some point, but
for now let’s make sure we at least have *something*.

Change-Id: I73e39c075e5018eb1af09d5336b44c7613128b47
---
M modules/ui/ConstraintReportGroup.less
1 file changed, 0 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/36/403736/1

diff --git a/modules/ui/ConstraintReportGroup.less 
b/modules/ui/ConstraintReportGroup.less
index 9820407..1e3fec0 100644
--- a/modules/ui/ConstraintReportGroup.less
+++ b/modules/ui/ConstraintReportGroup.less
@@ -1,8 +1,3 @@
-.wikibase-toolbar-item .mw-collapsible-toggle * {
-   /* wikibase CSS adds an icon, so hide the normal [expand] link */
-   display: none;
-}
-
 .wbqc-reports-all .wbqc-reports:not( :first-child ) {
/* add some space between groups in a list */
margin-top: 1em;

-- 
To view, visit https://gerrit.wikimedia.org/r/403736
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I73e39c075e5018eb1af09d5336b44c7613128b47
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Improve PARAM_HELP_MSG_PER_VALUE documentation

2018-01-11 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403707 )

Change subject: Improve PARAM_HELP_MSG_PER_VALUE documentation
..

Improve PARAM_HELP_MSG_PER_VALUE documentation

Per-value documentation is only generated if this option is specified,
even if it is only set to an empty array (i. e., when using the default
key for all values). Attempt to make this more clear.

Change-Id: I844df226271aadb1f06b3cc00ba32cc6c06ec76a
---
M includes/api/ApiBase.php
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/07/403707/1

diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 83d2ae9..6ff4eed 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -155,6 +155,7 @@
 * ((string|array|Message)[]) When PARAM_TYPE is an array, this is an 
array
 * mapping those values to $msg for ApiBase::makeMessage(). Any value 
not
 * having a mapping will use 
apihelp-{$path}-paramvalue-{$param}-{$value}.
+* (Specify an empty array to use that default message key for all 
values.)
 * @since 1.25
 */
const PARAM_HELP_MSG_PER_VALUE = 14;

-- 
To view, visit https://gerrit.wikimedia.org/r/403707
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I844df226271aadb1f06b3cc00ba32cc6c06ec76a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Ignore deprecated constraints

2018-01-11 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403641 )

Change subject: Ignore deprecated constraints
..

Ignore deprecated constraints

If a constraint statement is deprecated, don’t import the constraint
into the database at all. This provides editors with an easy way to
temporarily disable a constraint without removing it from the property.

Bug: T180874
Change-Id: I9a5bc78e5b204d7ff07ab4518c0fc80abf801ba7
---
M src/UpdateConstraintsTableJob.php
M tests/phpunit/Job/UpdateConstraintsTableJobTest.php
2 files changed, 64 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/41/403641/1

diff --git a/src/UpdateConstraintsTableJob.php 
b/src/UpdateConstraintsTableJob.php
index 2bde8ba..9b72cbf 100644
--- a/src/UpdateConstraintsTableJob.php
+++ b/src/UpdateConstraintsTableJob.php
@@ -122,7 +122,9 @@
ConstraintRepository $constraintRepo,
PropertyId $propertyConstraintPropertyId
) {
-   $constraintsStatements = 
$property->getStatements()->getByPropertyId( $propertyConstraintPropertyId );
+   $constraintsStatements = $property->getStatements()
+   ->getByPropertyId( $propertyConstraintPropertyId )
+   ->getByRank( [ Statement::RANK_PREFERRED, 
Statement::RANK_NORMAL ] );
$constraints = [];
foreach ( $constraintsStatements->getIterator() as 
$constraintStatement ) {
$constraints[] = $this->extractConstraintFromStatement( 
$property->getId(), $constraintStatement );
diff --git a/tests/phpunit/Job/UpdateConstraintsTableJobTest.php 
b/tests/phpunit/Job/UpdateConstraintsTableJobTest.php
index 85a..a13b551 100644
--- a/tests/phpunit/Job/UpdateConstraintsTableJobTest.php
+++ b/tests/phpunit/Job/UpdateConstraintsTableJobTest.php
@@ -10,12 +10,14 @@
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\DataModel\Entity\Property;
 use Wikibase\DataModel\Entity\PropertyId;
+use Wikibase\DataModel\Services\Lookup\InMemoryEntityLookup;
 use Wikibase\DataModel\Snak\PropertyNoValueSnak;
 use Wikibase\DataModel\Snak\PropertySomeValueSnak;
 use Wikibase\DataModel\Snak\PropertyValueSnak;
 use Wikibase\DataModel\Snak\SnakList;
 use Wikibase\DataModel\Statement\Statement;
 use Wikibase\DataModel\Statement\StatementList;
+use Wikibase\Repo\Tests\NewStatement;
 use WikibaseQuality\ConstraintReport\ConstraintRepository;
 use WikibaseQuality\ConstraintReport\Tests\DefaultConfig;
 use WikibaseQuality\ConstraintReport\UpdateConstraintsTableJob;
@@ -250,6 +252,65 @@
);
}
 
+   public function testImportConstraintsForProperty_Deprecated() {
+   $config = $this->getDefaultConfig();
+   $propertyConstraintId = $config->get( 
'WBQualityConstraintsPropertyConstraintId' );
+   $usedForValuesOnlyId = $config->get( 
'WBQualityConstraintsUsedForValuesOnlyConstraintId' );
+   $usedAsQualifierId = $config->get( 
'WBQualityConstraintsUsedAsQualifierConstraintId' );
+   $usedAsReferenceId = $config->get( 
'WBQualityConstraintsUsedAsReferenceConstraintId' );
+   $preferredConstraintStatement = NewStatement::forProperty( 
$propertyConstraintId )
+   ->withValue( new ItemId( $usedForValuesOnlyId ) )
+   ->withPreferredRank()
+   ->build();
+   $normalConstraintStatement = NewStatement::forProperty( 
$propertyConstraintId )
+   ->withValue( new ItemId( $usedAsQualifierId ) )
+   ->withNormalRank()
+   ->build();
+   $deprecatedConstraintStatement = NewStatement::forProperty( 
$propertyConstraintId )
+   ->withValue( new ItemId( $usedAsReferenceId ) )
+   ->withDeprecatedRank()
+   ->build();
+   $property = new Property(
+   new PropertyId( 'P3' ),
+   null,
+   'string',
+   new StatementList( [
+   $preferredConstraintStatement,
+   $normalConstraintStatement,
+   $deprecatedConstraintStatement
+   ] )
+   );
+   $entityLookup = new InMemoryEntityLookup();
+   $entityLookup->addEntity( $property );
+
+   $constraintRepository = $this->getMock( 
ConstraintRepository::class );
+   $constraintRepository->expects( $this->once() )
+   ->method( 'insertBatch' )
+   ->with( $this->callback(
+   function( array $constraints ) use ( 
$usedForValuesOnlyId, $usedAsQualifierId ) {
+   

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Gradually enable constraints gadget for all users

2018-01-10 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403459 )

Change subject: Gradually enable constraints gadget for all users
..

Gradually enable constraints gadget for all users

Starting 2018-02-28, we enable the constraints gadget for more and more
users (selected by the first character of their user name), until by
2018-04-04 it’s enabled for all (logged in) users. This is done by
loading a new ResourceLoader module unconditionally which then,
depending on the user name, possibly pulls in the gadget module.

Bug: T184069
Change-Id: If67d053626b85dfb2e870b2720fda689a8ee25b6
---
M extension.json
A modules/rollout/rollout.js
M src/WikibaseQualityConstraintsHooks.php
3 files changed, 66 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/59/403459/1

diff --git a/extension.json b/extension.json
index 7e5c26b..61eb574 100644
--- a/extension.json
+++ b/extension.json
@@ -21,7 +21,8 @@
"Hooks": {
"LoadExtensionSchemaUpdates": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onCreateSchema",
"WikibaseChangeNotification": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onWikibaseChange",
-   "ArticlePurge": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onArticlePurge"
+   "ArticlePurge": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onArticlePurge",
+   "BeforePageDisplay": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onBeforePageDisplay"
},
"SpecialPages": {
"ConstraintReport": 
"WikibaseQuality\\ConstraintReport\\Specials\\SpecialConstraintReport::newFromGlobalState"
@@ -104,6 +105,9 @@
"wikibase.quality.constraints.ui"
],
"skipFunction": "modules/gadget-skip.js"
+   },
+   "wikibase.quality.constraints.rollout": {
+   "scripts": "modules/rollout/rollout.js"
}
},
"JobClasses": {
diff --git a/modules/rollout/rollout.js b/modules/rollout/rollout.js
new file mode 100644
index 000..b8ddb04
--- /dev/null
+++ b/modules/rollout/rollout.js
@@ -0,0 +1,42 @@
+( function( mw ) {
+   'use strict';
+
+   function isEnabledForUserName( userName, date ) {
+   var threshold, initial, week;
+
+   if ( userName === null ) {
+   // anonymous
+   return false;
+   }
+
+   userName = userName.toLowerCase();
+   initial = userName[ 0 ];
+
+   if ( initial === 'z' ) {
+   week = 0;
+   } else if ( initial >= 'w' && initial < 'z' ) {
+   week = 1;
+   } else if ( initial >= 't' && initial < 'w' ) {
+   week = 2;
+   } else if ( initial >= 'n' && initial < 't' ) {
+   week = 3;
+   } else if ( initial >= 'e' && initial < 'n' ) {
+   week = 4;
+   } else {
+   week = 5;
+   }
+
+   threshold = new Date( Date.UTC(
+   2018,
+   3 - 1, // month numbers are zero-based
+   week * 7 // out-of-range values overflow into previous 
or next month(s)
+   ) );
+
+   return date.getTime() >= threshold.getTime();
+   }
+
+   if ( isEnabledForUserName( mw.config.get( 'wgUserName' ), new Date() ) 
) {
+   mw.loader.load( [ 'wikibase.quality.constraints.gadget' ] );
+   }
+
+} )( mediaWiki );
diff --git a/src/WikibaseQualityConstraintsHooks.php 
b/src/WikibaseQualityConstraintsHooks.php
index e24a3c8..6ec1447 100644
--- a/src/WikibaseQualityConstraintsHooks.php
+++ b/src/WikibaseQualityConstraintsHooks.php
@@ -7,6 +7,8 @@
 use JobQueueGroup;
 use JobSpecification;
 use MediaWiki\MediaWikiServices;
+use OutputPage;
+use Skin;
 use Title;
 use Wikibase\Change;
 use Wikibase\DataModel\Entity\PropertyId;
@@ -81,4 +83,21 @@
}
}
 
+   public static function onBeforePageDisplay( OutputPage &$out, Skin 
&$skin ) {
+   $repo = WikibaseRepo::getDefaultInstance();
+
+   $lookup = $repo->getEntityNamespaceLookup();
+   $title = $out->getTitle();
+   if ( $title === null ) {
+   return;
+   }
+
+   if (
+   $lookup->isEntityNamespace( $title->getNamespace() ) &&
+   $out->getUser()->isLoggedIn()
+   ) {
+   $out->addModules( 
'wikibase.quality.constraints.rollout' );
+

[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Remove misleading comment

2018-01-10 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403442 )

Change subject: Remove misleading comment
..

Remove misleading comment

It was probably copied from DummyChangeTransmitter in commit 3c17f1bc6b
(change I9fc12a0eef), but HookChangeTransmitter actually does something.

Change-Id: I242b63a65058cafbc0d208879a761c37e9d1cc5f
---
M repo/includes/Notifications/HookChangeTransmitter.php
1 file changed, 0 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/42/403442/1

diff --git a/repo/includes/Notifications/HookChangeTransmitter.php 
b/repo/includes/Notifications/HookChangeTransmitter.php
index 0ac03c9..37f8c73 100644
--- a/repo/includes/Notifications/HookChangeTransmitter.php
+++ b/repo/includes/Notifications/HookChangeTransmitter.php
@@ -31,8 +31,6 @@
/**
 * @see ChangeNotificationChannel::sendChangeNotification()
 *
-* This dummy implementation does nothing.
-*
 * @param Change $change
 */
public function transmitChange( Change $change ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/403442
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I242b63a65058cafbc0d208879a761c37e9d1cc5f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add missing @throws ConstraintParameterException

2018-01-10 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403421 )

Change subject: Add missing @throws ConstraintParameterException
..

Add missing @throws ConstraintParameterException

Most ConstaintChecker::checkConstraint() implementations can throw a
ConstraintParameterException. The interface documentation already
indicates this, but the documentations of the individual implementations
were previously missing the @throws tag, resulting in IntelliJ warnings.

(Some of them still have warnings due to a possible ConfigException, but
I don’t want to indicate that: as far as I can tell, since we always
call $config->get() with a constant name, I don’t think this exception
can actually be thrown.

Change-Id: I1543f1e80d66d86caca81736ad822b661ece9732
---
M src/ConstraintCheck/Checker/CommonsLinkChecker.php
M src/ConstraintCheck/Checker/ConflictsWithChecker.php
M src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
M src/ConstraintCheck/Checker/FormatChecker.php
M src/ConstraintCheck/Checker/InverseChecker.php
M src/ConstraintCheck/Checker/ItemChecker.php
M src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
M src/ConstraintCheck/Checker/OneOfChecker.php
M src/ConstraintCheck/Checker/QualifiersChecker.php
M src/ConstraintCheck/Checker/RangeChecker.php
M src/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
M src/ConstraintCheck/Checker/TypeChecker.php
M src/ConstraintCheck/Checker/ValueTypeChecker.php
13 files changed, 24 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/21/403421/1

diff --git a/src/ConstraintCheck/Checker/CommonsLinkChecker.php 
b/src/ConstraintCheck/Checker/CommonsLinkChecker.php
index 59e0f1e..ab355a2 100644
--- a/src/ConstraintCheck/Checker/CommonsLinkChecker.php
+++ b/src/ConstraintCheck/Checker/CommonsLinkChecker.php
@@ -86,6 +86,8 @@
 * @param Constraint $constraint
 *
 * @return CheckResult
+*
+* @throws ConstraintParameterException
 */
public function checkConstraint( Context $context, Constraint 
$constraint ) {
$parameters = [];
diff --git a/src/ConstraintCheck/Checker/ConflictsWithChecker.php 
b/src/ConstraintCheck/Checker/ConflictsWithChecker.php
index b2f4ddc..764cb1d 100644
--- a/src/ConstraintCheck/Checker/ConflictsWithChecker.php
+++ b/src/ConstraintCheck/Checker/ConflictsWithChecker.php
@@ -66,6 +66,8 @@
 * @param Constraint $constraint
 *
 * @return CheckResult
+*
+* @throws ConstraintParameterException
 */
public function checkConstraint( Context $context, Constraint 
$constraint ) {
if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
diff --git a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 
b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
index 3f48e92..299101c 100644
--- a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
+++ b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
@@ -116,6 +116,8 @@
 * @param Constraint $constraint
 *
 * @return CheckResult
+*
+* @throws ConstraintParameterException
 */
public function checkConstraint( Context $context, Constraint 
$constraint ) {
if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
diff --git a/src/ConstraintCheck/Checker/FormatChecker.php 
b/src/ConstraintCheck/Checker/FormatChecker.php
index b3f845c..f5ed2a1 100644
--- a/src/ConstraintCheck/Checker/FormatChecker.php
+++ b/src/ConstraintCheck/Checker/FormatChecker.php
@@ -69,6 +69,8 @@
 * @param Constraint $constraint
 *
 * @return CheckResult
+*
+* @throws ConstraintParameterException
 */
public function checkConstraint( Context $context, Constraint 
$constraint ) {
$parameters = [];
diff --git a/src/ConstraintCheck/Checker/InverseChecker.php 
b/src/ConstraintCheck/Checker/InverseChecker.php
index 42b9611..71ece54 100644
--- a/src/ConstraintCheck/Checker/InverseChecker.php
+++ b/src/ConstraintCheck/Checker/InverseChecker.php
@@ -69,6 +69,8 @@
 * @param Constraint $constraint
 *
 * @return CheckResult
+*
+* @throws ConstraintParameterException
 */
public function checkConstraint( Context $context, Constraint 
$constraint ) {
if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
diff --git a/src/ConstraintCheck/Checker/ItemChecker.php 
b/src/ConstraintCheck/Checker/ItemChecker.php
index 135a8af..9f3939f 100644
--- a/src/ConstraintCheck/Checker/ItemChecker.php
+++ b/src/ConstraintCheck/Checker/ItemChecker.php
@@ -65,6 +65,8 @@
 * @param Constraint $constraint
 *
 * @return CheckResult
+*
+* @throws 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Remove detail fields from API response by default

2018-01-09 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403207 )

Change subject: Remove detail fields from API response by default
..

Remove detail fields from API response by default

This option has been set to true on Wikimedia wikis since
mediawiki-config commit e4c63ff9cd (change I32d679cd5c). Let’s make that
the default so we can remove the specific config from mediawiki-config
again at some point.

Bug: T180614
Change-Id: I1d8460aa277b45f3872d5cde82c31277af278592
---
M extension.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/07/403207/1

diff --git a/extension.json b/extension.json
index 7e5c26b..8f5a3df 100644
--- a/extension.json
+++ b/extension.json
@@ -169,7 +169,7 @@
"public": true
},
"WBQualityConstraintsIncludeDetailInApi": {
-   "value": true,
+   "value": false,
"description": "Whether to include the 'detail' and 
'detailHTML' fields in the response of the wbcheckconstraints API action.",
"public": true
},

-- 
To view, visit https://gerrit.wikimedia.org/r/403207
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d8460aa277b45f3872d5cde82c31277af278592
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: Enable caching of constraint check results

2018-01-09 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403195 )

Change subject: Enable caching of constraint check results
..

Enable caching of constraint check results

This enables caching of responses of the wbcheckconstraints API action,
provided by the WikibaseQualityConstraints extension on Wikidata and
related wikis. Results are stored in the WANObjectCache; the TTL is
configurable with $WBQualityConstraintsCacheCheckConstraintsTTLSeconds,
but left at its default value of 86400 (one day) in this change.

Bug: T181060
Change-Id: I06b5d908c02a0d32c6e3e3227b57942682dbfacd
---
M wmf-config/Wikibase-production.php
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/95/403195/1

diff --git a/wmf-config/Wikibase-production.php 
b/wmf-config/Wikibase-production.php
index 65fe6d0..c4e8669 100644
--- a/wmf-config/Wikibase-production.php
+++ b/wmf-config/Wikibase-production.php
@@ -140,6 +140,7 @@
$wgWBQualityConstraintsSparqlEndpoint = 
$wgWBRepoSettings['sparqlEndpoint'];
$wgWBQualityConstraintsSparqlMaxMillis = 5000; // limit SPARQL 
queries to just 5 seconds for now
$wgWBQualityConstraintsTypeCheckMaxEntities = 10; // only check 
few entities in PHP => fall back to SPARQL very quickly
+   $wgWBQualityConstraintsCacheCheckConstraintsResults = true;
$wgWBQualityConstraintsPropertiesWithViolatingQualifiers = [ 
'P1855', 'P2271' ]; // T183267
// T148411: Use profile that uses statement boosting by default 
to boost/unboost specific types

$wgWBRepoSettings['entitySearch']['defaultPrefixRescoreProfile'] = 
'wikibase_prefix_boost';

-- 
To view, visit https://gerrit.wikimedia.org/r/403195
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I06b5d908c02a0d32c6e3e3227b57942682dbfacd
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] wikidata...gui[master]: Add lazy loading images and grid layout in rows to images

2018-01-09 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403192 )

Change subject: Add lazy loading images and grid layout in rows to images
..

Add lazy loading images and grid layout in rows to images

This adds lazy loading to images from queries so they do not all load at
the same time, which is very slow and a bad user experiance for large
queries. This also improves the layout and arranges the images in order.
The heights of images must be uniform within a row so that they do not
stagger at the bottom.

Bug: T166216
Change-Id: I56a144b4b228b1a60a195c3f0011cd88cc4108f4
---
M embed.html
M index.html
M style.less
M wikibase/queryService/ui/resultBrowser/ImageResultBrowser.js
M wikibase/tests/index.html
A wikibase/tests/queryService/ui/resultBrowser/ImageResultBrowser.test.js
M wikibase/tests/queryService/ui/resultBrowser/ResultBrowser.test.js
7 files changed, 331 insertions(+), 67 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/92/403192/1

diff --git a/embed.html b/embed.html
index 72cbf8a..e8e77fb 100644
--- a/embed.html
+++ b/embed.html
@@ -108,6 +108,9 @@
 .header-toolbar:hover {
opacity: 1;
 }
+.img-grid {
+   width: 95vw;
+}
 
 
 
@@ -150,6 +153,10 @@
Test result
Test error
 
+   
+   
+   Loading...
+   


  Explorer
diff --git a/index.html b/index.html
index 1684e15..744173a 100644
--- a/index.html
+++ b/index.html
@@ -253,6 +253,12 @@

Test 
error

+   
+   
+   
+   Loading...
+   
+   
 


diff --git a/style.less b/style.less
index 9c1bb04..28b6885 100644
--- a/style.less
+++ b/style.less
@@ -414,75 +414,64 @@
color: rgba( 51, 122, 183, 0.45 );
 }
 
-/* masonry */
-.masonry {
+/* image grid */
+.img-grid {
width: 95%;
margin: 3em auto;
-   margin: 1.5em 0;
+   margin: 1.5em auto;
padding: 0;
-   -moz-column-gap: 1.5em;
-   -webkit-column-gap: 1.5em;
-   column-gap: 1.5em;
font-size: 0.85em;
 }
-.item > a > img {
+.item.hidden {
+   visibility: hidden;
+}
+.item-row {
width: 100%;
-   display: inline-block;
+}
+.hidden-row {
+   height: 50px;
+   visibility: hidden;
 }
 .item {
-   display: inline-block;
background: #fff;
padding: 1em;
-   margin: 0 0 1.5em;
-   width: 100%;
+   margin: 0 0.75em 1.5em;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-shadow: 2px 2px 4px 0 #ccc;
+   display: inline-block;
+}
+.hidden-row > .item{
+   display: none;
+}
+.item-img {
+   width: 100%;
+}
+.summary > div {
+   height: 1.5em;
+}
+.summary > div > span {
+   white-space: nowrap;
+   text-overflow: ellipsis;
+   display: block;
+   overflow: hidden;
+}
+.summary .glyphicon {
+   display: inline;
 }
 
-@media only screen and ( min-width: 400px ) {
-   .masonry {
-   -moz-column-count: 2;
-   -webkit-column-count: 2;
-   column-count: 2;
-   }
+/* loading spinner */
+#loading-spinner {
+   display: none;
+   color: #777;
+}
+#loading-spinner > .fa-spinner {
+   margin: 0 auto 20px;
+   display: block;
 }
 
-@media only screen and ( min-width: 700px ) {
-   .masonry {
-   -moz-column-count: 3;
-   -webkit-column-count: 3;
-   column-count: 3;
-   }
-}
-
-@media only screen and ( min-width: 900px ) {
-   .masonry {
-   -moz-column-count: 4;
-   -webkit-column-count: 4;
-   column-count: 4;
-   }
-}
-
-@media only screen and ( min-width: 1100px ) {
-   .masonry {
-   -moz-column-count: 5;
-   -webkit-column-count: 5;
-   column-count: 5;
-   }
-}
-
-@media only screen and ( min-width: 1280px ) {
-   .wrapper {
-   width: 1260px;
-   }
-}
-
-/*
-   ActionBar
-*/
-
+/* ActionBar */
 .action-bar .progress {
height: 30px;
font-size: 30px;
diff --git a/wikibase/queryService/ui/resultBrowser/ImageResultBrowser.js 
b/wikibase/queryService/ui/resultBrowser/ImageResultBrowser.js
index 0fcd2b7..125429e 100644
--- a/wikibase/queryService/ui/resultBrowser/ImageResultBrowser.js
+++ b/wikibase/queryService/ui/resultBrowser/ImageResultBrowser.js
@@ -1,9 +1,10 @@
+/* jshint esversion: 6 */
 var wikibase = wikibase || {};
 wikibase.queryService = wikibase.queryService || {};
 wikibase.queryService.ui = wikibase.queryService.ui || {};
 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: DNM: CI test

2018-01-09 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403132 )

Change subject: DNM: CI test
..

DNM: CI test

CI is failing for reasons I don’t understand, and I can’t reproduce it
locally. Hopefully this gives me some more information.

Change-Id: Id7b235c5f3b0a08195eb98d3045d1a108ce474dc
---
M tests/phpunit/Helper/ConstraintParameterParserTest.php
M tests/phpunit/ResultAssertions.php
2 files changed, 12 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/32/403132/1

diff --git a/tests/phpunit/Helper/ConstraintParameterParserTest.php 
b/tests/phpunit/Helper/ConstraintParameterParserTest.php
index 1f08f7a..b8e39c0 100644
--- a/tests/phpunit/Helper/ConstraintParameterParserTest.php
+++ b/tests/phpunit/Helper/ConstraintParameterParserTest.php
@@ -84,6 +84,10 @@
$this->assertTrue( false,
"$method should have thrown a 
ConstraintParameterException with message ⧼${messageKey}⧽." );
} catch ( ConstraintParameterException $exception ) {
+   $message = $exception->getMessage();
+   if ( !is_string( $message ) ) {
+   var_export( $exception );
+   }
$checkResult = new CheckResult(
new MainSnakContext(
new Item( new ItemId( 'Q1' ) ),
@@ -92,7 +96,7 @@
$this->constraint,
[],
CheckResult::STATUS_VIOLATION,
-   $exception->getMessage()
+   $message
);
$this->assertViolation( $checkResult, $messageKey );
}
diff --git a/tests/phpunit/ResultAssertions.php 
b/tests/phpunit/ResultAssertions.php
index df64307..80b7190 100644
--- a/tests/phpunit/ResultAssertions.php
+++ b/tests/phpunit/ResultAssertions.php
@@ -44,10 +44,13 @@
$result->getStatus(),
'Check should not comply'
);
+   $resultMessage = $result->getMessage();
+   if ( !is_string( $resultMessage ) ) {
+   var_export( $result );
+   }
$this->assertStringNotMatchesFormat(
-   "⧼%a⧽",
-   $result->getMessage(),
-   "Message should not refer to a non-existing message key 
({$result->getMessage()})."
+   "⧼%a⧽", $resultMessage,
+   "Message should not refer to a non-existing message key 
({$resultMessage})."
);
if ( $messageKey !== null ) {
$message = wfMessage( $messageKey );
@@ -64,8 +67,7 @@
$pattern .= '%a';
}
$this->assertStringMatchesFormat(
-   $pattern,
-   $result->getMessage(),
+   $pattern, $resultMessage,
"Violation message should be ⧼${messageKey}⧽."
);
}

-- 
To view, visit https://gerrit.wikimedia.org/r/403132
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7b235c5f3b0a08195eb98d3045d1a108ce474dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Don’t use `self` reference in type hint

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402888 )

Change subject: Don’t use `self` reference in type hint
..

Don’t use `self` reference in type hint

The change of EntityContent::getDiff’s first parameter from
EntityContent to self makes the tests fail on PHP7 [1] (which is not
part of our pre-merge integration builds). I’m not sure why, but I
suspect that PHPUnit’s mocking framework, when instructed to create a
mock of ItemContent (a subclass of EntityContent), produces the
following signature:

class Mock_ItemContent_somehash {
public function getDiff( self $toContent ) {
// ...
}
}

If PHPUnit doesn’t resolve the `self` in EntityContent::getDiff to the
EntityContent class name, then `self` in the fake mocked class refers to
the fake mocked class, not EntityContent, resulting in an error due to
the incompatible signature.

This should probably considered a PHPUnit bug, but for the time being I
think we just need to work around it. (Our version of PHPUnit is ancient
due to MediaWiki’s support for old PHP versions, so this bug might well
be fixed in newer versions already.)

[1]: 
https://travis-ci.org/wikimedia/mediawiki-extensions-Wikibase/jobs/326482650

Change-Id: Ie261567b840d600a1a7dd7246f0d45e83ebf8c34
---
M repo/includes/Content/EntityContent.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/88/402888/1

diff --git a/repo/includes/Content/EntityContent.php 
b/repo/includes/Content/EntityContent.php
index b858d23..2063739 100644
--- a/repo/includes/Content/EntityContent.php
+++ b/repo/includes/Content/EntityContent.php
@@ -538,7 +538,7 @@
 *
 * @return EntityContentDiff
 */
-   public function getDiff( self $toContent ) {
+   public function getDiff( EntityContent $toContent ) {
$fromContent = $this;
 
$differ = new MapDiffer();

-- 
To view, visit https://gerrit.wikimedia.org/r/402888
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie261567b840d600a1a7dd7246f0d45e83ebf8c34
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add scope support to DelegatingConstraintChecker

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402884 )

Change subject: Add scope support to DelegatingConstraintChecker
..

Add scope support to DelegatingConstraintChecker

The “constraint scope” parameter’s validity is checked along with other
common parameters like “exception to constraint” or “constraint status”,
and when it comes to actually checking a constraint,
DelegatingConstraintChecker also takes care of assigning the default
scope and testing whether a constraint can even be checked on a certain
context.

Bug: T183542
Change-Id: Ie9d7c1c9e7a57d0e03ca0cb0f96d47d0f1869921
---
M src/ConstraintCheck/DelegatingConstraintChecker.php
M tests/phpunit/Api/CheckConstraintsTest.php
M tests/phpunit/DelegatingConstraintCheckerTest.php
3 files changed, 237 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/84/402884/1

diff --git a/src/ConstraintCheck/DelegatingConstraintChecker.php 
b/src/ConstraintCheck/DelegatingConstraintChecker.php
index cb71871..eb88ab5 100644
--- a/src/ConstraintCheck/DelegatingConstraintChecker.php
+++ b/src/ConstraintCheck/DelegatingConstraintChecker.php
@@ -190,6 +190,42 @@
return [];
}
 
+   private function getAllowedContextTypes( Constraint $constraint ) {
+   if ( !array_key_exists( $constraint->getConstraintTypeItemId(), 
$this->checkerMap ) ) {
+   return [
+   Context::TYPE_STATEMENT,
+   Context::TYPE_QUALIFIER,
+   Context::TYPE_REFERENCE,
+   ];
+   }
+
+   return array_keys( array_filter(
+   
$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
+   function ( array $supportedContextTypes ) {
+   list( $resultStatus, $default ) = 
$supportedContextTypes;
+   return $resultStatus !== 
CheckResult::STATUS_NOT_IN_SCOPE;
+   }
+   ) );
+   }
+
+   private function getDefaultContextTypes( Constraint $constraint ) {
+   if ( !array_key_exists( $constraint->getConstraintTypeItemId(), 
$this->checkerMap ) ) {
+   return [
+   Context::TYPE_STATEMENT,
+   Context::TYPE_QUALIFIER,
+   Context::TYPE_REFERENCE,
+   ];
+   }
+
+   return array_keys( array_filter(
+   
$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
+   function ( array $supportedContextTypes ) {
+   list( $resultStatus, $default ) = 
$supportedContextTypes;
+   return $default;
+   }
+   ) );
+   }
+
/**
 * Like ConstraintChecker::checkConstraintParameters,
 * but for meta-parameters common to all checkers.
@@ -214,6 +250,15 @@
}
try {

$this->constraintParameterParser->parseConstraintStatusParameter( 
$constraintParameters );
+   } catch ( ConstraintParameterException $e ) {
+   $problems[] = $e;
+   }
+   try {
+   
$this->constraintParameterParser->parseConstraintScopeParameter(
+   $constraintParameters,
+   $constraint->getConstraintTypeItemId(),
+   $this->getAllowedContextTypes( $constraint )
+   );
} catch ( ConstraintParameterException $e ) {
$problems[] = $e;
}
@@ -505,6 +550,30 @@
private function getCheckResultFor( Context $context, Constraint 
$constraint ) {
if ( array_key_exists( $constraint->getConstraintTypeItemId(), 
$this->checkerMap ) ) {
$checker = 
$this->checkerMap[$constraint->getConstraintTypeItemId()];
+   $result = null;
+
+   try {
+   $checkedContextTypes = 
$this->constraintParameterParser->parseConstraintScopeParameter(
+   $constraint->getConstraintParameters(),
+   $constraint->getConstraintTypeItemId()
+   );
+   } catch ( ConstraintParameterException $e ) {
+   $result = new CheckResult( $context, 
$constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
+   }
+   if ( 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Remove unnecessary code from checkers

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402885 )

Change subject: Remove unnecessary code from checkers
..

Remove unnecessary code from checkers

Now that DelegatingConstraintChecker is responsible for checking whether
a constraint can be checked on a context or not, depending on the
context’s type, we can remove the equivalent checks from the individual
checkers. (Besides, the STATUS_NOT_MAIN_SNAK constant was already
renamed to NOT_IN_SCOPE in I629afe85d2.)

Bug: T183542
Change-Id: I100a01e612565cec15a4f9726b11c6ef73587737
---
M src/ConstraintCheck/Checker/ConflictsWithChecker.php
M src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
M src/ConstraintCheck/Checker/InverseChecker.php
M src/ConstraintCheck/Checker/ItemChecker.php
M src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
M src/ConstraintCheck/Checker/MultiValueChecker.php
M src/ConstraintCheck/Checker/QualifiersChecker.php
M src/ConstraintCheck/Checker/SingleValueChecker.php
M src/ConstraintCheck/Checker/SymmetricChecker.php
9 files changed, 0 insertions(+), 32 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/85/402885/1

diff --git a/src/ConstraintCheck/Checker/ConflictsWithChecker.php 
b/src/ConstraintCheck/Checker/ConflictsWithChecker.php
index a1adec6..fa7033d 100644
--- a/src/ConstraintCheck/Checker/ConflictsWithChecker.php
+++ b/src/ConstraintCheck/Checker/ConflictsWithChecker.php
@@ -83,10 +83,6 @@
if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_DEPRECATED );
}
-   if ( $context->getType() !== Context::TYPE_STATEMENT ) {
-   // TODO T175562
-   return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_NOT_MAIN_SNAK );
-   }
 
$parameters = [];
$constraintParameters = $constraint->getConstraintParameters();
diff --git a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 
b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
index f52fc82..2d3922d 100644
--- a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
+++ b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
@@ -133,10 +133,6 @@
if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_DEPRECATED );
}
-   if ( $context->getType() !== Context::TYPE_STATEMENT ) {
-   // TODO T175565
-   return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_NOT_MAIN_SNAK );
-   }
 
$parameters = [];
 
diff --git a/src/ConstraintCheck/Checker/InverseChecker.php 
b/src/ConstraintCheck/Checker/InverseChecker.php
index 3b81432..a23d508 100644
--- a/src/ConstraintCheck/Checker/InverseChecker.php
+++ b/src/ConstraintCheck/Checker/InverseChecker.php
@@ -86,9 +86,6 @@
if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_DEPRECATED );
}
-   if ( $context->getType() !== Context::TYPE_STATEMENT ) {
-   return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_NOT_MAIN_SNAK );
-   }
 
$parameters = [];
$constraintParameters = $constraint->getConstraintParameters();
diff --git a/src/ConstraintCheck/Checker/ItemChecker.php 
b/src/ConstraintCheck/Checker/ItemChecker.php
index 738803b..0a5fc09 100644
--- a/src/ConstraintCheck/Checker/ItemChecker.php
+++ b/src/ConstraintCheck/Checker/ItemChecker.php
@@ -82,10 +82,6 @@
if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_DEPRECATED );
}
-   if ( $context->getType() !== Context::TYPE_STATEMENT ) {
-   // TODO T175562
-   return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_NOT_MAIN_SNAK );
-   }
 
$parameters = [];
$constraintParameters = $constraint->getConstraintParameters();
diff --git a/src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php 
b/src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
index 4aaef1a..df82637 100644
--- a/src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
+++ b/src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
@@ -64,9 +64,6 @@
if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
return new 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Rename status not-main-snak to not-in-scope

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402881 )

Change subject: Rename status not-main-snak to not-in-scope
..

Rename status not-main-snak to not-in-scope

The checkers referencing this status are not updated, since this status
will be handled centrally by DelegatingConstraintChecker (implemented in
Ie9d7c1c9e7) and the code in the checkers referencing this status will
be completely removed (in I100a01e612).

Bug: T183542
Change-Id: I629afe85d2913e092e77e64cef95543e68a4cadb
---
M i18n/en.json
M i18n/qqq.json
M modules/SpecialConstraintReportPage.less
M src/ConstraintCheck/Checker/TypeChecker.php
M src/ConstraintCheck/DelegatingConstraintChecker.php
M src/ConstraintCheck/Result/CheckResult.php
6 files changed, 8 insertions(+), 9 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/81/402881/1

diff --git a/i18n/en.json b/i18n/en.json
index 573918e..8c65861 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -24,7 +24,7 @@
"wbqc-constraintreport-status-bad-parameters": "Bad parameters",
"wbqc-constraintreport-status-deprecated": "Deprecated",
"wbqc-constraintreport-status-warning": "Warning",
-   "wbqc-constraintreport-status-not-main-snak": "Not main snak",
+   "wbqc-constraintreport-status-not-in-scope": "Not in scope",
"wbqc-constraintreport-result-table-header-status": "Status",
"wbqc-constraintreport-result-table-header-claim": "Claim",
"wbqc-constraintreport-result-table-header-constraint": "Constraint",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index fd06648..3974885 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -27,7 +27,7 @@
"wbqc-constraintreport-status-bad-parameters": "Status for constraints 
that have missing or invalid constraint parameters.",
"wbqc-constraintreport-status-deprecated": "Status for constraint 
checks that have been skipped because the statement is deprecated.",
"wbqc-constraintreport-status-warning": "Status for statements that 
violate a non-mandatory constraint.\n{{Identical|Warning}}",
-   "wbqc-constraintreport-status-not-main-snak": "Status for constraint 
checks that have been skipped because the snak to be checked is not the main 
snak of a statement (e. g. a qualifier or reference).",
+   "wbqc-constraintreport-status-not-in-scope": "Status for constraint 
checks that have been skipped because the kind of the snak to be checked (main 
snak, qualifier, or statement) is not within the scope of the constraint. This 
should follow the label of the “constraint scope” property 
([[wikidata:Property:P4680|P4680 on Wikidata]]).",
"wbqc-constraintreport-result-table-header-status": "Header of the 
column that tells whether the check found a violation or something 
else.\n{{Identical|Status}}",
"wbqc-constraintreport-result-table-header-claim": "Header of the 
column that displays a link to the claim, the used property and its 
value.\n{{Identical|Claim}}",
"wbqc-constraintreport-result-table-header-constraint": "Header of the 
column that gives information about which constraint was 
checked.\n{{Identical|Constraint}}",
diff --git a/modules/SpecialConstraintReportPage.less 
b/modules/SpecialConstraintReportPage.less
index 8fbcbcb..b97dabc 100644
--- a/modules/SpecialConstraintReportPage.less
+++ b/modules/SpecialConstraintReportPage.less
@@ -41,7 +41,7 @@
}
 
&-deprecated,
-   &-not-main-snak {
+   &-not-in-scope {
color: @colorNeutral;
}
 
diff --git a/src/ConstraintCheck/Checker/TypeChecker.php 
b/src/ConstraintCheck/Checker/TypeChecker.php
index 4bdaee3..ea1e4c2 100644
--- a/src/ConstraintCheck/Checker/TypeChecker.php
+++ b/src/ConstraintCheck/Checker/TypeChecker.php
@@ -74,7 +74,7 @@
return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_DEPRECATED );
}
if ( $context->getType() === Context::TYPE_REFERENCE ) {
-   return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_NOT_MAIN_SNAK );
+   return new CheckResult( $context, $constraint, [], 
CheckResult::STATUS_NOT_IN_SCOPE );
}
 
$parameters = [];
diff --git a/src/ConstraintCheck/DelegatingConstraintChecker.php 
b/src/ConstraintCheck/DelegatingConstraintChecker.php
index d583a04..cb71871 100644
--- a/src/ConstraintCheck/DelegatingConstraintChecker.php
+++ b/src/ConstraintCheck/DelegatingConstraintChecker.php
@@ -587,7 +587,7 @@
CheckResult::STATUS_EXCEPTION => $orderNum++,
CheckResult::STATUS_COMPLIANCE => $orderNum++,
CheckResult::STATUS_DEPRECATED => $orderNum++,
-   

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add support for constraint scopes to ConstraintParameterRend...

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402880 )

Change subject: Add support for constraint scopes to ConstraintParameterRenderer
..

Add support for constraint scopes to ConstraintParameterRenderer

ConstraintParameterParser turns constraint scopes from their special
items into the corresponding Role constants, but for error messages we’d
like to have the items again.

(As an alternative, I first considered having ConstraintParameterParser
return the item IDs as well, but that only gets us “X is not a valid
scope” messages, not “the valid scopes are X, Y, Z”.)

Change-Id: I0d6e77a14b79dc42e8dc2ca4f99d3ad7c24f5ee6
---
M src/Api/CheckConstraints.php
M src/ConstraintParameterRenderer.php
M src/ConstraintReportFactory.php
M src/Specials/SpecialConstraintReport.php
M tests/phpunit/Api/CheckConstraintsTest.php
M tests/phpunit/Api/CheckingResultsBuilderTest.php
M tests/phpunit/ConstraintParameters.php
M tests/phpunit/Specials/SpecialConstraintReportTest.php
8 files changed, 101 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/80/402880/1

diff --git a/src/Api/CheckConstraints.php b/src/Api/CheckConstraints.php
index d30ad93..bc4b96e 100644
--- a/src/Api/CheckConstraints.php
+++ b/src/Api/CheckConstraints.php
@@ -88,11 +88,15 @@
$entityIdHtmlLinkFormatter = 
$entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( 
$labelDescriptionLookup );
$entityIdLabelFormatterFactory = new 
EntityIdLabelFormatterFactory();
$entityIdLabelFormatter = 
$entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
-   $constraintParameterRenderer = new ConstraintParameterRenderer( 
$entityIdHtmlLinkFormatter, $valueFormatter );
$config = MediaWikiServices::getInstance()->getMainConfig();
$titleParser = 
MediaWikiServices::getInstance()->getTitleParser();
$unitConverter = $repo->getUnitConverter();
$dataFactory = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
+   $constraintParameterRenderer = new ConstraintParameterRenderer(
+   $entityIdHtmlLinkFormatter,
+   $valueFormatter,
+   $config
+   );
$constraintReportFactory = new ConstraintReportFactory(
$repo->getEntityLookup(),
$repo->getPropertyDataTypeLookup(),
diff --git a/src/ConstraintParameterRenderer.php 
b/src/ConstraintParameterRenderer.php
index 0735604..334185f 100644
--- a/src/ConstraintParameterRenderer.php
+++ b/src/ConstraintParameterRenderer.php
@@ -1,6 +1,7 @@
 entityIdLabelFormatter = $entityIdFormatter;
$this->dataValueFormatter = $dataValueFormatter;
+   $this->config = $config;
}
 
/**
@@ -223,6 +233,40 @@
}
 
/**
+* Format a constraint scope (check on main snak, on qualifiers, or on 
references).
+*
+* @param string $scope one of the Context::TYPE_* constants
+* @param string|null $role one of the Role constants or null
+* @return string HTML
+*/
+   public function formatConstraintScope( $scope, $role = null ) {
+   switch ( $scope ) {
+   case Context::TYPE_STATEMENT:
+   $itemId = $this->config->get(
+   
'WBQualityConstraintsConstraintCheckedOnMainValueId'
+   );
+   break;
+   case Context::TYPE_QUALIFIER:
+   $itemId = $this->config->get(
+   
'WBQualityConstraintsConstraintCheckedOnQualifiersId'
+   );
+   break;
+   case Context::TYPE_REFERENCE:
+   $itemId = $this->config->get(
+   
'WBQualityConstraintsConstraintCheckedOnReferencesId'
+   );
+   break;
+   default:
+   // callers should never let this happen, but if 
it does happen,
+   // showing “unknown value” seems reasonable
+   // @codeCoverageIgnoreStart
+   return $this->formatItemIdSnakValue( 
ItemIdSnakValue::someValue(), $role );
+   // @codeCoverageIgnoreEnd
+   }
+   return $this->formatItemId( $itemId, $role );
+   }
+
+   /**
 * Format a list of (potentially unparsed) property IDs.
 *
 * The returned array begins with an HTML 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add ConstraintChecker::getSupportedContextTypes()

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402882 )

Change subject: Add ConstraintChecker::getSupportedContextTypes()
..

Add ConstraintChecker::getSupportedContextTypes()

This method describes which context types (scopes) a constraint type
supports, and which should be checked by default. Using this
information, the constraint scope parameter can be parsed and validated
in a single location (most likely DelegatingConstraintChecker) without
duplicating error handling code in several locations.

Bug: T183542
Change-Id: I6720b4a984a6ba2daa7425a6de21a30e09af22db
---
M src/ConstraintCheck/Checker/CommonsLinkChecker.php
M src/ConstraintCheck/Checker/ConflictsWithChecker.php
M src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
M src/ConstraintCheck/Checker/FormatChecker.php
M src/ConstraintCheck/Checker/InverseChecker.php
M src/ConstraintCheck/Checker/ItemChecker.php
M src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
M src/ConstraintCheck/Checker/MultiValueChecker.php
M src/ConstraintCheck/Checker/OneOfChecker.php
M src/ConstraintCheck/Checker/QualifierChecker.php
M src/ConstraintCheck/Checker/QualifiersChecker.php
M src/ConstraintCheck/Checker/RangeChecker.php
M src/ConstraintCheck/Checker/ReferenceChecker.php
M src/ConstraintCheck/Checker/SingleValueChecker.php
M src/ConstraintCheck/Checker/SymmetricChecker.php
M src/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
M src/ConstraintCheck/Checker/TypeChecker.php
M src/ConstraintCheck/Checker/UniqueValueChecker.php
M src/ConstraintCheck/Checker/ValueOnlyChecker.php
M src/ConstraintCheck/Checker/ValueTypeChecker.php
M src/ConstraintCheck/ConstraintChecker.php
M tests/phpunit/Fake/FakeChecker.php
22 files changed, 267 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/82/402882/1

diff --git a/src/ConstraintCheck/Checker/CommonsLinkChecker.php 
b/src/ConstraintCheck/Checker/CommonsLinkChecker.php
index 59e0f1e..618ccd8 100644
--- a/src/ConstraintCheck/Checker/CommonsLinkChecker.php
+++ b/src/ConstraintCheck/Checker/CommonsLinkChecker.php
@@ -52,6 +52,17 @@
}
 
/**
+* @codeCoverageIgnore This method is purely declarative.
+*/
+   public function getSupportedContextTypes() {
+   return [
+   Context::TYPE_STATEMENT => [ 
CheckResult::STATUS_COMPLIANCE, true ],
+   Context::TYPE_QUALIFIER => [ 
CheckResult::STATUS_COMPLIANCE, true ],
+   Context::TYPE_REFERENCE => [ 
CheckResult::STATUS_COMPLIANCE, true ],
+   ];
+   }
+
+   /**
 * Get the number of a namespace on Wikimedia Commons (commonswiki).
 * All namespaces not known to this function will be looked up by the 
TitleParser.
 *
diff --git a/src/ConstraintCheck/Checker/ConflictsWithChecker.php 
b/src/ConstraintCheck/Checker/ConflictsWithChecker.php
index b2f4ddc..a1adec6 100644
--- a/src/ConstraintCheck/Checker/ConflictsWithChecker.php
+++ b/src/ConstraintCheck/Checker/ConflictsWithChecker.php
@@ -60,6 +60,18 @@
}
 
/**
+* @codeCoverageIgnore This method is purely declarative.
+*/
+   public function getSupportedContextTypes() {
+   return [
+   Context::TYPE_STATEMENT => [ 
CheckResult::STATUS_COMPLIANCE, true ],
+   // TODO T175562
+   Context::TYPE_QUALIFIER => [ CheckResult::STATUS_TODO, 
false ],
+   Context::TYPE_REFERENCE => [ CheckResult::STATUS_TODO, 
false ],
+   ];
+   }
+
+   /**
 * Checks 'Conflicts with' constraint.
 *
 * @param Context $context
diff --git a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 
b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
index 3f48e92..f52fc82 100644
--- a/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
+++ b/src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
@@ -62,6 +62,18 @@
}
 
/**
+* @codeCoverageIgnore This method is purely declarative.
+*/
+   public function getSupportedContextTypes() {
+   return [
+   Context::TYPE_STATEMENT => [ 
CheckResult::STATUS_COMPLIANCE, true ],
+   // TODO T175565
+   Context::TYPE_QUALIFIER => [ CheckResult::STATUS_TODO, 
false ],
+   Context::TYPE_REFERENCE => [ CheckResult::STATUS_TODO, 
false ],
+   ];
+   }
+
+   /**
 * @param Constraint $constraint
 *
 * @throws ConstraintParameterException
diff --git a/src/ConstraintCheck/Checker/FormatChecker.php 
b/src/ConstraintCheck/Checker/FormatChecker.php
index b3f845c..509f3cf 100644
--- a/src/ConstraintCheck/Checker/FormatChecker.php
+++ 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Fix CheckResult::STATUS_* comment

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402879 )

Change subject: Fix CheckResult::STATUS_* comment
..

Fix CheckResult::STATUS_* comment

SpecialConstraintReportPage.css was renamed to
SpecialConstraintReportPage.less in commit a7d7fb93ad (change
I5d53b985dd), and the stray “update” must have been a typo.

Change-Id: I8584648832987df802e7fc5b5f3a117be6b19ad7
---
M src/ConstraintCheck/Result/CheckResult.php
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/79/402879/1

diff --git a/src/ConstraintCheck/Result/CheckResult.php 
b/src/ConstraintCheck/Result/CheckResult.php
index 2e40ba0..57109bb 100644
--- a/src/ConstraintCheck/Result/CheckResult.php
+++ b/src/ConstraintCheck/Result/CheckResult.php
@@ -60,8 +60,8 @@
/*
 * When adding another status, don’t forget to also do the following:
 * * define a message for it in i18n/
-* * declare a color for it in modules/SpecialConstraintReportPage.css
-* * update $order in updateDelegatingConstraintChecker::sortResult
+* * declare a color for it in modules/SpecialConstraintReportPage.less
+* * update $order in DelegatingConstraintChecker::sortResult
 */
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/402879
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8584648832987df802e7fc5b5f3a117be6b19ad7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add scope helpers to test traits

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402883 )

Change subject: Add scope helpers to test traits
..

Add scope helpers to test traits

ConstraintParameters gains a method to turn Context::TYPE_* constants
into constraint parameters, and ResultAssertions gains an assertion that
a result is not in scope.

Bug: T183542
Change-Id: I668908f61a52c9d39ea27f590a1d72cfb541ec75
---
M tests/phpunit/ConstraintParameters.php
M tests/phpunit/ResultAssertions.php
2 files changed, 51 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/83/402883/1

diff --git a/tests/phpunit/ConstraintParameters.php 
b/tests/phpunit/ConstraintParameters.php
index 7c16529..3c0b424 100644
--- a/tests/phpunit/ConstraintParameters.php
+++ b/tests/phpunit/ConstraintParameters.php
@@ -17,6 +17,7 @@
 use Wikibase\DataModel\Snak\PropertySomeValueSnak;
 use Wikibase\DataModel\Snak\PropertyValueSnak;
 use Wikibase\DataModel\Snak\Snak;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Context\Context;
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
 use Wikibase\Repo\Parsers\TimeParserFactory;
@@ -313,4 +314,40 @@
];
}
 
+   /**
+* @param string[] $scopes Context::TYPE_* constants
+* @return array
+*/
+   public function scopeParameter( array $scopes ) {
+   $config = $this->getDefaultConfig();
+   $constraintScopeParameterId = $config->get( 
'WBQualityConstraintsConstraintScopeId' );
+   $itemIds = [];
+   foreach ( $scopes as $scope ) {
+   switch ( $scope ) {
+   case Context::TYPE_STATEMENT:
+   $itemIds[] = $config->get( 
'WBQualityConstraintsConstraintCheckedOnMainValueId' );
+   break;
+   case Context::TYPE_QUALIFIER:
+   $itemIds[] = $config->get( 
'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
+   break;
+   case Context::TYPE_REFERENCE:
+   $itemIds[] = $config->get( 
'WBQualityConstraintsConstraintCheckedOnReferencesId' );
+   break;
+   default:
+   $this->assertTrue( false, 'unknown 
context type ' . $scope );
+   }
+   }
+   return [ $constraintScopeParameterId => array_map(
+   function ( $itemId ) use ( $constraintScopeParameterId 
) {
+   return $this->getSnakSerializer()->serialize(
+   new PropertyValueSnak(
+   new PropertyId( 
$constraintScopeParameterId ),
+   new EntityIdValue( new ItemId( 
$itemId ) )
+   )
+   );
+   },
+   $itemIds
+   ) ];
+   }
+
 }
diff --git a/tests/phpunit/ResultAssertions.php 
b/tests/phpunit/ResultAssertions.php
index 3a41f11..df64307 100644
--- a/tests/phpunit/ResultAssertions.php
+++ b/tests/phpunit/ResultAssertions.php
@@ -122,4 +122,18 @@
);
}
 
+   /**
+* Assert that $result indicates a skipped constraint check
+* due to the snak not being within the scope of the constraint.
+*
+* @param CheckResult $result
+*/
+   public function assertNotInScope( CheckResult $result ) {
+   $this->assertSame(
+   CheckResult::STATUS_NOT_IN_SCOPE,
+   $result->getStatus(),
+   'Check should indicate that snak is out of scope of 
constraint; message: ' . $result->getMessage()
+   );
+   }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/402883
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I668908f61a52c9d39ea27f590a1d72cfb541ec75
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Declare dependency on jquery.makeCollapsible

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402864 )

Change subject: Declare dependency on jquery.makeCollapsible
..

Declare dependency on jquery.makeCollapsible

ConstraintReportGroup uses the makeCollapsible extension, and it seems
that it might not always be pulled in for us already.

Change-Id: I85c035ae3ade684fb184a2144c8656f6f0c50d28
---
M extension.json
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/64/402864/1

diff --git a/extension.json b/extension.json
index 4e5a372..7e5c26b 100644
--- a/extension.json
+++ b/extension.json
@@ -60,6 +60,7 @@
"dependencies": [
"oojs-ui-core",
"oojs-ui-widgets",
+   "jquery.makeCollapsible",
"wikibase"
],
"messages": [

-- 
To view, visit https://gerrit.wikimedia.org/r/402864
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I85c035ae3ade684fb184a2144c8656f6f0c50d28
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Document restriction of master_fallback mode

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402819 )

Change subject: Document restriction of master_fallback mode
..

Document restriction of master_fallback mode

Based on Amir’s comments in I7fb38cf3bb.

Change-Id: I639428ee93c10efce9a84eca6b452bf088199c20
---
M lib/includes/Store/EntityRevisionLookup.php
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/19/402819/1

diff --git a/lib/includes/Store/EntityRevisionLookup.php 
b/lib/includes/Store/EntityRevisionLookup.php
index bda324a..32c5b2a 100644
--- a/lib/includes/Store/EntityRevisionLookup.php
+++ b/lib/includes/Store/EntityRevisionLookup.php
@@ -23,6 +23,12 @@
 * Flag used to indicate that loading slightly lagged data is fine (like
 * LATEST_FROM_REPLICA), but in case an entity or revision couldn't be 
found,
 * we try loading it from master.
+*
+* Note that this flag must only be used in code
+* that is exclusively called from POST requests,
+* since master may reside in a different datacenter
+* and GET requests which trigger reading or writing to master
+* result in an error in that case.
 */
const LATEST_FROM_REPLICA_WITH_FALLBACK = 'master_fallback';
 

-- 
To view, visit https://gerrit.wikimedia.org/r/402819
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I639428ee93c10efce9a84eca6b452bf088199c20
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add type hint to array|null parameter

2018-01-08 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402808 )

Change subject: Add type hint to array|null parameter
..

Add type hint to array|null parameter

I removed the type hint for this parameter in commit a4c1832358 (change
I60ad838dda) when it was made nullable because I didn’t know that PHP
lets you declare a default argument (which makes the parameter nullable)
even when there are later parameters without default arguments.

Change-Id: I9a3645b51a0fbfb39b6b7c20393f56ba058e8525
---
M src/ConstraintCheck/Context/ApiV2Context.php
M src/ConstraintCheck/Context/Context.php
M tests/phpunit/Fake/FakeSnakContext.php
3 files changed, 3 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/08/402808/1

diff --git a/src/ConstraintCheck/Context/ApiV2Context.php 
b/src/ConstraintCheck/Context/ApiV2Context.php
index b693b10..e74613e 100644
--- a/src/ConstraintCheck/Context/ApiV2Context.php
+++ b/src/ConstraintCheck/Context/ApiV2Context.php
@@ -75,7 +75,7 @@
 */
abstract protected function ( array &$container );
 
-   public function storeCheckResultInArray( $result, array &$container ) {
+   public function storeCheckResultInArray( array $result = null, array 
&$container ) {
$mainArray = &$this->getMainArray( $container );
if ( !array_key_exists( 'results', $mainArray ) ) {
$mainArray['results'] = [];
diff --git a/src/ConstraintCheck/Context/Context.php 
b/src/ConstraintCheck/Context/Context.php
index 844bc8b..b09bfe9 100644
--- a/src/ConstraintCheck/Context/Context.php
+++ b/src/ConstraintCheck/Context/Context.php
@@ -86,6 +86,6 @@
 * @param array|null $result
 * @param array &$container
 */
-   public function storeCheckResultInArray( $result, array &$container );
+   public function storeCheckResultInArray( array $result = null, array 
&$container );
 
 }
diff --git a/tests/phpunit/Fake/FakeSnakContext.php 
b/tests/phpunit/Fake/FakeSnakContext.php
index c51f11e..632c8b3 100644
--- a/tests/phpunit/Fake/FakeSnakContext.php
+++ b/tests/phpunit/Fake/FakeSnakContext.php
@@ -32,7 +32,7 @@
return 'statement';
}
 
-   public function storeCheckResultInArray( $result, array &$container ) {
+   public function storeCheckResultInArray( array $result = null, array 
&$container ) {
if ( $result !== null ) {
$container[] = $result;
}

-- 
To view, visit https://gerrit.wikimedia.org/r/402808
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a3645b51a0fbfb39b6b7c20393f56ba058e8525
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] wikidata...gui[master]: Use moment’s relative time for “x seconds ago” message

2018-01-05 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402401 )

Change subject: Use moment’s relative time for “x seconds ago” message
..

Use moment’s relative time for “x seconds ago” message

Formatting the duration stand-alone and then appending some string does
not always yield correct results. For example, in German, the
stand-alone duration is in the nominative case („eine Minute“), but the
suffix requires the dative case („vor einer Minute“, not „vor eine
Minute“). Moment.js can fix this for us; unfortunately, it requires an
incompatible change to the message (Moment.js already adds the “ago”, so
we can’t have it in the message), so the message key is changed and we
lose all existing translations.

Change-Id: I08fd2133a1cd772e844fa4b73c5a9673662f6945
---
M i18n/en.json
M i18n/qqq.json
M wikibase/queryService/ui/App.js
3 files changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/01/402401/1

diff --git a/i18n/en.json b/i18n/en.json
index 9c2679a..c82a4ed 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -35,7 +35,7 @@
 "wdqs-app-help-copy": "Licensing information",
 "wdqs-app-help-queryhelper": "Query Helper",
 "wdqs-app-footer-help": "Press [CTRL-SPACE] to activate auto 
completion.",
-"wdqs-app-footer-updated": "Data updated $1 ago",
+"wdqs-app-footer-updated-ago": "Data updated $1",
 "wdqs-app-result-shorturl": "Short URL to result",
 "wdqs-app-result-shorturl-title": "Short URL to this result",
 "wdqs-app-result-rawgraphs": "Open in RAWGraphs.io",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 63ab7ba..89f9246 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -37,7 +37,7 @@
"wdqs-app-help-copy": "Link to page with licensing information",
"wdqs-app-help-queryhelper": "Heading of the Query Helper widget",
"wdqs-app-footer-help": "Help message at the footer of the editor",
-   "wdqs-app-footer-updated": "Message displaying how long ago data was 
updated",
+   "wdqs-app-footer-updated-ago": "Message displaying how long ago data 
was updated. $1 contains the time period, including a suffix indicating that 
the period is in the past, e.g. “a few seconds ago” or “two minutes 
ago”.",
"wdqs-app-result-shorturl": "Link message in the footer link dropdown",
"wdqs-app-result-shorturl-title": "Title of link message in the footer 
link dropdown",
"wdqs-app-result-rawgraphs": "Link message in the footer link dropdown",
diff --git a/wikibase/queryService/ui/App.js b/wikibase/queryService/ui/App.js
index 6f60eb4..6a7dcb8 100644
--- a/wikibase/queryService/ui/App.js
+++ b/wikibase/queryService/ui/App.js
@@ -447,7 +447,7 @@
 
var e = $( this );
self._sparqlApi.queryDataUpdatedTime().done( function( 
time, difference ) {
-   var text = moment.duration( difference, 
'seconds' ).humanize(),
+   var text = moment.duration( -difference, 
'seconds' ).humanize( true ),
title = time,
badge = '' + text + 
'';
 
@@ -456,7 +456,7 @@
html: true,
trigger: 'hover',
placement: 'top',
-   content: $.i18n( 
'wdqs-app-footer-updated', badge )
+   content: $.i18n( 
'wdqs-app-footer-updated-ago', badge )
} );
} ).fail( function() {
e.popover( {

-- 
To view, visit https://gerrit.wikimedia.org/r/402401
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I08fd2133a1cd772e844fa4b73c5a9673662f6945
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] wikidata...gui[master]: Remove unused wdqs-app-footer-updated-seconds message

2018-01-05 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402400 )

Change subject: Remove unused wdqs-app-footer-updated-seconds message
..

Remove unused wdqs-app-footer-updated-seconds message

The message has been unused since commit 39ce7595f5 (change I9fd9a760a8)
replaced it with the more generic wdqs-app-footer-updated message.

Change-Id: Ifec1d8d24ea796564e47b87e975ae38c7ec53e66
---
M i18n/en.json
M i18n/qqq.json
2 files changed, 0 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/00/402400/1

diff --git a/i18n/en.json b/i18n/en.json
index b0eebff..9c2679a 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -36,7 +36,6 @@
 "wdqs-app-help-queryhelper": "Query Helper",
 "wdqs-app-footer-help": "Press [CTRL-SPACE] to activate auto 
completion.",
 "wdqs-app-footer-updated": "Data updated $1 ago",
-"wdqs-app-footer-updated-seconds": "Data updated $1 seconds ago",
 "wdqs-app-result-shorturl": "Short URL to result",
 "wdqs-app-result-shorturl-title": "Short URL to this result",
 "wdqs-app-result-rawgraphs": "Open in RAWGraphs.io",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 56247e2..63ab7ba 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -38,7 +38,6 @@
"wdqs-app-help-queryhelper": "Heading of the Query Helper widget",
"wdqs-app-footer-help": "Help message at the footer of the editor",
"wdqs-app-footer-updated": "Message displaying how long ago data was 
updated",
-   "wdqs-app-footer-updated-seconds": "Message displaying how many seconds 
ago data was updated",
"wdqs-app-result-shorturl": "Link message in the footer link dropdown",
"wdqs-app-result-shorturl-title": "Title of link message in the footer 
link dropdown",
"wdqs-app-result-rawgraphs": "Link message in the footer link dropdown",

-- 
To view, visit https://gerrit.wikimedia.org/r/402400
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifec1d8d24ea796564e47b87e975ae38c7ec53e66
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Make constraint report border flush with help link

2018-01-05 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402360 )

Change subject: Make constraint report border flush with help link
..

Make constraint report border flush with help link

Several refactorings in ConstraintReportPanel. The main visible effect
is that the border between constraint report panels (added by the
gadget’s style sheet) is now flush on the right side with the “help”
text, since the margin is on the whole panel (including the border)
instead of only on the help text.

In preparation for I5814ef1866, the help link is also wrapped inside a
container, and it’s this whole container which floats to the right (and
has a margin, etc.), not just the individual help link.

And finally, the heading gains a class, instead of being identified in
the style sheet as “the first heading inside the panel”.

Bug: T164351
Change-Id: I548b6072191fc5a06bff06858026062047d7a004
---
M modules/ui/ConstraintReportPanel.js
M modules/ui/ConstraintReportPanel.less
2 files changed, 22 insertions(+), 18 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/60/402360/1

diff --git a/modules/ui/ConstraintReportPanel.js 
b/modules/ui/ConstraintReportPanel.js
index 0289eb7..142d799 100644
--- a/modules/ui/ConstraintReportPanel.js
+++ b/modules/ui/ConstraintReportPanel.js
@@ -27,7 +27,8 @@
 * @cfg {Object} constraint The constraint of the report, as returned 
by the wbcheckconstraints API.
 * @cfg {string} [message=''] The message (HTML) of the report, if 
present.
 * @cfg {string[]} [ancillaryMessages=[]] Additional messages (HTML) 
attached to the report, if any.
-* @cfg {jQuery} [$heading] The heading element of the panel. Should 
not contain the help link.
+* @cfg {jQuery} [$heading] The heading element of the panel. Should 
not yet contain the heading links.
+* @cfg {jQuery} [$headingLinks] The container for the links in the 
heading of the panel. Should not yet contain the help link.
 * @cfg {jQuery} [$helpLink] The help link for the heading.
 * @cfg {jQuery} [$message] The message paragraph of the panel.
 * @cfg {jQuery} [$ancillaryMessages] The container of the additional 
messages.
@@ -49,19 +50,18 @@
// Properties
this.status = config.status;
this.constraint = config.constraint;
-   this.$heading = config.$heading || $( '' ).append(
+   this.$heading = config.$heading || $( '' ).append(
$( '' )
.text( this.constraint.typeLabel )
.attr( 'href', this.constraint.link )
.attr( 'target', '_blank' )
);
-   this.$helpLink = config.$helpLink || $( '' ).append(
-   $( '' )
-   .text( mw.message( 
'wbqc-constrainttypehelp-short' ).text() )
-   .attr( 'title', mw.message( 
'wbqc-constrainttypehelp-long' ).text() )
-   .attr( 'href', 
'https://www.wikidata.org/wiki/Help:Property_constraints_portal/' + 
this.constraint.type )
-   .attr( 'target', '_blank' )
-   );
+   this.$headingLinks = config.$headingLinks || $( '' );
+   this.$helpLink = config.$helpLink || $( '' )
+   .text( mw.message( 'wbqc-constrainttypehelp-short' 
).text() )
+   .attr( 'title', mw.message( 
'wbqc-constrainttypehelp-long' ).text() )
+   .attr( 'href', 
'https://www.wikidata.org/wiki/Help:Property_constraints_portal/' + 
this.constraint.type )
+   .attr( 'target', '_blank' );
this.message = config.message;
this.$message = config.$message || $( '' ).html( 
this.message );
this.ancillaryMessages = config.ancillaryMessages;
@@ -78,7 +78,8 @@
this.$element
.addClass( 'wbqc-report' )
.addClass( 'wbqc-report-status-' + this.status );
-   this.$heading.append( this.$helpLink );
+   this.$headingLinks.append( this.$helpLink );
+   this.$heading.append( this.$headingLinks );
this.$element.append( this.$heading );
this.$element.append( this.$message );
this.$element.append( this.$ancillaryMessages );
diff --git a/modules/ui/ConstraintReportPanel.less 
b/modules/ui/ConstraintReportPanel.less
index 78da6d9..b9b936d 100644
--- a/modules/ui/ConstraintReportPanel.less
+++ b/modules/ui/ConstraintReportPanel.less
@@ -1,15 +1,18 @@
 @import 'mediawiki.ui/variables';
 
 .wbqc-report {
-   h4:first-child + p {
-   margin-top: 0;
-   }
+   

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add support for parsing constraint scope parameter

2018-01-04 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402099 )

Change subject: Add support for parsing constraint scope parameter
..

Add support for parsing constraint scope parameter

This constraint parameter holds one of three possible values, indicating
that a constraint should be checked on the main snak, qualifiers, and/or
references. The three values (items) are translated to context types and
returned in an array.

Bug: T184202
Change-Id: I34111535994dd7cfc8d564fdb9f37662c3aa876e
---
M extension.json
M src/ConstraintCheck/Helper/ConstraintParameterParser.php
M tests/phpunit/Helper/ConstraintParameterParserTest.php
3 files changed, 131 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/99/402099/1

diff --git a/extension.json b/extension.json
index 7be24ea..887c600 100644
--- a/extension.json
+++ b/extension.json
@@ -375,6 +375,26 @@
"description": "The property ID of the 'syntax 
clarification' property (data type: monolingual text), which specifies 
human-readable explanations of a 'format' constraint.",
"public": true
},
+   "WBQualityConstraintsConstraintScopeId": {
+   "value": "P4680",
+   "description": "The property ID of the 'constraint 
scope' property (data type: item), which specifies the context(s) in which a 
constraint is checked.",
+   "public": true
+   },
+   "WBQualityConstraintsConstraintCheckedOnMainValueId": {
+   "value": "Q46466787",
+   "description": "The item ID of the 'constraint checked 
on main value' item, which, when used in a 'constraint scope' qualifier of a 
'property constraint' statement on a property, indicates that the constraint 
should be checked on the main snak of a statement.",
+   "public": true
+   },
+   "WBQualityConstraintsConstraintCheckedOnQualifiersId": {
+   "value": "Q46466783",
+   "description": "The item ID of the 'constraint checked 
on qualifiers' item, which, when used in a 'constraint scope' qualifier of a 
'property constraint' statement on a property, indicates that the constraint 
should be checked on the qualifier snaks of a statement.",
+   "public": true
+   },
+   "WBQualityConstraintsConstraintCheckedOnReferencesId": {
+   "value": "Q46466805",
+   "description": "The item ID of the 'constraint checked 
on references' item, which, when used in a 'constraint scope' qualifier of a 
'property constraint' statement on a property, indicates that the constraint 
should be checked on the reference snaks of a statement.",
+   "public": true
+   },
"WBQualityConstraintsPropertiesWithViolatingQualifiers": {
"value": [],
"description": "Property IDs of statements whose 
qualifiers are expected to violate constraints, and where constraints checks 
are therefore skipped, as if the subject entity was an exception to the 
constraints defined on the qualifier properties.",
diff --git a/src/ConstraintCheck/Helper/ConstraintParameterParser.php 
b/src/ConstraintCheck/Helper/ConstraintParameterParser.php
index 2177456..2926c1c 100644
--- a/src/ConstraintCheck/Helper/ConstraintParameterParser.php
+++ b/src/ConstraintCheck/Helper/ConstraintParameterParser.php
@@ -18,6 +18,7 @@
 use Wikibase\DataModel\Snak\PropertyValueSnak;
 use Wikibase\DataModel\Snak\Snak;
 use Wikibase\Repo\Parsers\TimeParserFactory;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Context\Context;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\ItemIdSnakValue;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
 use WikibaseQuality\ConstraintReport\Role;
@@ -667,4 +668,57 @@
return null;
}
 
+   /**
+* @param array $constraintParameters see {@link 
\WikibaseQuality\Constraint::getConstraintParameters()}
+* @throws ConstraintParameterException if the parameter is invalid
+* @return string[]|null Context::TYPE_* constants
+*/
+   public function parseConstraintScopeParameter( array 
$constraintParameters ) {
+   $constraintScopeId = $this->config->get( 
'WBQualityConstraintsConstraintScopeId' );
+   $mainSnakId = $this->config->get( 
'WBQualityConstraintsConstraintCheckedOnMainValueId' );
+   $qualifiersId = $this->config->get( 
'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
+   $referencesId = $this->config->get( 
'WBQualityConstraintsConstraintCheckedOnReferencesId' );
+
+

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Improve ConstraintParameterParserTest function names

2018-01-04 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402098 )

Change subject: Improve ConstraintParameterParserTest function names
..

Improve ConstraintParameterParserTest function names

The pattern of all the test functions here is “test”, then the name of
the function under test (“parse*Parameter”), and then optionally some
kind of qualifying detail. To improve readability of these names, add
underscores between the name of the tested function and the details, and
within some of the details as well.

Change-Id: I2a74c79265fae1286a5e7f2eee2108e6d59e4cf2
---
M tests/phpunit/Helper/ConstraintParameterParserTest.php
1 file changed, 52 insertions(+), 52 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/98/402098/1

diff --git a/tests/phpunit/Helper/ConstraintParameterParserTest.php 
b/tests/phpunit/Helper/ConstraintParameterParserTest.php
index 42bd87a..1d783c0 100644
--- a/tests/phpunit/Helper/ConstraintParameterParserTest.php
+++ b/tests/phpunit/Helper/ConstraintParameterParserTest.php
@@ -107,7 +107,7 @@
$this->assertEquals( [ 'Q100', 'Q101' ], $parsed );
}
 
-   public function testParseClassParameterMissing() {
+   public function testParseClassParameter_Missing() {
$this->assertThrowsConstraintParameterException(
'parseClassParameter',
[ [], 'constraint' ],
@@ -115,7 +115,7 @@
);
}
 
-   public function testParseClassParameterNoValue() {
+   public function testParseClassParameter_NoValue() {
$config = $this->getDefaultConfig();
$classId = $config->get( 'WBQualityConstraintsClassId' );
$this->assertThrowsConstraintParameterException(
@@ -132,7 +132,7 @@
);
}
 
-   public function testParseClassParameterStringValue() {
+   public function testParseClassParameter_StringValue() {
$config = $this->getDefaultConfig();
$classId = $config->get( 'WBQualityConstraintsClassId' );
$this->assertThrowsConstraintParameterException(
@@ -163,7 +163,7 @@
$this->assertEquals( 'instance', $parsed );
}
 
-   public function testParseRelationParameterMissing() {
+   public function testParseRelationParameter_Missing() {
$this->assertThrowsConstraintParameterException(
'parseRelationParameter',
[ [], 'constraint' ],
@@ -171,7 +171,7 @@
);
}
 
-   public function testParseRelationParameterNoValue() {
+   public function testParseRelationParameter_NoValue() {
$config = $this->getDefaultConfig();
$relationId = $config->get( 'WBQualityConstraintsRelationId' );
$this->assertThrowsConstraintParameterException(
@@ -188,7 +188,7 @@
);
}
 
-   public function testParseRelationParameterStringValue() {
+   public function testParseRelationParameter_StringValue() {
$config = $this->getDefaultConfig();
$relationId = $config->get( 'WBQualityConstraintsRelationId' );
$this->assertThrowsConstraintParameterException(
@@ -208,7 +208,7 @@
);
}
 
-   public function testParseRelationParameterMultiValue() {
+   public function testParseRelationParameter_MultiValue() {
$config = $this->getDefaultConfig();
$relationId = $config->get( 'WBQualityConstraintsRelationId' );
$instanceOfId = $config->get( 
'WBQualityConstraintsInstanceOfRelationId' );
@@ -228,7 +228,7 @@
);
}
 
-   public function testParseRelationParameterWrongValue() {
+   public function testParseRelationParameter_WrongValue() {
$config = $this->getDefaultConfig();
$relationId = $config->get( 'WBQualityConstraintsRelationId' );
$this->assertThrowsConstraintParameterException(
@@ -253,7 +253,7 @@
$this->assertEquals( new PropertyId( 'P100' ), $parsed );
}
 
-   public function testParsePropertyParameterMissing() {
+   public function testParsePropertyParameter_Missing() {
$this->assertThrowsConstraintParameterException(
'parsePropertyParameter',
[ [], 'constraint' ],
@@ -261,7 +261,7 @@
);
}
 
-   public function testParsePropertyParameterNoValue() {
+   public function testParsePropertyParameter_NoValue() {
$config = $this->getDefaultConfig();
$propertyId = $config->get( 'WBQualityConstraintsPropertyId' );
$this->assertThrowsConstraintParameterException(
@@ -278,7 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Inject StatsdDataFactory everywhere

2018-01-04 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402038 )

Change subject: Inject StatsdDataFactory everywhere
..

Inject StatsdDataFactory everywhere

Instead of using the default MediaWikiServices’ statsd data factory
wherever we need one, inject it properly. In the tests, we can use
NullStatsdFactory instead of the real implementation.

Change-Id: I68ad243ae79d642850a52a3c7df4ceca837c8068
---
M src/Api/CheckConstraintParameters.php
M src/Api/CheckConstraints.php
M src/ConstraintCheck/Helper/SparqlHelper.php
M src/ConstraintCheck/Helper/TypeCheckerHelper.php
M src/ConstraintReportFactory.php
M src/Specials/SpecialConstraintReport.php
M tests/phpunit/Api/CheckConstraintParametersTest.php
M tests/phpunit/Api/CheckConstraintsTest.php
M tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
M tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php
M tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
M tests/phpunit/DelegatingConstraintCheckerTest.php
M tests/phpunit/Helper/SparqlHelperTest.php
M tests/phpunit/Specials/SpecialConstraintReportTest.php
14 files changed, 130 insertions(+), 42 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/38/402038/1

diff --git a/src/Api/CheckConstraintParameters.php 
b/src/Api/CheckConstraintParameters.php
index 6bdf4e8..46d2eb4 100644
--- a/src/Api/CheckConstraintParameters.php
+++ b/src/Api/CheckConstraintParameters.php
@@ -5,6 +5,7 @@
 use ApiBase;
 use ApiMain;
 use ApiResult;
+use IBufferingStatsdDataFactory;
 use InvalidArgumentException;
 use MediaWiki\MediaWikiServices;
 use RequestContext;
@@ -51,6 +52,11 @@
private $statementGuidParser;
 
/**
+* @var IBufferingStatsdDataFactory
+*/
+   private $dataFactory;
+
+   /**
 * Creates new instance from global state.
 *
 * @param ApiMain $main
@@ -69,7 +75,8 @@
$prefix,
$helperFactory,
$constraintReportFactory->getConstraintChecker(),
-   $repo->getStatementGuidParser()
+   $repo->getStatementGuidParser(),
+   MediaWikiServices::getInstance()->getStatsdDataFactory()
);
}
 
@@ -80,6 +87,7 @@
 * @param ApiHelperFactory $apiHelperFactory
 * @param DelegatingConstraintChecker $delegatingConstraintChecker
 * @param StatementGuidParser $statementGuidParser
+* @param IBufferingStatsdDataFactory $dataFactory
 */
public function __construct(
ApiMain $main,
@@ -87,18 +95,21 @@
$prefix,
ApiHelperFactory $apiHelperFactory,
DelegatingConstraintChecker $delegatingConstraintChecker,
-   StatementGuidParser $statementGuidParser
+   StatementGuidParser $statementGuidParser,
+   IBufferingStatsdDataFactory $dataFactory
) {
parent::__construct( $main, $name, $prefix );
 
$this->apiErrorReporter = $apiHelperFactory->getErrorReporter( 
$this );
$this->delegatingConstraintChecker = 
$delegatingConstraintChecker;
$this->statementGuidParser = $statementGuidParser;
+   $this->dataFactory = $dataFactory;
}
 
public function execute() {
-   MediaWikiServices::getInstance()->getStatsdDataFactory()
-   ->increment( 
'wikibase.quality.constraints.api.checkConstraintParameters.execute' );
+   $this->dataFactory->increment(
+   
'wikibase.quality.constraints.api.checkConstraintParameters.execute'
+   );
 
$params = $this->extractRequestParams();
$result = $this->getResult();
diff --git a/src/Api/CheckConstraints.php b/src/Api/CheckConstraints.php
index c7aa9cb..2c7010d 100644
--- a/src/Api/CheckConstraints.php
+++ b/src/Api/CheckConstraints.php
@@ -4,6 +4,7 @@
 
 use ApiBase;
 use ApiMain;
+use IBufferingStatsdDataFactory;
 use MediaWiki\MediaWikiServices;
 use RequestContext;
 use ValueFormatters\FormatterOptions;
@@ -58,6 +59,11 @@
private $resultsBuilder;
 
/**
+* @var IBufferingStatsdDataFactory
+*/
+   private $dataFactory;
+
+   /**
 * Creates new instance from global state.
 *
 * @param ApiMain $main
@@ -85,6 +91,7 @@
$config = MediaWikiServices::getInstance()->getMainConfig();
$titleParser = 
MediaWikiServices::getInstance()->getTitleParser();
$unitConverter = $repo->getUnitConverter();
+   $dataFactory = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
$constraintReportFactory = new ConstraintReportFactory(

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Track cache hit/miss counts per-entity

2018-01-03 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401772 )

Change subject: Track cache hit/miss counts per-entity
..

Track cache hit/miss counts per-entity

Increment counters for how many per-entity results we got from the
cache, and how many we didn’t get.

Per-statement results are ignored, since we don’t cache results per
statement. This means that we might increment the counter by zero if
constraint checks for only statement IDs are requested – I verified
manually that statsd is okay with such a non-increment.

Bug: T184062
Change-Id: I6375603af2f865cc2e881fec91df0488173f5528
---
M src/Api/CachingResultsBuilder.php
1 file changed, 16 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/72/401772/1

diff --git a/src/Api/CachingResultsBuilder.php 
b/src/Api/CachingResultsBuilder.php
index 185832a..ca6bb20 100644
--- a/src/Api/CachingResultsBuilder.php
+++ b/src/Api/CachingResultsBuilder.php
@@ -2,6 +2,8 @@
 
 namespace WikibaseQuality\ConstraintReport\Api;
 
+use IBufferingStatsdDataFactory;
+use MediaWiki\MediaWikiServices;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\EntityIdParser;
 use Wikibase\Lib\Store\EntityRevisionLookup;
@@ -64,6 +66,11 @@
private $possiblyStaleConstraintTypes;
 
/**
+* @var IBufferingStatsdDataFactory
+*/
+   private $dataFactory;
+
+   /**
 * @var callable
 */
private $microtime = 'microtime';
@@ -91,6 +98,8 @@
$this->entityIdParser = $entityIdParser;
$this->ttlInSeconds = $ttlInSeconds;
$this->possiblyStaleConstraintTypes = 
$possiblyStaleConstraintTypes;
+
+   $this->dataFactory = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
}
 
/**
@@ -111,6 +120,9 @@
foreach ( $entityIds as $entityId ) {
$storedResults = $this->getStoredResults( 
$entityId );
if ( $storedResults !== null ) {
+   $this->dataFactory->increment(
+   
'wikibase.quality.constraints.cache.entity.hit'
+   );
$results += $storedResults->getArray();
$metadatas[] = 
$storedResults->getMetadata();
$storedEntityIds[] = $entityId;
@@ -119,6 +131,10 @@
$entityIds = array_values( array_diff( $entityIds, 
$storedEntityIds ) );
}
if ( $entityIds !== [] || $claimIds !== [] ) {
+   $this->dataFactory->updateCount(
+   
'wikibase.quality.constraints.cache.entity.miss',
+   count( $entityIds )
+   );
$response = $this->getAndStoreResults( $entityIds, 
$claimIds, $constraintIds );
$results += $response->getArray();
$metadatas[] = $response->getMetadata();

-- 
To view, visit https://gerrit.wikimedia.org/r/401772
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6375603af2f865cc2e881fec91df0488173f5528
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Get revision IDs in bulk

2018-01-03 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401752 )

Change subject: Get revision IDs in bulk
..

Get revision IDs in bulk

Use a WikiPageEntityMetaDataAccessor instead of an EntityRevisionLookup
in order to load the latest revision of several entities at once.

Bug: T182994
Change-Id: I7fb38cf3bbcd8589d5a4ef9b45f1d1daf63df001
---
M src/Api/CachingResultsBuilder.php
M src/Api/CheckConstraints.php
M tests/phpunit/Api/CachingResultsBuilderTest.php
3 files changed, 67 insertions(+), 53 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/52/401752/1

diff --git a/src/Api/CachingResultsBuilder.php 
b/src/Api/CachingResultsBuilder.php
index 185832a..89772e9 100644
--- a/src/Api/CachingResultsBuilder.php
+++ b/src/Api/CachingResultsBuilder.php
@@ -5,6 +5,7 @@
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\EntityIdParser;
 use Wikibase\Lib\Store\EntityRevisionLookup;
+use Wikibase\Lib\Store\Sql\WikiPageEntityMetaDataAccessor;
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Cache\CachedCheckConstraintsResponse;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Cache\CachingMetadata;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Cache\DependencyMetadata;
@@ -44,9 +45,9 @@
private $cache;
 
/**
-* @var EntityRevisionLookup
+* @var WikiPageEntityMetaDataAccessor
 */
-   private $entityRevisionLookup;
+   private $wikiPageEntityMetaDataAccessor;
 
/**
 * @var EntityIdParser
@@ -71,7 +72,7 @@
/**
 * @param ResultsBuilder $resultsBuilder The ResultsBuilder that cache 
misses are delegated to.
 * @param ResultsCache $cache The cache where results can be stored.
-* @param EntityRevisionLookup $entityRevisionLookup Used to get the 
latest revision ID.
+* @param WikiPageEntityMetaDataAccessor 
$wikiPageEntityMetaDataAccessor Used to get the latest revision ID.
 * @param EntityIdParser $entityIdParser Used to parse entity IDs in 
cached objects.
 * @param int $ttlInSeconds Time-to-live of the cached values, in 
seconds.
 * @param string[] $possiblyStaleConstraintTypes item IDs of constraint 
types
@@ -80,14 +81,14 @@
public function __construct(
ResultsBuilder $resultsBuilder,
ResultsCache $cache,
-   EntityRevisionLookup $entityRevisionLookup,
+   WikiPageEntityMetaDataAccessor $wikiPageEntityMetaDataAccessor,
EntityIdParser $entityIdParser,
$ttlInSeconds,
array $possiblyStaleConstraintTypes
) {
$this->resultsBuilder = $resultsBuilder;
$this->cache = $cache;
-   $this->entityRevisionLookup = $entityRevisionLookup;
+   $this->wikiPageEntityMetaDataAccessor = 
$wikiPageEntityMetaDataAccessor;
$this->entityIdParser = $entityIdParser;
$this->ttlInSeconds = $ttlInSeconds;
$this->possiblyStaleConstraintTypes = 
$possiblyStaleConstraintTypes;
@@ -249,11 +250,13 @@
 * @return int[]
 */
private function getLatestRevisionIds( array $entityIds ) {
+   $revisionInformations = 
$this->wikiPageEntityMetaDataAccessor->loadRevisionInformation(
+   $entityIds,
+   EntityRevisionLookup::LATEST_FROM_REPLICA_WITH_FALLBACK
+   );
$latestRevisionIds = [];
-   foreach ( $entityIds as $entityId ) {
-   $serialization = $entityId->getSerialization();
-   $latestRevisionId = 
$this->entityRevisionLookup->getLatestRevisionId( $entityId );
-   $latestRevisionIds[$serialization] = $latestRevisionId;
+   foreach ( $revisionInformations as $serialization => 
$revisionInformation ) {
+   $latestRevisionIds[$serialization] = 
$revisionInformation->page_latest;
}
return $latestRevisionIds;
}
diff --git a/src/Api/CheckConstraints.php b/src/Api/CheckConstraints.php
index c7aa9cb..2ac5ad5 100644
--- a/src/Api/CheckConstraints.php
+++ b/src/Api/CheckConstraints.php
@@ -11,6 +11,7 @@
 use Wikibase\DataModel\Entity\EntityIdParsingException;
 use Wikibase\DataModel\Services\Statement\StatementGuidValidator;
 use Wikibase\Lib\SnakFormatter;
+use Wikibase\Lib\Store\Sql\WikiPageEntityMetaDataLookup;
 use Wikibase\Repo\Api\ApiErrorReporter;
 use Wikibase\Repo\Api\ApiHelperFactory;
 use Wikibase\Repo\Api\ResultBuilder;
@@ -110,12 +111,15 @@
$config
);
if ( $config->get( 
'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
+   $wikiPageEntityMetaDataAccessor = new 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Improve type safety in parseItemIdParameter()

2018-01-03 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401731 )

Change subject: Improve type safety in parseItemIdParameter()
..

Improve type safety in parseItemIdParameter()

Instead of calling getters multiple times, assign the returned values to
variables, so that we know they’re the same values (and therefore have
the same types).

The pattern is inspired by the Ceylon programming language, where I
would write something like this:

if (is EntityIdValue dataValue = snak.dataValue,
is ItemId itemId = dataValue.entityId) {
return ItemIdSnakValue.ofItemId(itemId);
} else {
throw ConstraintParameterException {
message = ...;
};
}

Change-Id: I027a2ad16a74c8b786acaa5abcad83b8e95a3678
---
M src/ConstraintCheck/Helper/ConstraintParameterParser.php
1 file changed, 5 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/31/401731/1

diff --git a/src/ConstraintCheck/Helper/ConstraintParameterParser.php 
b/src/ConstraintCheck/Helper/ConstraintParameterParser.php
index 2177456..d90d3c8 100644
--- a/src/ConstraintCheck/Helper/ConstraintParameterParser.php
+++ b/src/ConstraintCheck/Helper/ConstraintParameterParser.php
@@ -259,16 +259,17 @@
}
 
private function parseItemIdParameter( PropertyValueSnak $snak, 
$parameterId ) {
-   if ( $snak->getDataValue() instanceof EntityIdValue &&
-   $snak->getDataValue()->getEntityId() instanceof ItemId
+   if (
+   ( $dataValue = $snak->getDataValue() ) instanceof 
EntityIdValue &&
+   ( $itemId = $dataValue->getEntityId() ) instanceof 
ItemId
) {
-   return ItemIdSnakValue::fromItemId( 
$snak->getDataValue()->getEntityId() );
+   return ItemIdSnakValue::fromItemId( $itemId );
} else {
throw new ConstraintParameterException(
wfMessage( 
'wbqc-violation-message-parameter-item' )
->rawParams(

$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ),
-   
$this->constraintParameterRenderer->formatDataValue( $snak->getDataValue(), 
Role::CONSTRAINT_PARAMETER_VALUE )
+   
$this->constraintParameterRenderer->formatDataValue( $dataValue, 
Role::CONSTRAINT_PARAMETER_VALUE )
)
->escaped()
);

-- 
To view, visit https://gerrit.wikimedia.org/r/401731
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I027a2ad16a74c8b786acaa5abcad83b8e95a3678
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Catch ConstraintParameterException in SparqlHelper

2018-01-03 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401724 )

Change subject: Catch ConstraintParameterException in SparqlHelper
..

Catch ConstraintParameterException in SparqlHelper

When an invalid regex is detected, matchesRegularExpressionWithSparql
throws a ConstraintParameterException. matchesRegularExpression needs to
catch this exception in the caching callback, and store the relevant
part (the message) so we can reconstruct the exception from the cached
value.

Bug: T183992
Change-Id: I1671255279f82acdcdeb42050f0e2332c635718f
---
M src/ConstraintCheck/Helper/SparqlHelper.php
1 file changed, 30 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/24/401724/1

diff --git a/src/ConstraintCheck/Helper/SparqlHelper.php 
b/src/ConstraintCheck/Helper/SparqlHelper.php
index 175318d..85c5acd 100644
--- a/src/ConstraintCheck/Helper/SparqlHelper.php
+++ b/src/ConstraintCheck/Helper/SparqlHelper.php
@@ -9,6 +9,7 @@
 use InvalidArgumentException;
 use MapCacheLRU;
 use MediaWiki\MediaWikiServices;
+use MWException;
 use MWHttpRequest;
 use WANObjectCache;
 use Wikibase\DataModel\Entity\EntityId;
@@ -361,15 +362,16 @@
// caching wrapper around matchesRegularExpressionWithSparql
 
$textHash = hash( 'sha256', $text );
+   $cacheKey = $this->cache->makeKey(
+   'WikibaseQualityConstraints', // extension
+   'regex', // action
+   'WDQS-Java', // regex flavor
+   hash( 'sha256', $regex )
+   );
$cacheMapSize = $this->config->get( 
'WBQualityConstraintsFormatCacheMapSize' );
 
$cacheMapArray = $this->cache->getWithSetCallback(
-   $this->cache->makeKey(
-   'WikibaseQualityConstraints', // extension
-   'regex', // action
-   'WDQS-Java', // regex flavor
-   hash( 'sha256', $regex )
-   ),
+   $cacheKey,
WANObjectCache::TTL_DAY,
function( $cacheMapArray ) use ( $text, $regex, 
$textHash, $cacheMapSize ) {
// Initialize the cache map if not set
@@ -389,9 +391,17 @@
} else {
$key = 
'wikibase.quality.constraints.regex.cache.refresh.miss';
$this->dataFactory->increment( $key );
+   try {
+   $matches = 
$this->matchesRegularExpressionWithSparql( $text, $regex );
+   } catch ( ConstraintParameterException 
$e ) {
+   $matches = $e->getMessage();
+   } catch ( SparqlHelperException $e ) {
+   // don’t cache this
+   return $cacheMap->toArray();
+   }
$cacheMap->set(
$textHash,
-   
$this->matchesRegularExpressionWithSparql( $text, $regex ),
+   $matches,
3 / 8
);
}
@@ -412,7 +422,19 @@
if ( isset( $cacheMapArray[$textHash] ) ) {
$key = 'wikibase.quality.constraints.regex.cache.hit';
$this->dataFactory->increment( $key );
-   return $cacheMapArray[$textHash];
+   $matches = $cacheMapArray[$textHash];
+   if ( is_bool( $matches ) ) {
+   return $matches;
+   } elseif ( is_string( $matches ) ) {
+   throw new ConstraintParameterException( 
$matches );
+   } else {
+   throw new MWException(
+   'Value of unknown type in object cache 
(' .
+   'cache key: ' . $cacheKey . ', ' .
+   'cache map key: ' . $textHash . ', ' .
+   'value type: ' . gettype( $matches ) . 
')'
+   );
+   }
} else {
$key = 'wikibase.quality.constraints.regex.cache.miss';
$this->dataFactory->increment( $key );

-- 
To view, visit 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Remove stray @package tag

2018-01-02 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401570 )

Change subject: Remove stray @package tag
..

Remove stray @package tag

This file was added in commit a4c1832358 (change I60ad838dda), which was
authored before commit 0d5c5e7156 (change Ib0a0cb771d) (which removed
redundant @package tags) but merged after it, so the @package tag was
accidentally left in the repository. Let’s get rid of it.

Change-Id: I1a711148adf887ca370185d886a31b097bb54e0d
---
M src/ConstraintCheck/Result/NullResult.php
1 file changed, 0 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/70/401570/1

diff --git a/src/ConstraintCheck/Result/NullResult.php 
b/src/ConstraintCheck/Result/NullResult.php
index d0e0804..91c0488 100644
--- a/src/ConstraintCheck/Result/NullResult.php
+++ b/src/ConstraintCheck/Result/NullResult.php
@@ -12,7 +12,6 @@
  * Used for contexts that should appear in the API output
  * even if no constraints are defined for them.
  *
- * @package WikibaseQuality\ConstraintReport\ConstraintCheck\Result
  * @author Lucas Werkmeister
  * @license GNU GPL v2+
  */

-- 
To view, visit https://gerrit.wikimedia.org/r/401570
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a711148adf887ca370185d886a31b097bb54e0d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Remove @uses from README.md

2018-01-02 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401568 )

Change subject: Remove @uses from README.md
..

Remove @uses from README.md

Following commit 74034e2555 (change I11ba079a7f), we should no longer
recommend adding @uses on new tests.

Bug: T173409
Change-Id: I639b8c6466649de0563baca6c0cdd5fe2b19855b
---
M README.md
1 file changed, 0 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/68/401568/1

diff --git a/README.md b/README.md
index c0c3fa6..c604cee 100644
--- a/README.md
+++ b/README.md
@@ -214,8 +214,6 @@
  *
  * @group WikibaseQualityConstraints
  *
- * @uses 
\WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult
- *
  * @author YOUR NAME HERE
  * @license GNU GPL v2+
  */

-- 
To view, visit https://gerrit.wikimedia.org/r/401568
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I639b8c6466649de0563baca6c0cdd5fe2b19855b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] wikidata...gui[master]: DNM: break tests

2018-01-02 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401534 )

Change subject: DNM: break tests
..

DNM: break tests

This change breaks several tests, and CI should not pass on it.

Bug: T183831
Change-Id: I2a1c561e1e9fec9def97e3b475bd1302e717f8b3
---
M wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
1 file changed, 3 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/34/401534/1

diff --git a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js 
b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
index 64b6575..bc7305c 100644
--- a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
+++ b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
@@ -518,6 +518,9 @@
 */
SELF.prototype._extractGeoJsonWktLiteral = function( literal ) {
var split = this._splitWktLiteral( literal );
+   if ( true === true ) {
+   return null;
+   }
if ( !split ) {
return null;
}

-- 
To view, visit https://gerrit.wikimedia.org/r/401534
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2a1c561e1e9fec9def97e3b475bd1302e717f8b3
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Update comments on string validators

2017-12-26 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/400238 )

Change subject: Update comments on string validators
..

Update comments on string validators

It appears the regex has been updated several times since the comment
was written. Hopefully this is more correct.

Change-Id: I1dc87a8c71c23a0ae9da80a27cc1b50c16c04147
---
M repo/includes/ValidatorBuilders.php
M repo/includes/Validators/TermValidatorFactory.php
2 files changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/38/400238/1

diff --git a/repo/includes/ValidatorBuilders.php 
b/repo/includes/ValidatorBuilders.php
index d52a513..567a1d5 100644
--- a/repo/includes/ValidatorBuilders.php
+++ b/repo/includes/ValidatorBuilders.php
@@ -184,7 +184,7 @@
$validators[] = new TypeValidator( 'string' );
//TODO: validate UTF8 (here and elsewhere)
$validators[] = new StringLengthValidator( 1, $maxLength, 
'mb_strlen' );
-   $validators[] = new RegexValidator( '/^\s|[\v\t]|\s$/u', true 
); // no leading/trailing whitespace, no line breaks.
+   $validators[] = new RegexValidator( '/^\s|[\v\t]|\s$/u', true 
); // no leading/trailing whitespace, no tab or vertical whitespace, no line 
breaks.
 
return $validators;
}
diff --git a/repo/includes/Validators/TermValidatorFactory.php 
b/repo/includes/Validators/TermValidatorFactory.php
index 6fd3bf3..24fbe32 100644
--- a/repo/includes/Validators/TermValidatorFactory.php
+++ b/repo/includes/Validators/TermValidatorFactory.php
@@ -128,7 +128,7 @@
$validators = [];
$validators[] = new TypeValidator( 'string' );
$validators[] = new StringLengthValidator( 1, $this->maxLength, 
'mb_strlen' );
-   $validators[] = new RegexValidator( '/^\s|[\v\t]|\s$/u', true 
); // no leading/trailing whitespace, no line breaks.
+   $validators[] = new RegexValidator( '/^\s|[\v\t]|\s$/u', true 
); // no leading/trailing whitespace, no tab or vertical whitespace, no line 
breaks.
 
return $validators;
}

-- 
To view, visit https://gerrit.wikimedia.org/r/400238
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1dc87a8c71c23a0ae9da80a27cc1b50c16c04147
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Delete cached check results on article purge

2017-12-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399851 )

Change subject: Delete cached check results on article purge
..

Delete cached check results on article purge

Bug: T182107
Change-Id: I7bb8b9a7c20508c2ce601ba5f3537c4b4cc2103a
---
M extension.json
M src/WikibaseQualityConstraintsHooks.php
2 files changed, 16 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/51/399851/1

diff --git a/extension.json b/extension.json
index ee2b974..4867c38 100644
--- a/extension.json
+++ b/extension.json
@@ -17,7 +17,8 @@
},
"Hooks": {
"LoadExtensionSchemaUpdates": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onCreateSchema",
-   "WikibaseChangeNotification": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onWikibaseChange"
+   "WikibaseChangeNotification": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onWikibaseChange",
+   "ArticlePurge": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onArticlePurge"
},
"SpecialPages": {
"ConstraintReport": 
"WikibaseQuality\\ConstraintReport\\Specials\\SpecialConstraintReport::newFromGlobalState"
diff --git a/src/WikibaseQualityConstraintsHooks.php 
b/src/WikibaseQualityConstraintsHooks.php
index 4ccdfc0..e24a3c8 100644
--- a/src/WikibaseQualityConstraintsHooks.php
+++ b/src/WikibaseQualityConstraintsHooks.php
@@ -12,6 +12,9 @@
 use Wikibase\DataModel\Entity\PropertyId;
 use Wikibase\EntityChange;
 use Wikibase\Lib\Changes\EntityDiffChangedAspects;
+use Wikibase\Repo\WikibaseRepo;
+use WikibaseQuality\ConstraintReport\Api\ResultsCache;
+use WikiPage;
 
 /**
  * Container for hook callbacks registered in extension.json.
@@ -67,4 +70,15 @@
return in_array( $propertyConstraintId, 
$aspects->getStatementChanges() );
}
 
+   public static function onArticlePurge( WikiPage $wikiPage ) {
+   $repo = WikibaseRepo::getDefaultInstance();
+
+   $entityContentFactory = $repo->getEntityContentFactory();
+   if ( $entityContentFactory->isEntityContentModel( 
$wikiPage->getContentModel() ) ) {
+   $entityId = $entityContentFactory->getEntityIdForTitle( 
$wikiPage->getTitle() );
+   $resultsCache = ResultsCache::getDefaultInstance();
+   $resultsCache->delete( $entityId );
+   }
+   }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/399851
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7bb8b9a7c20508c2ce601ba5f3537c4b4cc2103a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Extract ResultsCache from CachingResultsBuilder

2017-12-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399850 )

Change subject: Extract ResultsCache from CachingResultsBuilder
..

Extract ResultsCache from CachingResultsBuilder

ResultsCache contains just the key-handling logic from
CachingResultsBuilder, which is necessary because we need just that part
when handling the ArticlePurge hook, and don’t want to create a full
CachingResultsBuilder (wrapping a CheckingResultsBuilder, which contains
a DelegatingConstraintChecker, etc.) just to handle that hook.

Bug: T182107
Change-Id: I2b4602e99d936d33c21b716a24186f879d1449a9
---
M src/Api/CachingResultsBuilder.php
M src/Api/CheckConstraints.php
A src/Api/ResultsCache.php
M tests/phpunit/Api/CachingResultsBuilderTest.php
A tests/phpunit/Api/ResultsCacheTest.php
5 files changed, 164 insertions(+), 37 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/50/399850/1

diff --git a/src/Api/CachingResultsBuilder.php 
b/src/Api/CachingResultsBuilder.php
index fc57923..0bdb063 100644
--- a/src/Api/CachingResultsBuilder.php
+++ b/src/Api/CachingResultsBuilder.php
@@ -12,7 +12,7 @@
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Cache\Metadata;
 
 /**
- * A wrapper around another ResultsBuilder that caches results in a 
WANObjectCache.
+ * A wrapper around another ResultsBuilder that caches results in a 
ResultsCache.
  *
  * The format of the response returned by the wrapped ResultsBuilder mostly 
does not matter,
  * but the outermost level must be an array from entity ID serialization to 
results for that entity.
@@ -29,7 +29,7 @@
private $resultsBuilder;
 
/**
-* @var WANObjectCache
+* @var ResultsCache
 */
private $cache;
 
@@ -55,14 +55,14 @@
 
/**
 * @param ResultsBuilder $resultsBuilder The ResultsBuilder that cache 
misses are delegated to.
-* @param WANObjectCache $cache The cache where results can be stored.
+* @param ResultsCache $cache The cache where results can be stored.
 * @param EntityRevisionLookup $entityRevisionLookup Used to get the 
latest revision ID.
 * @param EntityIdParser $entityIdParser Used to parse entity IDs in 
cached objects.
 * @param int $ttlInSeconds Time-to-live of the cached values, in 
seconds.
 */
public function __construct(
ResultsBuilder $resultsBuilder,
-   WANObjectCache $cache,
+   ResultsCache $cache,
EntityRevisionLookup $entityRevisionLookup,
EntityIdParser $entityIdParser,
$ttlInSeconds
@@ -129,19 +129,6 @@
}
 
/**
-* @param EntityId $entityId
-* @return string cache key
-*/
-   public function makeKey( EntityId $entityId ) {
-   return $this->cache->makeKey(
-   'WikibaseQualityConstraints', // extension
-   'checkConstraints', // action
-   'v2', // API response format version
-   $entityId->getSerialization()
-   );
-   }
-
-   /**
 * @param EntityId[] $entityIds
 * @param string[] $claimIds
 * @param string[]|null $constraintIds
@@ -156,14 +143,13 @@
 
if ( $this->canStoreResults( $entityIds, $claimIds, 
$constraintIds ) ) {
foreach ( $entityIds as $entityId ) {
-   $key = $this->makeKey( $entityId );
$value = [
'results' => 
$results->getArray()[$entityId->getSerialization()],
'latestRevisionIds' => 
$this->getLatestRevisionIds(

$results->getMetadata()->getDependencyMetadata()->getEntityIds()
),
];
-   $this->cache->set( $key, $value, 
$this->ttlInSeconds );
+   $this->cache->set( $entityId, $value, 
$this->ttlInSeconds );
}
}
 
@@ -196,8 +182,7 @@
public function getStoredResults(
EntityId $entityId
) {
-   $key = $this->makeKey( $entityId );
-   $value = $this->cache->get( $key, $curTTL, [], $asOf );
+   $value = $this->cache->get( $entityId, $curTTL, [], $asOf );
$now = call_user_func( $this->microtime, true );
 
if ( $value === false ) {
diff --git a/src/Api/CheckConstraints.php b/src/Api/CheckConstraints.php
index a384895..e3e3338 100644
--- a/src/Api/CheckConstraints.php
+++ b/src/Api/CheckConstraints.php
@@ -110,12 +110,11 @@
$config
);
if ( 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Move …\ConstraintCheck\Api namespace to …\Api

2017-12-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399843 )

Change subject: Move …\ConstraintCheck\Api namespace to …\Api
..

Move …\ConstraintCheck\Api namespace to …\Api

The ResultsBuilder interface and implementing classes don’t perform
constraint checks themselves, so they are placed more appropriately in
the general WikibaseQuality\ConstraintReport\Api namespace.

Change-Id: I2d1786728781bd45440c38621c9ab87487be
---
R src/Api/CachingResultsBuilder.php
M src/Api/CheckConstraints.php
R src/Api/CheckingResultsBuilder.php
R src/Api/ResultsBuilder.php
M tests/phpunit/Api/CachingResultsBuilderTest.php
M tests/phpunit/Api/CheckConstraintsTest.php
M tests/phpunit/Api/CheckingResultsBuilderTest.php
7 files changed, 12 insertions(+), 12 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/43/399843/1

diff --git a/src/ConstraintCheck/Api/CachingResultsBuilder.php 
b/src/Api/CachingResultsBuilder.php
similarity index 98%
rename from src/ConstraintCheck/Api/CachingResultsBuilder.php
rename to src/Api/CachingResultsBuilder.php
index f37249f..fc57923 100644
--- a/src/ConstraintCheck/Api/CachingResultsBuilder.php
+++ b/src/Api/CachingResultsBuilder.php
@@ -1,6 +1,6 @@
 https://gerrit.wikimedia.org/r/399843
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d1786728781bd45440c38621c9ab87487be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Register hooks without array syntax

2017-12-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399842 )

Change subject: Register hooks without array syntax
..

Register hooks without array syntax

If we only register a single handler for a hook, we can omit the
surrounding array.

Change-Id: I983c62f56e7048b39c8f4ca0a323a8af9185eda6
---
M extension.json
1 file changed, 2 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/42/399842/1

diff --git a/extension.json b/extension.json
index 72fb5a6..ee2b974 100644
--- a/extension.json
+++ b/extension.json
@@ -16,12 +16,8 @@
"WikibaseQualityConstraintsAlias": 
"WikibaseQualityConstraints.alias.php"
},
"Hooks": {
-   "LoadExtensionSchemaUpdates": [
-   
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onCreateSchema"
-   ],
-   "WikibaseChangeNotification": [
-   
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onWikibaseChange"
-   ]
+   "LoadExtensionSchemaUpdates": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onCreateSchema",
+   "WikibaseChangeNotification": 
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onWikibaseChange"
},
"SpecialPages": {
"ConstraintReport": 
"WikibaseQuality\\ConstraintReport\\Specials\\SpecialConstraintReport::newFromGlobalState"

-- 
To view, visit https://gerrit.wikimedia.org/r/399842
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I983c62f56e7048b39c8f4ca0a323a8af9185eda6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: Don’t check constraints on example properties

2017-12-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399825 )

Change subject: Don’t check constraints on example properties
..

Don’t check constraints on example properties

For the properties “Wikidata property example” and “Wikidata property
example for properties”, it doesn’t make sense to check constraints on
qualifiers of statements of that properties, since the object of the
statement is actually the subject of a virtual example statement, and
the snak of that virtual example statement is actually a qualifier of
the statement. This reshuffling of roles in the datamodel results in
constraint violations for most properties, and it’s pointless to report
them to users.

Bug: T183267
Change-Id: Ica42f7d125d803b6d4a49711794d5626e48e5aef
Depends-On: If068c786779122d4f5ff158c9ac8a9a6e6610535
---
M wmf-config/Wikibase-production.php
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/25/399825/1

diff --git a/wmf-config/Wikibase-production.php 
b/wmf-config/Wikibase-production.php
index e866bed..0552e5a 100644
--- a/wmf-config/Wikibase-production.php
+++ b/wmf-config/Wikibase-production.php
@@ -140,6 +140,7 @@
$wgWBQualityConstraintsSparqlEndpoint = 
$wgWBRepoSettings['sparqlEndpoint'];
$wgWBQualityConstraintsSparqlMaxMillis = 5000; // limit SPARQL 
queries to just 5 seconds for now
$wgWBQualityConstraintsTypeCheckMaxEntities = 10; // only check 
few entities in PHP => fall back to SPARQL very quickly
+   $wgWBQualityConstraintsPropertiesWithViolatingQualifiers = [ 
'P1855', 'P2271' ]; // T183267
// T148411: Use profile that demotes disambigs by default

$wgWBRepoSettings['entitySearch']['defaultPrefixRescoreProfile'] = 
'wikibase_prefix_boost';
$wgWBRepoSettings['entitySearch']['statementBoost'] = [ 
'P31=Q4167410' => '-10' ];

-- 
To view, visit https://gerrit.wikimedia.org/r/399825
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica42f7d125d803b6d4a49711794d5626e48e5aef
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Skip constraint checks for qualifiers of certain properties

2017-12-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399824 )

Change subject: Skip constraint checks for qualifiers of certain properties
..

Skip constraint checks for qualifiers of certain properties

Properties like Wikidata’s “property example” change the roles of
statement values and qualifiers, which results in lots of pointless
constraint violations that can’t (and shouldn’t) be fixed. Ignore all
qualifiers of such properties.

We don’t add the Wikidata properties “Wikidata property example” and
“Wikidata property example for properties” as the default value, since
there is no way to specify an array config variable that gets
*overwritten* by LocalSettings.php instead of merged with the default
value. Instead, those Wikidata properties are ignored in the
Wikidata-specific configuration in Ica42f7d125. (This also means that
the import snippet in README.md will not import these properties into a
local installation, which is what we want – they’re not required for
WikibaseQualityConstraints to work.)

Bug: T183267
Change-Id: If068c786779122d4f5ff158c9ac8a9a6e6610535
---
M extension.json
M src/ConstraintCheck/DelegatingConstraintChecker.php
M src/ConstraintReportFactory.php
M tests/phpunit/Api/CheckConstraintsTest.php
M tests/phpunit/DelegatingConstraintCheckerTest.php
5 files changed, 76 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/24/399824/1

diff --git a/extension.json b/extension.json
index 72fb5a6..d880bcd 100644
--- a/extension.json
+++ b/extension.json
@@ -375,6 +375,11 @@
"description": "The property ID of the 'syntax 
clarification' property (data type: monolingual text), which specifies 
human-readable explanations of a 'format' constraint.",
"public": true
},
+   "WBQualityConstraintsPropertiesWithViolatingQualifiers": {
+   "value": [],
+   "description": "Property IDs of statements whose 
qualifiers are expected to violate constraints, and where constraints checks 
are therefore skipped, as if the subject entity was an exception to the 
constraints defined on the qualifier properties.",
+   "public": true
+   },
"WBQualityConstraintsYearUnit": {
"value": "http://www.wikidata.org/entity/Q577;,
"description": "The unit used for a quantity that 
represents a difference between two dates, in years. Note that for entity 
units, the full concept URI must be used, not just the entity ID.",
diff --git a/src/ConstraintCheck/DelegatingConstraintChecker.php 
b/src/ConstraintCheck/DelegatingConstraintChecker.php
index 6df9f3d..d583a04 100644
--- a/src/ConstraintCheck/DelegatingConstraintChecker.php
+++ b/src/ConstraintCheck/DelegatingConstraintChecker.php
@@ -79,6 +79,11 @@
private $checkReferences;
 
/**
+* @var string[]
+*/
+   private $propertiesWithViolatingQualifiers;
+
+   /**
 * @param EntityLookup $lookup
 * @param ConstraintChecker[] $checkerMap
 * @param ConstraintLookup $constraintRepository
@@ -87,6 +92,8 @@
 * @param LoggingHelper $loggingHelper
 * @param bool $checkQualifiers whether to check qualifiers
 * @param bool $checkReferences whether to check references
+* @param string[] $propertiesWithViolatingQualifiers on statements of 
these properties,
+* qualifiers will not be checked
 */
public function __construct(
EntityLookup $lookup,
@@ -96,7 +103,8 @@
StatementGuidParser $statementGuidParser,
LoggingHelper $loggingHelper,
$checkQualifiers,
-   $checkReferences
+   $checkReferences,
+   array $propertiesWithViolatingQualifiers
) {
$this->entityLookup = $lookup;
$this->checkerMap = $checkerMap;
@@ -106,6 +114,7 @@
$this->loggingHelper = $loggingHelper;
$this->checkQualifiers = $checkQualifiers;
$this->checkReferences = $checkReferences;
+   $this->propertiesWithViolatingQualifiers = 
$propertiesWithViolatingQualifiers;
}
 
/**
@@ -421,6 +430,13 @@
) {
$result = [];
 
+   if ( in_array(
+   $statement->getPropertyId()->getSerialization(),
+   $this->propertiesWithViolatingQualifiers
+   ) ) {
+   return $result;
+   }
+
foreach ( $statement->getQualifiers() as $qualifier ) {
$qualifierContext = new QualifierContext( $entity, 
$statement, $qualifier );
if ( 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add semantic tags to license info text

2017-12-22 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399818 )

Change subject: Add semantic tags to license info text
..

Add semantic tags to license info text

Instead of writing parts of the text in UPPERCASE, surround it with
emphasis or strong importance tags, and then change the style of those
tags back to UPPERCASE via CSS. In normal browsers, there should be no
visible difference, but other user agents might be able to utilize the
additional semantic information.

Change-Id: Ief505e28fe971da537726afd75238b87204b85dd
---
M includes/specials/SpecialVersion.php
M languages/i18n/en.json
M resources/src/mediawiki.special/mediawiki.special.version.css
3 files changed, 12 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/18/399818/1

diff --git a/includes/specials/SpecialVersion.php 
b/includes/specials/SpecialVersion.php
index f176b40..2b72403 100644
--- a/includes/specials/SpecialVersion.php
+++ b/includes/specials/SpecialVersion.php
@@ -169,7 +169,7 @@
$ret .= '';
$ret .= "__NOTOC__
" . self::getCopyrightAndAuthorList() . "\n
-   " . wfMessage( 'version-license-info' )->text();
+   " . '' . wfMessage( 
'version-license-info' )->text() . '';
$ret .= '';
 
return str_replace( "\t\t", '', $ret ) . "\n";
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 301408f..e91cd4e 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -3806,7 +3806,7 @@
"version-poweredby-others": "others",
"version-poweredby-translators": "translatewiki.net translators",
"version-credits-summary": "We would like to recognize the following 
persons for their contribution to [[Special:Version|MediaWiki]].",
-   "version-license-info": "MediaWiki is free software; you can 
redistribute it and/or modify it under the terms of the GNU General Public 
License as published by the Free Software Foundation; either version 2 of the 
License, or (at your option) any later version.\n\nMediaWiki is distributed in 
the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 
the GNU General Public License for more details.\n\nYou should have received 
[{{SERVER}}{{SCRIPTPATH}}/COPYING a copy of the GNU General Public License] 
along with this program; if not, write to the Free Software Foundation, Inc., 
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA or 
[//www.gnu.org/licenses/old-licenses/gpl-2.0.html read it online].",
+   "version-license-info": "MediaWiki is free software; you can 
redistribute it and/or modify it under the terms of the GNU General Public 
License as published by the Free Software Foundation; either version 2 of the 
License, or (at your option) any later version.\n\nMediaWiki is distributed in 
the hope that it will be useful, but without any warranty; without 
even the implied warranty of merchantability or 
fitness for a particular purpose. See the GNU General Public 
License for more details.\n\nYou should have received 
[{{SERVER}}{{SCRIPTPATH}}/COPYING a copy of the GNU General Public License] 
along with this program; if not, write to the Free Software Foundation, Inc., 
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA or 
[//www.gnu.org/licenses/old-licenses/gpl-2.0.html read it online].",
"version-software": "Installed software",
"version-software-product": "Product",
"version-software-version": "Version",
diff --git a/resources/src/mediawiki.special/mediawiki.special.version.css 
b/resources/src/mediawiki.special/mediawiki.special.version.css
index ebb6b48..5fd87bb 100644
--- a/resources/src/mediawiki.special/mediawiki.special.version.css
+++ b/resources/src/mediawiki.special/mediawiki.special.version.css
@@ -24,3 +24,13 @@
-moz-column-width: 18em;
-webkit-column-width: 18em;
 }
+
+.mw-version-license-info strong {
+  text-transform: uppercase;
+  font-weight: normal;
+}
+
+.mw-version-license-info em {
+  text-transform: uppercase;
+  font-style: normal;
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/399818
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief505e28fe971da537726afd75238b87204b85dd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Update CachingMetadata embedded in constraint check results

2017-12-21 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399655 )

Change subject: Update CachingMetadata embedded in constraint check results
..

Update CachingMetadata embedded in constraint check results

When we retrieve constraint check results from the cache, we need to
update the 'cached' information encoded in them, and merge it with the
new information as to how old the response from the WANObjectCache is.

Bug: T182992
Change-Id: Id6b165296640fd6e9c20299c040d5c0ea76b3a3f
---
M src/Api/CheckConstraints.php
M src/ConstraintCheck/Api/CachingResultsBuilder.php
M tests/phpunit/Api/CachingResultsBuilderTest.php
3 files changed, 134 insertions(+), 16 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/55/399655/1

diff --git a/src/Api/CheckConstraints.php b/src/Api/CheckConstraints.php
index 4e6518d..72eee86 100644
--- a/src/Api/CheckConstraints.php
+++ b/src/Api/CheckConstraints.php
@@ -121,7 +121,13 @@
$cache,
$entityRevisionLookup,
$entityIdParser,
-   $config->get( 
'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' )
+   $config->get( 
'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
+   [
+   $config->get( 
'WBQualityConstraintsCommonsLinkConstraintId' ),
+   $config->get( 
'WBQualityConstraintsTypeConstraintId' ),
+   $config->get( 
'WBQualityConstraintsValueTypeConstraintId' ),
+   $config->get( 
'WBQualityConstraintsDistinctValuesConstraintId' ),
+   ]
);
}
 
diff --git a/src/ConstraintCheck/Api/CachingResultsBuilder.php 
b/src/ConstraintCheck/Api/CachingResultsBuilder.php
index 06bbd58..3353bde 100644
--- a/src/ConstraintCheck/Api/CachingResultsBuilder.php
+++ b/src/ConstraintCheck/Api/CachingResultsBuilder.php
@@ -49,6 +49,11 @@
private $ttlInSeconds;
 
/**
+* @var string[]
+*/
+   private $possiblyStaleConstraintTypes;
+
+   /**
 * @var callable
 */
private $microtime = 'microtime';
@@ -59,19 +64,23 @@
 * @param EntityRevisionLookup $entityRevisionLookup Used to get the 
latest revision ID.
 * @param EntityIdParser $entityIdParser Used to parse entity IDs in 
cached objects.
 * @param int $ttlInSeconds Time-to-live of the cached values, in 
seconds.
+* @param string[] $possiblyStaleConstraintTypes item IDs of constraint 
types
+* where cached results may always be stale, regardless of invalidation 
logic
 */
public function __construct(
ResultsBuilder $resultsBuilder,
WANObjectCache $cache,
EntityRevisionLookup $entityRevisionLookup,
EntityIdParser $entityIdParser,
-   $ttlInSeconds
+   $ttlInSeconds,
+   array $possiblyStaleConstraintTypes
) {
$this->resultsBuilder = $resultsBuilder;
$this->cache = $cache;
$this->entityRevisionLookup = $entityRevisionLookup;
$this->entityIdParser = $entityIdParser;
$this->ttlInSeconds = $ttlInSeconds;
+   $this->possiblyStaleConstraintTypes = 
$possiblyStaleConstraintTypes;
}
 
/**
@@ -215,6 +224,12 @@
return null;
}
 
+   $cachingMetadata = $ageInSeconds > 0 ?
+   CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) 
:
+   CachingMetadata::fresh();
+
+   array_walk( $value['results'], [ $this, 'updateCachingMetadata' 
], $cachingMetadata );
+
return new CachedCheckConstraintsResponse(
[ $entityId->getSerialization() => $value['results'] ],
array_reduce(
@@ -227,11 +242,7 @@
)
] );
},
-   Metadata::ofCachingMetadata(
-   $ageInSeconds > 0 ?
-   
CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
-   CachingMetadata::fresh()
-   )
+   Metadata::ofCachingMetadata( $cachingMetadata )
)
);
}
@@ -250,6 +261,30 @@
return $latestRevisionIds;
}
 
+   public function updateCachingMetadata( 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Move CachingMetadata array serialization into class

2017-12-20 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399441 )

Change subject: Move CachingMetadata array serialization into class
..

Move CachingMetadata array serialization into class

This moves the serialization of CachingMetadata into an array structure
(or null) from CheckingResultsBuilder into the CachingMetadata itself,
and also adds matching deserialization.

Bug: T182992
Change-Id: I10548d60091fa1464ca7702282d0d4d71417ab78
---
M src/ConstraintCheck/Api/CheckingResultsBuilder.php
M src/ConstraintCheck/Cache/CachingMetadata.php
M tests/phpunit/Cache/CachingMetadataTest.php
3 files changed, 78 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/41/399441/1

diff --git a/src/ConstraintCheck/Api/CheckingResultsBuilder.php 
b/src/ConstraintCheck/Api/CheckingResultsBuilder.php
index 0a194ae..a90bf03 100644
--- a/src/ConstraintCheck/Api/CheckingResultsBuilder.php
+++ b/src/ConstraintCheck/Api/CheckingResultsBuilder.php
@@ -149,11 +149,9 @@
if ( $checkResult->getContext()->getType() === 
Context::TYPE_STATEMENT ) {
$result['claim'] = 
$checkResult->getContext()->getSnakStatement()->getGuid();
}
-   $cachingMetadata = 
$checkResult->getMetadata()->getCachingMetadata();
-   if ( $cachingMetadata->isCached() ) {
-   $result['cached'] = [
-   'maximumAgeInSeconds' => 
$cachingMetadata->getMaximumAgeInSeconds(),
-   ];
+   $cachingMetadataArray = 
$checkResult->getMetadata()->getCachingMetadata()->toArray();
+   if ( $cachingMetadataArray !== null ) {
+   $result['cached'] = $cachingMetadataArray;
}
 
return $result;
diff --git a/src/ConstraintCheck/Cache/CachingMetadata.php 
b/src/ConstraintCheck/Cache/CachingMetadata.php
index 18217be..328be5a 100644
--- a/src/ConstraintCheck/Cache/CachingMetadata.php
+++ b/src/ConstraintCheck/Cache/CachingMetadata.php
@@ -38,6 +38,19 @@
}
 
/**
+* Deserializes the metadata from an array (or null if the value is 
fresh).
+* @param array|null $array As returned by toArray.
+* @return CachingMetadata
+*/
+   public static function ofArray( array $array = null ) {
+   $ret = new self;
+   if ( $array !== null ) {
+   $ret->maxAge = $array['maximumAgeInSeconds'];
+   }
+   return $ret;
+   }
+
+   /**
 * @param self[] $metadatas
 * @return self
 */
@@ -70,4 +83,16 @@
}
}
 
+   /**
+* Serializes the metadata into an array (or null if the value is 
fresh).
+* @return array|null
+*/
+   public function toArray() {
+   return $this->isCached() ?
+   [
+   'maximumAgeInSeconds' => $this->maxAge,
+   ] :
+   null;
+   }
+
 }
diff --git a/tests/phpunit/Cache/CachingMetadataTest.php 
b/tests/phpunit/Cache/CachingMetadataTest.php
index a11f1a0..23434a6 100644
--- a/tests/phpunit/Cache/CachingMetadataTest.php
+++ b/tests/phpunit/Cache/CachingMetadataTest.php
@@ -84,4 +84,54 @@
] );
}
 
+   public function testToArray_fresh() {
+   $cm = CachingMetadata::fresh();
+
+   $array = $cm->toArray();
+
+   $this->assertNull( $array );
+   }
+
+   public function testToArray_ofMaximumAgeInSeconds() {
+   $cm = CachingMetadata::ofMaximumAgeInSeconds( 42 );
+
+   $array = $cm->toArray();
+
+   $this->assertSame( [ 'maximumAgeInSeconds' => 42 ], $array );
+   }
+
+   public function testOfArray_fresh() {
+   $array = null;
+
+   $cm = CachingMetadata::ofArray( $array );
+
+   $this->assertFalse( $cm->isCached() );
+   }
+
+   public function testOfArray_ofMaximumAgeInSeconds() {
+   $array = [ 'maximumAgeInSeconds' => 45 ];
+
+   $cm = CachingMetadata::ofArray( $array );
+
+   $this->assertTrue( $cm->isCached() );
+   $this->assertSame( 45, $cm->getMaximumAgeInSeconds() );
+   }
+
+   /**
+* @dataProvider arrayRoundTripProvider
+*/
+   public function testOfArray_RoundTrip( CachingMetadata $cm ) {
+   $array = $cm->toArray();
+   $cm_ = CachingMetadata::ofArray( $array );
+
+   $this->assertEquals( $cm, $cm_ );
+   }
+
+   public function arrayRoundTripProvider() {
+   return [
+   [ CachingMetadata::fresh() ],
+   [ 

[MediaWiki-commits] [Gerrit] wikidata...gui[master]: Remove unused IIFE parameter

2017-12-20 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399429 )

Change subject: Remove unused IIFE parameter
..

Remove unused IIFE parameter

Change-Id: I7875f73810127b22bb90598cb17f80d58e61875b
---
M wikibase/queryService/ui/editor/Editor.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/29/399429/1

diff --git a/wikibase/queryService/ui/editor/Editor.js 
b/wikibase/queryService/ui/editor/Editor.js
index 912a30d..0292140 100644
--- a/wikibase/queryService/ui/editor/Editor.js
+++ b/wikibase/queryService/ui/editor/Editor.js
@@ -3,7 +3,7 @@
 wikibase.queryService.ui = wikibase.queryService.ui || {};
 wikibase.queryService.ui.editor = wikibase.queryService.ui.editor || {};
 
-wikibase.queryService.ui.editor.Editor = ( function( $, wikibase, CodeMirror, 
WikibaseRDFTooltip ) {
+wikibase.queryService.ui.editor.Editor = ( function( $, wikibase, CodeMirror ) 
{
'use strict';
 
var CODEMIRROR_DEFAULTS = {

-- 
To view, visit https://gerrit.wikimedia.org/r/399429
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7875f73810127b22bb90598cb17f80d58e61875b
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] wikidata...gui[master]: Hide Ctrl+Space help toast when shortcut is used

2017-12-20 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399430 )

Change subject: Hide Ctrl+Space help toast when shortcut is used
..

Hide Ctrl+Space help toast when shortcut is used

When the user has used the Ctrl+Space keyboard shortcut, it’s
probably safe to assume that they no longer need the hint informing them
of the Ctrl+Space keyboard shortcut, so let’s hide it instead of making
them hurry to click the “” button before the toast vanishes.

Change-Id: I638fa3c423ca7076e898b920f9bbc0f8bb76d730
---
M wikibase/queryService/ui/editor/Editor.js
1 file changed, 6 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/30/399430/1

diff --git a/wikibase/queryService/ui/editor/Editor.js 
b/wikibase/queryService/ui/editor/Editor.js
index 0292140..7416404 100644
--- a/wikibase/queryService/ui/editor/Editor.js
+++ b/wikibase/queryService/ui/editor/Editor.js
@@ -3,7 +3,7 @@
 wikibase.queryService.ui = wikibase.queryService.ui || {};
 wikibase.queryService.ui.editor = wikibase.queryService.ui.editor || {};
 
-wikibase.queryService.ui.editor.Editor = ( function( $, wikibase, CodeMirror ) 
{
+wikibase.queryService.ui.editor.Editor = ( function( $, wikibase, CodeMirror, 
Cookies ) {
'use strict';
 
var CODEMIRROR_DEFAULTS = {
@@ -11,7 +11,10 @@
'matchBrackets': true,
'mode': 'sparql',
'extraKeys': {
-   'Ctrl-Space': 'autocomplete',
+   'Ctrl-Space': function( cm ) {
+   Cookies.set( 
'hide-toast-wdqs-app-footer-help', true );
+   cm.execCommand( 'autocomplete' );
+   },
'Tab': function( cm ) {
var spaces = Array( cm.getOption( 
'indentUnit' ) + 1 ).join( ' ' );
cm.replaceSelection( spaces );
@@ -313,4 +316,4 @@
 
return SELF;
 
-}( jQuery, wikibase, CodeMirror ) );
+}( jQuery, wikibase, CodeMirror, Cookies ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/399430
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I638fa3c423ca7076e898b920f9bbc0f8bb76d730
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Reuse blank/fresh metadata objects

2017-12-20 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399384 )

Change subject: Reuse blank/fresh metadata objects
..

Reuse blank/fresh metadata objects

All our metadata objects are immutable, so we can reuse a single
blank/fresh instance per class instead of instantiating new ones for
every invocation.

Change-Id: I9de5131aa0fd13f8cf95ce4106ea9ddbac219099
---
M src/ConstraintCheck/Cache/CachingMetadata.php
M src/ConstraintCheck/Cache/DependencyMetadata.php
M src/ConstraintCheck/Cache/Metadata.php
3 files changed, 15 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/84/399384/1

diff --git a/src/ConstraintCheck/Cache/CachingMetadata.php 
b/src/ConstraintCheck/Cache/CachingMetadata.php
index 18217be..ed3443b 100644
--- a/src/ConstraintCheck/Cache/CachingMetadata.php
+++ b/src/ConstraintCheck/Cache/CachingMetadata.php
@@ -22,7 +22,11 @@
 * @return self Indication that a value is fresh, i. e. not cached.
 */
public static function fresh() {
-   return new self;
+   static $fresh = null;
+   if ( $fresh === null ) {
+   $fresh = new self;
+   }
+   return $fresh;
}
 
/**
diff --git a/src/ConstraintCheck/Cache/DependencyMetadata.php 
b/src/ConstraintCheck/Cache/DependencyMetadata.php
index fc30e2d..b39a260 100644
--- a/src/ConstraintCheck/Cache/DependencyMetadata.php
+++ b/src/ConstraintCheck/Cache/DependencyMetadata.php
@@ -22,7 +22,11 @@
 * @return self Indication that a value does not depend on anything 
else.
 */
public static function blank() {
-   return new self;
+   static $blank = null;
+   if ( $blank === null ) {
+   $blank = new self;
+   }
+   return $blank;
}
 
/**
diff --git a/src/ConstraintCheck/Cache/Metadata.php 
b/src/ConstraintCheck/Cache/Metadata.php
index c9ff9a3..3941902 100644
--- a/src/ConstraintCheck/Cache/Metadata.php
+++ b/src/ConstraintCheck/Cache/Metadata.php
@@ -26,7 +26,11 @@
 * @return self Empty collection.
 */
public static function blank() {
-   return new self;
+   static $blank = null;
+   if ( $blank === null ) {
+   $blank = new self;
+   }
+   return $blank;
}
 
public static function ofCachingMetadata( CachingMetadata 
$cachingMetadata ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/399384
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9de5131aa0fd13f8cf95ce4106ea9ddbac219099
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Normalize Metadata after merge

2017-12-20 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399381 )

Change subject: Normalize Metadata after merge
..

Normalize Metadata after merge

Tests that use assertEquals() on metadata objects require that
equivalent objects are member-by-member equal, so we need to replace
blank merged metadata members with null ones so they’re equal to members
of Metadata::blank().

Change-Id: I60a921ba6527336e745644fddc787875fb7faf1b
---
M src/ConstraintCheck/Cache/Metadata.php
M tests/phpunit/Cache/MetadataTest.php
2 files changed, 28 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/81/399381/1

diff --git a/src/ConstraintCheck/Cache/Metadata.php 
b/src/ConstraintCheck/Cache/Metadata.php
index c9ff9a3..1c5509c 100644
--- a/src/ConstraintCheck/Cache/Metadata.php
+++ b/src/ConstraintCheck/Cache/Metadata.php
@@ -60,10 +60,32 @@
$ret = new self;
$ret->cachingMetadata = CachingMetadata::merge( 
$cachingMetadatas );
$ret->dependencyMetadata = DependencyMetadata::merge( 
$dependencyMetadatas );
+   $ret->normalize();
return $ret;
}
 
/**
+* Replace blank metadata members with null,
+* which is equivalent (the getters return new blank objects in that 
case).
+* This is required for tests which use assertEquals() on metadata 
objects,
+* so the tests don’t fail because one object has blank members and the 
other has null members.
+*/
+   private function normalize() {
+   if (
+   $this->cachingMetadata !== null &&
+   $this->cachingMetadata == CachingMetadata::fresh()
+   ) {
+   $this->cachingMetadata = null;
+   }
+   if (
+   $this->dependencyMetadata !== null &&
+   $this->dependencyMetadata == DependencyMetadata::blank()
+   ) {
+   $this->dependencyMetadata = null;
+   }
+   }
+
+   /**
 * @return CachingMetadata
 */
public function getCachingMetadata() {
diff --git a/tests/phpunit/Cache/MetadataTest.php 
b/tests/phpunit/Cache/MetadataTest.php
index e1fa48f..e7e97f6 100644
--- a/tests/phpunit/Cache/MetadataTest.php
+++ b/tests/phpunit/Cache/MetadataTest.php
@@ -84,4 +84,10 @@
] );
}
 
+   public function testMerge_blankEquals() {
+   $m = Metadata::merge( [ Metadata::blank() ] );
+
+   $this->assertEquals( Metadata::blank(), $m );
+   }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/399381
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I60a921ba6527336e745644fddc787875fb7faf1b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Split up CachingMetadata

2017-12-18 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/39 )

Change subject: Split up CachingMetadata
..

Split up CachingMetadata

The CachingMetadata class is split up into three classes:

- Metadata, a container for the other metadata classes. A Metadata
  object holds one CachingMetadata object and one DependencyMetadata
  object. It also knows how to merge several Metadata objects into one.
- CachingMetadata, which contains information about how a value was
  cached: currently its maximum age, in the future perhaps also the
  caches that were used (WDQS Varnish, WANObjectCache, …).
- DependencyMetadata, which contains information about what a value
  depends on (which influences how it *should* be cached, more
  specifically when cached values need to be purged, but has nothing to
  do with how a value *was* cached): currently a list of entity IDs, in
  the future perhaps also some separate tracking for properties of
  constraints so that cached results are only invalidated when
  constraints are edited, not on other edits on the property (T183159).

Everything that previously held or passed around a CachingMetadata
object now handles Metadata instead; places that instantiated
CachingMetadata are updated to instantiate the correct class instead and
wrap it in a new Metadata object.

The wrappers in the Cache namespace (CachedArray, CachedBool etc.) keep
their names for now, even though they are no longer entirely
appropriate. They can be renamed later, once we have another good naming
scheme for them.

Bug: T182697
Change-Id: I4b2d02196feada0d4eddd816b4ef7e33bfcde02b
---
M src/ConstraintCheck/Api/CachingResultsBuilder.php
M src/ConstraintCheck/Api/CheckingResultsBuilder.php
M src/ConstraintCheck/Cache/CachedArray.php
M src/ConstraintCheck/Cache/CachedBool.php
M src/ConstraintCheck/Cache/CachingMetadata.php
A src/ConstraintCheck/Cache/DependencyMetadata.php
A src/ConstraintCheck/Cache/Metadata.php
M src/ConstraintCheck/Checker/InverseChecker.php
M src/ConstraintCheck/Checker/SymmetricChecker.php
M src/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
M src/ConstraintCheck/Checker/TypeChecker.php
M src/ConstraintCheck/Checker/UniqueValueChecker.php
M src/ConstraintCheck/Checker/ValueTypeChecker.php
M src/ConstraintCheck/DelegatingConstraintChecker.php
M src/ConstraintCheck/Helper/SparqlHelper.php
M src/ConstraintCheck/Helper/TypeCheckerHelper.php
M src/ConstraintCheck/Result/CheckResult.php
M tests/phpunit/Api/CachingResultsBuilderTest.php
M tests/phpunit/Api/CheckingResultsBuilderTest.php
M tests/phpunit/Cache/CachedArrayTest.php
M tests/phpunit/Cache/CachedBoolTest.php
M tests/phpunit/Cache/CachedCheckConstraintsResponseTest.php
M tests/phpunit/Cache/CachedEntityIdsTest.php
M tests/phpunit/Cache/CachedQueryResultsTest.php
M tests/phpunit/Cache/CachingMetadataTest.php
A tests/phpunit/Cache/DependencyMetadataTest.php
A tests/phpunit/Cache/MetadataTest.php
M tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php
M tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php
M tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php
M tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php
M tests/phpunit/DelegatingConstraintCheckerTest.php
M tests/phpunit/Helper/SparqlHelperTest.php
M tests/phpunit/Result/CheckResultTest.php
M tests/phpunit/SparqlHelperMock.php
35 files changed, 450 insertions(+), 165 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/88/39/1

diff --git a/src/ConstraintCheck/Api/CachingResultsBuilder.php 
b/src/ConstraintCheck/Api/CachingResultsBuilder.php
index 93ae400..8513223 100644
--- a/src/ConstraintCheck/Api/CachingResultsBuilder.php
+++ b/src/ConstraintCheck/Api/CachingResultsBuilder.php
@@ -89,7 +89,7 @@
$value = [
'results' => 
$results->getArray()[$entityId->getSerialization()],
'latestRevisionIds' => 
$this->getLatestRevisionIds(
-   
$results->getCachingMetadata()->getDependedEntityIds()
+   
$results->getMetadata()->getDependencyMetadata()->getEntityIds()
),
];
$this->cache->set( $key, $value, 
$this->ttlInSeconds );
diff --git a/src/ConstraintCheck/Api/CheckingResultsBuilder.php 
b/src/ConstraintCheck/Api/CheckingResultsBuilder.php
index d622fee..0a194ae 100644
--- a/src/ConstraintCheck/Api/CheckingResultsBuilder.php
+++ b/src/ConstraintCheck/Api/CheckingResultsBuilder.php
@@ -7,7 +7,7 @@
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\DataModel\Services\EntityId\EntityIdFormatter;
 use Wikibase\Lib\Store\EntityTitleLookup;
-use 

[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Escape autocomment message arguments

2017-12-18 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398821 )

Change subject: Escape autocomment message arguments
..

Escape autocomment message arguments

As far as I can tell, none of the existing wikibase-*-summary-* messages
have any wikitext parameters:

- wikibase-entity-summary-wbcreateredirect,
  wikibase-entity-summary-wbmergeitems-from and
  wikibase-entity-summary-wbmergeitems-to only insert the plain page
  title for the mentioned page, not a link.
- wikibase-entity-summary-undo and wikibase-entity-summary-restore
  create a link to Special:Contributions inside the message text itself,
  the parameter is just the plain user name.
- All other message parameters appear to be language codes, wiki codes,
  or counts, all of which should be plain text.

So none of the messages should break when we escape wikitext in the
arguments. On the other hand, some messages take user name arguments,
user names can contain characters like ‘*’ or ‘;’ which at the beginning
of a line have special meaning in wikitext, and the English message
substitutes the user names like {{GENDER:$3|$3}}, which inserts a
newline before the username – with the effect that usernames like “*foo”
or “;bar” render as lists or definition lists in the summary. Escaping
all arguments (in AutoCommentFormatter, we don’t know which arguments
are usernames) fixes this.

(We can’t just use plaintextParams() instead of params(), since that
only substitutes the parameters after parser functions are processed,
i. e. {{COUNT}}, {{GENDER}} etc. are broken.)

Bug: T182800
Change-Id: Iae6bac3bd0d487de9a5ca68e117c070105c695db
Depends-On: Ic5a8fc76c28dca43ce8e334ef1874c2673433f00
---
M lib/includes/Formatters/AutoCommentFormatter.php
1 file changed, 3 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/21/398821/1

diff --git a/lib/includes/Formatters/AutoCommentFormatter.php 
b/lib/includes/Formatters/AutoCommentFormatter.php
index 0c77d87..a8ce5a7 100644
--- a/lib/includes/Formatters/AutoCommentFormatter.php
+++ b/lib/includes/Formatters/AutoCommentFormatter.php
@@ -99,6 +99,9 @@
return null;
}
 
+   // no message requires wikitext params and some args are 
user-controlled
+   $args = array_map( 'wfEscapeWikiText', $args );
+
// render the autocomment
$auto = $msg->params( $args )->parse();
return $auto;

-- 
To view, visit https://gerrit.wikimedia.org/r/398821
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iae6bac3bd0d487de9a5ca68e117c070105c695db
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Minor test improvements

2017-12-15 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398487 )

Change subject: Minor test improvements
..

Minor test improvements

The “equal” matcher is the default, it doesn’t need to be specified
explicitly. And I think if all the parameters use that matcher it’s more
readable not to specify it (though I would still use it if there was a
mix of several matchers).

Change-Id: I3a52ef280a76bf3c52e93f05bc7b81222d69d0af
---
M tests/phpunit/Api/CachingResultsBuilderTest.php
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/87/398487/1

diff --git a/tests/phpunit/Api/CachingResultsBuilderTest.php 
b/tests/phpunit/Api/CachingResultsBuilderTest.php
index ff2e85a..f10b880 100644
--- a/tests/phpunit/Api/CachingResultsBuilderTest.php
+++ b/tests/phpunit/Api/CachingResultsBuilderTest.php
@@ -29,7 +29,7 @@
$resultsBuilder = $this->getMock( ResultsBuilder::class );
$resultsBuilder->expects( $this->once() )
->method( 'getResults' )
-   ->with( $this->equalTo( [ $q100 ] ), $this->equalTo( [] 
), $this->equalTo( null ) )
+   ->with( [ $q100 ], [], null )
->willReturn( $expectedResults );
$cachingResultsBuilder = new CachingResultsBuilder(
$resultsBuilder,
@@ -51,7 +51,7 @@
$resultsBuilder = $this->getMock( ResultsBuilder::class );
$resultsBuilder->expects( $this->once() )
->method( 'getResults' )
-   ->with( $this->equalTo( [] ), $this->equalTo( [ 'fake' 
] ), $this->equalTo( null ) )
+   ->with( [], [ 'fake' ], null )
->willReturn( $expectedResults );
$cache = $this->getMockBuilder( WANObjectCache::class )
->disableOriginalConstructor()
@@ -78,7 +78,7 @@
$resultsBuilder = $this->getMock( ResultsBuilder::class );
$resultsBuilder->expects( $this->once() )
->method( 'getResults' )
-   ->with( $this->equalTo( [ $q100 ] ), $this->equalTo( [] 
), $this->equalTo( [ 'fake' ] ) )
+   ->with( [ $q100 ], [], [ 'fake' ] )
->willReturn( $expectedResults );
$cache = $this->getMockBuilder( WANObjectCache::class )
->disableOriginalConstructor()
@@ -105,7 +105,7 @@
$resultsBuilder = $this->getMock( ResultsBuilder::class );
$resultsBuilder->expects( $this->once() )
->method( 'getResults' )
-   ->with( $this->equalTo( [ $q100 ] ), $this->equalTo( [] 
), $this->equalTo( null ) )
+   ->with( [ $q100 ], [], null )
->willReturn( $expectedResults );
$cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] 
);
$lookup = $this->getMock( EntityRevisionLookup::class );
@@ -149,7 +149,7 @@
$resultsBuilder = $this->getMock( ResultsBuilder::class );
$resultsBuilder->expects( $this->once() )
->method( 'getResults' )
-   ->with( $this->equalTo( [ $q100 ] ), $this->equalTo( [] 
), $this->equalTo( null ) )
+   ->with( [ $q100 ], [], null )
->willReturn( $expectedResults );
$cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] 
);
$lookup = $this->getMock( EntityRevisionLookup::class );

-- 
To view, visit https://gerrit.wikimedia.org/r/398487
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3a52ef280a76bf3c52e93f05bc7b81222d69d0af
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...TwoColConflict[master]: Reject non-editable pages in test page

2017-12-14 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398270 )

Change subject: Reject non-editable pages in test page
..

Reject non-editable pages in test page

If the content model of a page does not support direct editing (e. g. a
Structure Discussions topic page, a Wikibase item, etc.), attempting to
use it in Special:SimulateTwoColEditConflict will first expose the
internal serialized content, which the user should never need to see,
and then result in an MWException. To fix this, reject such pages.

Bug: T182668
Change-Id: I01abae3e9080a9dc51872d7975c1fc6a555edff8
---
M i18n/en.json
M i18n/qqq.json
M includes/SpecialConflictTestPage/SpecialConflictTestPage.php
M 
tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
4 files changed, 41 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TwoColConflict 
refs/changes/70/398270/1

diff --git a/i18n/en.json b/i18n/en.json
index e32f5d4..193b83c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -48,6 +48,7 @@
"twoColConflict-test-title-label": "Enter the title of a non-protected 
wiki page for which the edit conflict should be simulated:",
"twoColConflict-test-title-submit": "Show edit page",
"twoColConflict-test-title-not-existing": "There is no page with this 
title.",
+   "twoColConflict-test-no-direct-editing": "This page cannot be edited 
directly.",
"twoColConflict-test-text-submit": "Create conflict",
"twoColConflict-test-initial-hint": "On this page you can try out the 
new Two Column Edit Conflict interface without messing anything up.",
"twoColConflict-test-edit-hint": "Make some changes below. They won't 
be saved. They will only be used to simulate an example edit conflict.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index abdd0c6..d85d0d1 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -53,6 +53,7 @@
"twoColConflict-test-title-label": "Label for the conflict test page 
input box to load an article.",
"twoColConflict-test-title-submit": "Submit button on the conflict test 
page to load an article.",
"twoColConflict-test-title-not-existing": "Error message shown on the 
conflict test page when the submitted title does not exist.",
+   "twoColConflict-test-no-direct-editing": "Error message shown on the 
conflict test page when the submitted page's content model does not support 
direct editing (e.g. a Structured Discussions topic or a Wikibase item).",
"twoColConflict-test-text-submit": "Submit button on the conflict test 
page to submit changes creating a test conflict.",
"twoColConflict-test-initial-hint": "First hint shown on the conflict 
test page above the input field to load an article to experiment with.",
"twoColConflict-test-edit-hint": "Second hint shown on the conflict 
test page above the editor to make changes.",
diff --git a/includes/SpecialConflictTestPage/SpecialConflictTestPage.php 
b/includes/SpecialConflictTestPage/SpecialConflictTestPage.php
index fa536d7..a758e8a 100644
--- a/includes/SpecialConflictTestPage/SpecialConflictTestPage.php
+++ b/includes/SpecialConflictTestPage/SpecialConflictTestPage.php
@@ -56,6 +56,15 @@
}
 
$testArticle = Article::newFromTitle( $testTitle, 
$this->getContext() );
+
+   if ( 
!$testArticle->getContentHandler()->supportsDirectEditing() ) {
+   $this->showHintBox( ( new Message( 
'twoColConflict-test-initial-hint' ) )->parse() );
+
+   $this->showWarningBox( new Message( 
'twoColConflict-test-no-direct-editing' ) );
+   $this->showLoadTitle();
+   return;
+   }
+
if ( $request->getVal( 'mw-twocolconflict-test-text' ) === null 
) {
$this->showHintBox( ( new Message( 
'twoColConflict-test-edit-hint' ) )->parse() );
 
diff --git 
a/tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
 
b/tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
index 29f848f..3f4d507 100644
--- 
a/tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
+++ 
b/tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
@@ -2,6 +2,26 @@
 
 class SpecialConflictTestPageIntegrationTest extends SpecialPageTestBase {
 
+   protected function setUp() {
+   global $wgContLang;
+   parent::setUp();
+
+   // register a namespace with non-editable content model to test 
T182668
+   $this->mergeMwGlobalArrayValue( 'wgExtraNamespaces', [
+   12312 => 'Dummy',
+   12313 => 'Dummy_talk',
+   ] );
+   $this->mergeMwGlobalArrayValue( 'wgNamespaceContentModels', [

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Rename includes/ to src/

2017-12-14 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398261 )

Change subject: Rename includes/ to src/
..

Rename includes/ to src/

Git history details:

- `git blame` follows whole-file renames by default and therefore
  continues to work.

- `git log PATH`, by default, does not follow renames, so it won’t
  display history beyond this commit. You can change that with the
  --follow option (or by setting the config variable log.follow to true,
  either in this repository or globally). Unfortunately, that only works
  for a single path; to see the history for several files, both the old
  and new paths have to be specified, for example:

  git log -- {src,includes}/ConstraintCheck/Checker/

- `git shortlog` behaves like `git log`.

- `git diff` detects renames, since the default threshold for the
  similarity index (-M option) is 50%, and a full rename of the files as
  here means 100% similarity.

Change-Id: I2140df1fc7d65f8ead78626af277ed4e971b70bd
---
M README.md
M extension.json
M phpunit.xml.dist
R src/Api/CheckConstraintParameters.php
R src/Api/CheckConstraints.php
R src/CachingConstraintLookup.php
R src/Constraint.php
R src/ConstraintCheck/Api/CheckingResultsBuilder.php
R src/ConstraintCheck/Api/ResultsBuilder.php
R src/ConstraintCheck/Cache/CachedArray.php
R src/ConstraintCheck/Cache/CachedBool.php
R src/ConstraintCheck/Cache/CachedCheckConstraintsResponse.php
R src/ConstraintCheck/Cache/CachedEntityIds.php
R src/ConstraintCheck/Cache/CachedQueryResults.php
R src/ConstraintCheck/Cache/CachingMetadata.php
R src/ConstraintCheck/Checker/CommonsLinkChecker.php
R src/ConstraintCheck/Checker/ConflictsWithChecker.php
R src/ConstraintCheck/Checker/DiffWithinRangeChecker.php
R src/ConstraintCheck/Checker/FormatChecker.php
R src/ConstraintCheck/Checker/InverseChecker.php
R src/ConstraintCheck/Checker/ItemChecker.php
R src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
R src/ConstraintCheck/Checker/MultiValueChecker.php
R src/ConstraintCheck/Checker/OneOfChecker.php
R src/ConstraintCheck/Checker/QualifierChecker.php
R src/ConstraintCheck/Checker/QualifiersChecker.php
R src/ConstraintCheck/Checker/RangeChecker.php
R src/ConstraintCheck/Checker/ReferenceChecker.php
R src/ConstraintCheck/Checker/SingleValueChecker.php
R src/ConstraintCheck/Checker/SymmetricChecker.php
R src/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
R src/ConstraintCheck/Checker/TypeChecker.php
R src/ConstraintCheck/Checker/UniqueValueChecker.php
R src/ConstraintCheck/Checker/ValueOnlyChecker.php
R src/ConstraintCheck/Checker/ValueTypeChecker.php
R src/ConstraintCheck/ConstraintChecker.php
R src/ConstraintCheck/Context/AbstractContext.php
R src/ConstraintCheck/Context/ApiV2Context.php
R src/ConstraintCheck/Context/Context.php
R src/ConstraintCheck/Context/MainSnakContext.php
R src/ConstraintCheck/Context/QualifierContext.php
R src/ConstraintCheck/Context/ReferenceContext.php
R src/ConstraintCheck/DelegatingConstraintChecker.php
R src/ConstraintCheck/Helper/ConnectionCheckerHelper.php
R src/ConstraintCheck/Helper/ConstraintParameterException.php
R src/ConstraintCheck/Helper/ConstraintParameterParser.php
R src/ConstraintCheck/Helper/LoggingHelper.php
R src/ConstraintCheck/Helper/RangeCheckerHelper.php
R src/ConstraintCheck/Helper/SparqlHelper.php
R src/ConstraintCheck/Helper/SparqlHelperException.php
R src/ConstraintCheck/Helper/TypeCheckerHelper.php
R src/ConstraintCheck/Helper/ValueCountCheckerHelper.php
R src/ConstraintCheck/ItemIdSnakValue.php
R src/ConstraintCheck/Result/CheckResult.php
R src/ConstraintCheck/Result/NullResult.php
R src/ConstraintLookup.php
R src/ConstraintParameterRenderer.php
R src/ConstraintReportFactory.php
R src/ConstraintRepository.php
R src/Role.php
R src/Specials/SpecialConstraintReport.php
R src/UpdateConstraintsTableJob.php
R src/WikibaseQualityConstraintsHooks.php
63 files changed, 3 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/61/398261/1

diff --git a/README.md b/README.md
index 581d396..c0c3fa6 100644
--- a/README.md
+++ b/README.md
@@ -152,7 +152,7 @@
 To add a new constraint type, the following steps are necessary:
 
 * Define the constraint checker class.
-  * It should be defined in a new file in `includes/ConstraintCheck/Checker/`,
+  * It should be defined in a new file in `src/ConstraintCheck/Checker/`,
 named after the class name.
 It should be in the 
`WikibaseQuality\ConstraintReport\ConstraintCheck\Checker` namespace.
   * The class name should follow the constraint type name (in English), ending 
in “Checker”.
diff --git a/extension.json b/extension.json
index 64c5bdb..0cff846 100644
--- a/extension.json
+++ b/extension.json
@@ -375,7 +375,7 @@
}
},
"AutoloadNamespaces": {
-   "WikibaseQuality\\ConstraintReport\\": 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Move source code into includes/

2017-12-14 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398260 )

Change subject: Move source code into includes/
..

Move source code into includes/

The Api and Specials namespaces are moved from their own source
directories into the general includes/ directory.
WikibaseQualityConstraintsHooks.php is also moved into includes/
according to its namespace.

The Maintenance namespace stays in maintenance/, but is also removed
from the AutoloadNamespaces, because it never needs to be autoloaded
anyways.

Change-Id: I85f4f333a96051d50acc53bbe2a0b545bb1f9e01
---
M extension.json
R includes/Api/CheckConstraintParameters.php
R includes/Api/CheckConstraints.php
R includes/Specials/SpecialConstraintReport.php
R includes/WikibaseQualityConstraintsHooks.php
M phpunit.xml.dist
6 files changed, 1 insertion(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/60/398260/1

diff --git a/extension.json b/extension.json
index 00d52c7..64c5bdb 100644
--- a/extension.json
+++ b/extension.json
@@ -374,15 +374,9 @@
"public": true
}
},
-   "AutoloadClasses": {
-   
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks": 
"WikibaseQualityConstraintsHooks.php"
-   },
"AutoloadNamespaces": {
"WikibaseQuality\\ConstraintReport\\": "includes/",
-   "WikibaseQuality\\ConstraintReport\\Api\\": "api/",
-   "WikibaseQuality\\ConstraintReport\\Specials\\": "specials/",
-   "WikibaseQuality\\ConstraintReport\\Tests\\": "tests/phpunit/",
-   "WikibaseQuality\\ConstraintReport\\Maintenance\\": 
"maintenance/"
+   "WikibaseQuality\\ConstraintReport\\Tests\\": "tests/phpunit/"
},
"manifest_version": 2
 }
diff --git a/api/CheckConstraintParameters.php 
b/includes/Api/CheckConstraintParameters.php
similarity index 100%
rename from api/CheckConstraintParameters.php
rename to includes/Api/CheckConstraintParameters.php
diff --git a/api/CheckConstraints.php b/includes/Api/CheckConstraints.php
similarity index 100%
rename from api/CheckConstraints.php
rename to includes/Api/CheckConstraints.php
diff --git a/specials/SpecialConstraintReport.php 
b/includes/Specials/SpecialConstraintReport.php
similarity index 100%
rename from specials/SpecialConstraintReport.php
rename to includes/Specials/SpecialConstraintReport.php
diff --git a/WikibaseQualityConstraintsHooks.php 
b/includes/WikibaseQualityConstraintsHooks.php
similarity index 100%
rename from WikibaseQualityConstraintsHooks.php
rename to includes/WikibaseQualityConstraintsHooks.php
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index bf6b657..1797287 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -19,7 +19,6 @@
 
 
 includes
-specials
 maintenance
 
 

-- 
To view, visit https://gerrit.wikimedia.org/r/398260
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I85f4f333a96051d50acc53bbe2a0b545bb1f9e01
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Add messages for longer cache durations

2017-12-14 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398248 )

Change subject: Add messages for longer cache durations
..

Add messages for longer cache durations

If the max age is longer than 90 minutes (1½ hours), abbreviate it to
“hours”; if it’s older than 36 hours (1½ days), abbreviate it to “days”.

(The current getCachedMessage() will never call the “hours” and “days”
messages with a parameter of 1, but we still do the {{PLURAL}} handling
in there, both in case the implementation changes and to signal to
translators that they can use the template (in some languages “2 hours”
and “5 hours” use different plural forms).)

Change-Id: I71b3524ba184fcd2237dad796e074b3bf48082d4
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/gadget.js
4 files changed, 25 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/48/398248/1

diff --git a/extension.json b/extension.json
index 00d52c7..72d54c1 100644
--- a/extension.json
+++ b/extension.json
@@ -74,7 +74,9 @@
"wbqc-constrainttypehelp-short",
"wbqc-constrainttypehelp-long",
"wbqc-cached-generic",
-   "wbqc-cached-minutes"
+   "wbqc-cached-minutes",
+   "wbqc-cached-hours",
+   "wbqc-cached-days"
],
"scripts": [
"modules/ui/module.js",
diff --git a/i18n/en.json b/i18n/en.json
index 2d9a5db..fbd6779 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -44,6 +44,8 @@
"wbqc-constrainttypehelp-long": "Help page for this constraint type",
"wbqc-cached-generic": "This result is cached and might be out of 
date.",
"wbqc-cached-minutes": "This result is cached and might be out of date 
by up to {{PLURAL:$1|1=one minute|$1minutes}}.",
+   "wbqc-cached-hours": "This result is cached and might be out of date by 
up to {{PLURAL:$1|1=one hour|$1hours}}.",
+   "wbqc-cached-days": "This result is cached and might be out of date by 
up to {{PLURAL:$1|1=one day|$1days}}.",
 
"apihelp-wbcheckconstraints-description": "Performs constraint checks 
on any entity you want and returns the result.",
"apihelp-wbcheckconstraints-summary": "Performs constraint checks on 
any entity you want and returns the result.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 5189171..2178bb2 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -46,6 +46,8 @@
"wbqc-constrainttypehelp-long": "Title for the help link shown next to 
the constraint type in a constraint violation report. The link leads to a help 
page on Wikidata about the constraint 
type.\n{{Related|wbqc-constrainttypehelp-short}}",
"wbqc-cached-generic": "Generic message informing the user that a 
constraint check result might be outdated. There is no information on how old 
the cached result is; if more information is available, a more specific message 
is used.",
"wbqc-cached-minutes": "Message informing the user that a constraint 
check result might be outdated by up to ''n'' 
minutes.\n{{Related|wbqc-cached-generic}}",
+   "wbqc-cached-hours": "Message informing the user that a constraint 
check result might be outdated by up to ''n'' 
hours.\n{{Related|wbqc-cached-minutes}}\n{{Related|wbqc-cached-generic}}",
+   "wbqc-cached-days": "Message informing the user that a constraint check 
result might be outdated by up to ''n'' 
days.\n{{Related|wbqc-cached-minutes}}\n{{Related|wbqc-cached-generic}}",
"apihelp-wbcheckconstraints-description": 
"{{doc-apihelp-description|wbcheckconstraints}}",
"apihelp-wbcheckconstraints-summary": 
"{{doc-apihelp-summary|wbcheckconstraints}}",
"apihelp-wbcheckconstraints-param-id": 
"{{doc-apihelp-param|wbcheckconstraints|id}}",
diff --git a/modules/gadget.js b/modules/gadget.js
index 9b5cc74..b368d6e 100644
--- a/modules/gadget.js
+++ b/modules/gadget.js
@@ -25,11 +25,25 @@
}
 
function getCachedMessage( cached ) {
-   var maximumAgeInMinutes;
+   var maximumAgeInMinutes,
+   maximumAgeInHours,
+   maximumAgeInDays;
if ( typeof cached === 'object' && cached.maximumAgeInSeconds ) 
{
-   maximumAgeInMinutes = Math.ceil( 
cached.maximumAgeInSeconds / 60 );
-   return mw.message( 'wbqc-cached-minutes' )
-   .params( [ maximumAgeInMinutes ] )
+   if ( cached.maximumAgeInSeconds < 60 * 90 ) {
+   maximumAgeInMinutes = Math.ceil( 
cached.maximumAgeInSeconds / 60 );
+   return mw.message( 

  1   2   3   4   5   6   7   >