Addshore has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/73978


Change subject: Adding missing wfProfileOut() s to api modules
......................................................................

Adding missing wfProfileOut() s to api modules

Change-Id: I6acf7e53e31ebaaaecf1d31dd7eab25dddafbded
---
M repo/includes/api/ApiWikibase.php
M repo/includes/api/CreateClaim.php
M repo/includes/api/EditEntity.php
M repo/includes/api/GetClaims.php
M repo/includes/api/ModifyEntity.php
M repo/includes/api/RemoveClaims.php
M repo/includes/api/RemoveQualifiers.php
M repo/includes/api/RemoveReferences.php
M repo/includes/api/SetAliases.php
M repo/includes/api/SetClaim.php
M repo/includes/api/SetClaimValue.php
M repo/includes/api/SetQualifier.php
M repo/includes/api/SetReference.php
M repo/includes/api/SetSiteLink.php
M repo/includes/api/SetStatementRank.php
M repo/includes/api/SnakValidationHelper.php
16 files changed, 83 insertions(+), 0 deletions(-)


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

diff --git a/repo/includes/api/ApiWikibase.php 
b/repo/includes/api/ApiWikibase.php
index 76ae393..9eae6e2 100644
--- a/repo/includes/api/ApiWikibase.php
+++ b/repo/includes/api/ApiWikibase.php
@@ -402,10 +402,12 @@
                        $revision = \Revision::newFromId( $revId );
 
                        if ( !$revision ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( "Revision not found: $revId", 
'nosuchrevid' );
                        }
 
                        if ( $revision->getPage() != $title->getArticleID() ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( "Revision $revId does not 
belong to " .
                                        $title->getPrefixedDBkey(), 
'nosuchrevid' );
                        }
@@ -414,6 +416,7 @@
                }
 
                if ( is_null( $content ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "Can't access item content of " .
                                $title->getPrefixedDBkey() .
                                ", revision may have been deleted.", 
'cant-load-entity-content' );
diff --git a/repo/includes/api/CreateClaim.php 
b/repo/includes/api/CreateClaim.php
index e5027e1..1218e70 100644
--- a/repo/includes/api/CreateClaim.php
+++ b/repo/includes/api/CreateClaim.php
@@ -198,14 +198,17 @@
        protected function validateParameters( array $params ) {
                if ( $params['snaktype'] == 'value' XOR isset( $params['value'] 
) ) {
                        if ( $params['snaktype'] == 'value' ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'A value needs to be provided 
when creating a claim with PropertyValueSnak snak', 'param-missing' );
                        }
                        else {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'You cannot provide a value 
when creating a claim with no PropertyValueSnak as main snak', 'param-illegal' 
);
                        }
                }
 
                if ( !isset( $params['property'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'A property ID needs to be provided 
when creating a claim with a Snak', 'param-missing' );
                }
        }
@@ -225,6 +228,7 @@
                $entityContent = $entityTitle === null ? null : 
$this->loadEntityContent( $entityTitle, $baseRevisionId );
 
                if ( $entityContent === null ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Entity not found, snak not created', 
'no-such-entity' );
                }
 
@@ -251,6 +255,7 @@
                $entityId = $entityIdParser->parse( $params['property'] );
 
                if ( $entityId->getEntityType() !== Property::ENTITY_TYPE ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Property expected, got ' . 
$entityId->getEntityType(), 'invalid-snak' );
                }
 
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 9cef820..165ed7c 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -67,6 +67,7 @@
         */
        protected function createEntity( array $params ) {
                if ( !isset( $params['new'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "Either 'id' or 'new' parameter has to 
be set", 'no-such-entity' );
                }
 
@@ -76,6 +77,7 @@
                try {
                        return $entityContentFactory->newFromType( $type );
                } catch ( InvalidArgumentException $e ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "No such entity type: '$type'", 
'no-such-entity-type' );
                }
        }
@@ -86,12 +88,15 @@
        protected function validateParameters( array $params ) {
                // note that this is changed back and could fail
                if ( !( isset( $params['data'] ) OR  isset( $params['id'] ) XOR 
( isset( $params['site'] ) && isset( $params['title'] ) ) ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Either provide the item "id" or pairs 
of "site" and "title" for a corresponding page, or "data" for a new item', 
'param-missing' );
                }
                if ( isset( $params['id'] ) && isset( $params['new'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "Parameter 'id' and 'new' are not 
allowed to be both set in the same request", 'param-illegal' );
                }
                if ( !isset( $params['id'] ) && !isset( $params['new'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "Either 'id' or 'new' parameter has to 
be set", 'no-such-entity' );
                }
        }
@@ -131,6 +136,7 @@
                // if we create a new property, make sure we set the datatype
                if ( $entityContent->isNew() && $entity->getType() === 
Property::ENTITY_TYPE ) {
                        if ( !isset( $data['datatype'] ) ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'No datatype given', 
'param-illegal' );
                        } else {
                                $entity->setDataTypeId( $data['datatype'] );
@@ -397,10 +403,12 @@
 
                foreach ( $data as $prop => $args ) {
                        if ( !is_string( $prop ) ) { // NOTE: catch json_decode 
returning an indexed array (list)
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'Top level structure must be a 
JSON object', 'not-recognized-string' );
                        }
 
                        if ( !in_array( $prop, $allowedProps ) ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( "unknown key: $prop", 
'not-recognized' );
                        }
                }
@@ -538,20 +546,25 @@
        public function checkMultilangArgs( $arg, $langCode ) {
                $status = Status::newGood();
                if ( !is_array( $arg ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'An array was expected, but not found' 
, 'not-recognized-array' );
                }
                if ( !is_string( $arg['language'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'A string was expected, but not found' 
, 'not-recognized-string' );
                }
                if ( !is_numeric( $langCode ) ) {
                        if ( $langCode !== $arg['language'] ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( "inconsistent language: 
{$langCode} is not equal to {$arg['language']}", 'inconsistent-language' );
                        }
                }
                if ( isset( $this->validLanguageCodes ) && !array_key_exists( 
$arg['language'], $this->validLanguageCodes ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "unknown language: 
{$arg['language']}", 'not-recognized-language' );
                }
                if ( !is_string( $arg['value'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'A string was expected, but not found' 
, 'not-recognized-string' );
                }
                return $status;
@@ -569,20 +582,25 @@
        public function checkSiteLinks( $arg, $siteCode, SiteList &$sites = 
null ) {
                $status = Status::newGood();
                if ( !is_array( $arg ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'An array was expected, but not found' 
, 'not-recognized-array' );
                }
                if ( !is_string( $arg['site'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'A string was expected, but not found' 
, 'not-recognized-string' );
                }
                if ( !is_numeric( $siteCode ) ) {
                        if ( $siteCode !== $arg['site'] ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( "inconsistent site: 
{$siteCode} is not equal to {$arg['site']}", 'inconsistent-site' );
                        }
                }
                if ( isset( $sites ) && !$sites->hasSite( $arg['site'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "unknown site: {$arg['site']}", 
'not-recognized-site' );
                }
                if ( !is_string( $arg['title'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'A string was expected, but not found' 
, 'not-recognized-string' );
                }
                return $status;
diff --git a/repo/includes/api/GetClaims.php b/repo/includes/api/GetClaims.php
index 68ca8cc..29dc48c 100644
--- a/repo/includes/api/GetClaims.php
+++ b/repo/includes/api/GetClaims.php
@@ -67,6 +67,7 @@
                $entity = $entityId ? $this->getEntity( $entityId ) : null;
 
                if ( !$entity ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "No entity found matching ID $id", 
'no-such-entity' );
                }
 
@@ -120,6 +121,7 @@
                $content = EntityContentFactory::singleton()->getFromId( $id );
 
                if ( $content === null ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'The specified entity does not exist, 
so it\'s claims cannot be obtained', 'no-such-entity' );
                }
 
@@ -179,6 +181,7 @@
                $params = $this->extractRequestParams();
 
                if ( !isset( $params['entity'] ) && !isset( $params['claim'] ) 
) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Either the entity parameter or the 
key parameter need to be set', 'param-missing' );
                }
 
@@ -190,6 +193,7 @@
                $claimGuidValidator = new ClaimGuidValidator( $entityPrefixes );
 
                if ( isset( $params['claim'] ) && 
$claimGuidValidator->validateFormat( $params['claim'] ) === false ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
                }
 
@@ -197,6 +201,7 @@
                        $entityId = Entity::getIdFromClaimGuid( 
$params['claim'] );
 
                        if ( $entityId !== $params['entity'] ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'If both entity id and claim 
key are provided they need to point to the same entity', 'param-illegal' );
                        }
                }
diff --git a/repo/includes/api/ModifyEntity.php 
b/repo/includes/api/ModifyEntity.php
index c502826..62aca3a 100644
--- a/repo/includes/api/ModifyEntity.php
+++ b/repo/includes/api/ModifyEntity.php
@@ -86,6 +86,7 @@
                        $entityTitle = $entityId ? 
$entityContentFactory->getTitleForId( $entityId, \Revision::FOR_THIS_USER ) : 
null;
 
                        if ( is_null( $entityTitle ) ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( "No entity found matching ID 
$id", 'no-such-entity-id' );
                        }
                }
@@ -100,6 +101,7 @@
                        );
 
                        if ( is_null( $entityTitle ) ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'No entity found matching site 
link ' . $params['site'] . ':' . $params['title'] , 'no-such-entity-link' );
                        }
                } else {
@@ -110,6 +112,7 @@
                $entityContent = $this->loadEntityContent( $entityTitle, 
$baseRevisionId );
 
                if ( is_null( $entityContent ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "Can't access item content of " . 
$entityTitle->getPrefixedDBkey() . ", revision may have been deleted.", 
'no-such-entity' );
                }
 
@@ -127,6 +130,7 @@
         * @return \Wikibase\EntityContent Newly created entity
         */
        protected function createEntity( array $params ) {
+               wfProfileOut( __METHOD__ );
                $this->dieUsage( 'Could not find an existing entity' , 
'no-such-entity' );
        }
 
@@ -165,6 +169,7 @@
        protected function validateParameters( array $params ) {
                // note that this is changed back and could fail
                if ( !( isset( $params['id'] ) XOR ( isset( $params['site'] ) 
&& isset( $params['title'] ) ) ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Either provide the item "id" or pairs 
of "site" and "title" for a corresponding page' , 'param-illegal' );
                }
        }
diff --git a/repo/includes/api/RemoveClaims.php 
b/repo/includes/api/RemoveClaims.php
index ccc6da2..79129a5 100644
--- a/repo/includes/api/RemoveClaims.php
+++ b/repo/includes/api/RemoveClaims.php
@@ -159,6 +159,7 @@
 
                                $guids[$entityId][] = $guid;
                        } else {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'Invalid claim guid' , 
'invalid-guid' );
                        }
                }
@@ -218,6 +219,7 @@
                        $entityId = EntityId::newFromPrefixedId( $id );
 
                        if ( $entityId === null ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'Invalid entity id provided', 
'no-such-entity' );
                        }
 
@@ -226,6 +228,7 @@
                        $content = $this->loadEntityContent( $entityTitle, 
$baseRevisionId );
 
                        if ( $content === null ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( "The specified entity does not 
exist, so it's claims cannot be obtained", 'no-such-entity' );
                        }
 
diff --git a/repo/includes/api/RemoveQualifiers.php 
b/repo/includes/api/RemoveQualifiers.php
index a88ca43..ccf78c5 100644
--- a/repo/includes/api/RemoveQualifiers.php
+++ b/repo/includes/api/RemoveQualifiers.php
@@ -79,6 +79,7 @@
                $claimGuidValidator = new ClaimGuidValidator( $entityPrefixes );
 
                if ( !( $claimGuidValidator->validateFormat( $params['claim'] ) 
) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
                }
 
@@ -86,6 +87,7 @@
                $entityTitle = 
EntityContentFactory::singleton()->getTitleForId( $entityId );
 
                if ( $entityTitle === null ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find an existing entity' , 
'no-such-entity' );
                }
 
@@ -109,6 +111,7 @@
                foreach ( array_unique( $params['qualifiers'] ) as 
$qualifierHash ) {
                        if ( !$qualifiers->hasSnakHash( $qualifierHash ) ) {
                                // TODO: does $qualifierHash need to be escaped?
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'There is no qualifier with 
hash ' . $qualifierHash, 'no-such-qualifier' );
                        }
 
@@ -128,6 +131,7 @@
                $claims = new Claims( $entity->getClaims() );
 
                if ( !$claims->hasClaimWithGuid( $claimGuid ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find a claim with that 
guid', 'no-such-claim' );
                }
 
diff --git a/repo/includes/api/RemoveReferences.php 
b/repo/includes/api/RemoveReferences.php
index b7722ed..2a62a86 100644
--- a/repo/includes/api/RemoveReferences.php
+++ b/repo/includes/api/RemoveReferences.php
@@ -89,6 +89,7 @@
                $claimGuidValidator = new ClaimGuidValidator( $entityPrefixes );
 
                if ( !( $claimGuidValidator->validateFormat( 
$params['statement'] ) ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
                }
 
@@ -96,6 +97,7 @@
                $entityTitle = 
EntityContentFactory::singleton()->getTitleForId( $entityId );
 
                if ( $entityTitle === null ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find an existing entity' , 
'no-such-entity' );
                }
 
@@ -115,12 +117,14 @@
                $claims = new Claims( $entity->getClaims() );
 
                if ( !$claims->hasClaimWithGuid( $statementGuid ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find the claim' , 
'no-such-claim' );
                }
 
                $statement = $claims->getClaimWithGuid( $statementGuid );
 
                if ( ! ( $statement instanceof Statement ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'The referenced claim is not a 
statement and thus cannot have references', 'not-statement' );
                }
 
@@ -136,6 +140,7 @@
                        }
                        else {
                                // TODO: does $refHash need to be escaped 
somehow?
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'The statement does not have 
any associated reference with the provided reference hash "' . $refHash . '"', 
'no-such-reference' );
                        }
                }
diff --git a/repo/includes/api/SetAliases.php b/repo/includes/api/SetAliases.php
index 622e1b9..f0473da 100644
--- a/repo/includes/api/SetAliases.php
+++ b/repo/includes/api/SetAliases.php
@@ -49,6 +49,7 @@
                parent::validateParameters( $params );
 
                if ( !( ( !empty( $params['add'] ) || !empty( $params['remove'] 
) ) xor isset( $params['set'] ) ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Invalid-list' , 'invalid-list' );
                }
        }
@@ -57,6 +58,7 @@
         * @see ApiModifyEntity::createEntity()
         */
        protected function createEntity( array $params ) {
+               wfProfileOut( __METHOD__ );
                $this->dieUsage( 'Could not find an existing entity' , 
'no-such-entity' );
        }
 
diff --git a/repo/includes/api/SetClaim.php b/repo/includes/api/SetClaim.php
index 06512b3..4152559 100644
--- a/repo/includes/api/SetClaim.php
+++ b/repo/includes/api/SetClaim.php
@@ -139,6 +139,7 @@
                        assert( $claim instanceof Claim );
                        return $claim;
                } catch ( IllegalValueException $illegalValueException ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( $illegalValueException->getMessage(), 
'invalid-claim' );
                }
        }
diff --git a/repo/includes/api/SetClaimValue.php 
b/repo/includes/api/SetClaimValue.php
index 9f79964..02adba7 100644
--- a/repo/includes/api/SetClaimValue.php
+++ b/repo/includes/api/SetClaimValue.php
@@ -110,6 +110,7 @@
                $claimGuidValidator = new ClaimGuidValidator( $entityPrefixes );
 
                if ( !( $claimGuidValidator->validate( $params['claim'] ) ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
                }
 
@@ -117,6 +118,7 @@
                $entityTitle = 
EntityContentFactory::singleton()->getTitleForId( $entityId );
 
                if ( $entityTitle === null ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'No such entity' , 'no-such-entity' );
                }
 
@@ -142,6 +144,7 @@
                $claims = new Claims( $entity->getClaims() );
 
                if ( !$claims->hasClaimWithGuid( $guid ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'No such claim' , 'no-such-claim' );
                }
 
@@ -156,6 +159,7 @@
                        $content = 
EntityContentFactory::singleton()->getFromId( 
$claim->getMainSnak()->getPropertyId() );
 
                        if ( $content === null ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'The value cannot be 
interpreted since the property cannot be found, and thus the type of the value 
not be determined', 'no-such-property' );
                        }
 
@@ -174,6 +178,7 @@
 
                        return $claim;
                } catch ( IllegalValueException $ex ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( $ex->getMessage(), 'invalid-snak' );
                }
        }
diff --git a/repo/includes/api/SetQualifier.php 
b/repo/includes/api/SetQualifier.php
index d92999a..0d733bd 100644
--- a/repo/includes/api/SetQualifier.php
+++ b/repo/includes/api/SetQualifier.php
@@ -117,15 +117,18 @@
                //@todo addshore all of these errors should be more general
                if ( !isset( $params['snakhash'] ) ) {
                        if ( !isset( $params['snaktype'] ) ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'When creating a new qualifier 
(ie when not providing a snakhash) a snaktype should be specified', 
'param-missing' );
                        }
 
                        if ( !isset( $params['property'] ) ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'When creating a new qualifier 
(ie when not providing a snakhash) a property should be specified', 
'param-missing' );
                        }
                }
 
                if ( isset( $params['snaktype'] ) && $params['snaktype'] === 
'value' && !isset( $params['value'] ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'When setting a qualifier that is a 
PropertyValueSnak, the value needs to be provided', 'param-missing' );
                }
        }
@@ -144,6 +147,7 @@
                $claimGuidValidator = new ClaimGuidValidator( $entityPrefixes );
 
                if ( !( $claimGuidValidator->validate( $params['claim'] ) ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
                }
 
@@ -151,6 +155,7 @@
                $entityTitle = 
EntityContentFactory::singleton()->getTitleForId( $entityId );
 
                if ( $entityTitle === null ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find the entity' , 
'no-such-entity' );
                }
 
@@ -174,6 +179,7 @@
                $claims = new \Wikibase\Claims( $entity->getClaims() );
 
                if ( !$claims->hasClaimWithGuid( $claimGuid ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find the claim' , 
'no-such-claim' );
                }
 
@@ -214,6 +220,7 @@
         */
        protected function updateQualifier( Snaks $qualifiers, $snakHash ) {
                if ( !$qualifiers->hasSnakHash( $snakHash ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find the qualifier' , 
'no-such-qualifier' );
                }
 
@@ -248,6 +255,7 @@
                } catch ( IllegalValueException $illegalValueException ) {
                        //Note: This handles failures during snak 
instantiation, not validation.
                        //      Validation errors are handled by the validation 
helper.
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( $illegalValueException->getMessage(), 
'invalid-snak' );
                }
 
@@ -261,11 +269,13 @@
                        $entityId = $entityIdParser->parse( $prefixedId );
 
                        if ( $entityId->getEntityType() !== 
Property::ENTITY_TYPE ) {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'Not a property: ' . 
$prefixedId, $errorCode );
                                return null;
                        }
                }
                catch ( ParseException $parseException ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( $parseException->getMessage(), 
$errorCode );
                        return null;
                }
@@ -280,6 +290,7 @@
         */
        protected function newSnak( EntityId $propertyId, $snakType, $valueData 
) {
                if ( $propertyId->getEntityType() !== Property::ENTITY_TYPE ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( "Property expected, got " . 
$propertyId->getEntityType(), 'invalid-snak' );
                }
 
@@ -317,6 +328,7 @@
 
                        return $qualifiers->addSnak( $newQualifier );
                } catch ( IllegalValueException $illegalValueException ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( $illegalValueException->getMessage(), 
'invalid-snak' );
                }
 
diff --git a/repo/includes/api/SetReference.php 
b/repo/includes/api/SetReference.php
index 311837f..880b77f 100644
--- a/repo/includes/api/SetReference.php
+++ b/repo/includes/api/SetReference.php
@@ -113,18 +113,21 @@
                $claimGuidValidator = new ClaimGuidValidator( $entityPrefixes );
 
                if ( !( $claimGuidValidator->validate( $params['statement'] ) ) 
) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
                }
 
                $entityId = EntityId::newFromPrefixedId( 
Entity::getIdFromClaimGuid( $params['statement'] ) );
 
                if ( $entityId === null ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find an existing entity' , 
'no-such-entity' );
                }
 
                $entityTitle = 
EntityContentFactory::singleton()->getTitleForId( $entityId );
 
                if ( $entityTitle === null ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find an existing entity' , 
'no-such-entity' );
                }
 
@@ -144,6 +147,7 @@
                $rawSnaks = \FormatJson::decode( $rawSnaks, true );
 
                if ( !is_array( $rawSnaks ) || !count( $rawSnaks ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'No snaks or invalid JSON given', 
'invalid-json' );
                }
 
@@ -155,6 +159,7 @@
                try {
                        foreach ( $rawSnaks as $byPropertySnaks ) {
                                if ( !is_array( $byPropertySnaks ) ) {
+                                       wfProfileOut( __METHOD__ );
                                        $this->dieUsage( 'Invalid snak JSON 
given', 'invalid-json' );
                                }
                                foreach ( $byPropertySnaks as $rawSnak ) {
@@ -165,6 +170,7 @@
                        }
                } catch ( IllegalValueException $ex ) {
                        // Handle Snak instantiation failures
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Invalid snak JSON given. 
IllegalValueException', 'invalid-json' );
                }
 
@@ -185,12 +191,14 @@
                $claims = new Claims( $entity->getClaims() );
 
                if ( !$claims->hasClaimWithGuid( $statementGuid ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find the statement' , 
'no-such-statement' );
                }
 
                $statement = $claims->getClaimWithGuid( $statementGuid );
 
                if ( ! ( $statement instanceof Statement ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'The referenced claim is not a 
statement and thus cannot have references', 'not-statement' );
                }
 
@@ -206,6 +214,7 @@
                                $references->removeReferenceHash( $refHash );
                        }
                        else {
+                               wfProfileOut( __METHOD__ );
                                $this->dieUsage( 'The statement does not have 
any associated reference with the provided reference hash', 'no-such-reference' 
);
                        }
                }
diff --git a/repo/includes/api/SetSiteLink.php 
b/repo/includes/api/SetSiteLink.php
index eacc13e..4aaf525 100644
--- a/repo/includes/api/SetSiteLink.php
+++ b/repo/includes/api/SetSiteLink.php
@@ -47,6 +47,7 @@
 
                // If we found anything then check if it is of the correct base 
class
                if ( !is_null( $entityContent ) && !( $entityContent instanceof 
ItemContent ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'The content on the found page is not 
of correct type', 'wrong-class' );
                }
 
diff --git a/repo/includes/api/SetStatementRank.php 
b/repo/includes/api/SetStatementRank.php
index 0cb39ea..d311548 100644
--- a/repo/includes/api/SetStatementRank.php
+++ b/repo/includes/api/SetStatementRank.php
@@ -92,6 +92,7 @@
                $claimGuidValidator = new ClaimGuidValidator( $entityPrefixes );
 
                if ( !( $claimGuidValidator->validate( $params['statement'] ) ) 
) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
                }
 
@@ -99,6 +100,7 @@
                $entityTitle = 
EntityContentFactory::singleton()->getTitleForId( $entityId );
 
                if ( $entityTitle === null ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find an existing entity' , 
'no-such-entity' );
                }
 
@@ -120,12 +122,14 @@
                $claims = new \Wikibase\Claims( $entity->getClaims() );
 
                if ( !$claims->hasClaimWithGuid( $statementGuid ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'Could not find the statement' , 
'no-such-statement' );
                }
 
                $statement = $claims->getClaimWithGuid( $statementGuid );
 
                if ( ! ( $statement instanceof Statement ) ) {
+                       wfProfileOut( __METHOD__ );
                        $this->dieUsage( 'The referenced claim is not a 
statement and thus does not have a rank' , 'not-statement' );
                }
 
diff --git a/repo/includes/api/SnakValidationHelper.php 
b/repo/includes/api/SnakValidationHelper.php
index f5d735b..fab42ab 100644
--- a/repo/includes/api/SnakValidationHelper.php
+++ b/repo/includes/api/SnakValidationHelper.php
@@ -140,6 +140,7 @@
                        $this->apiModule->handleStatus( $status, 
'invalid-snak-value' );
                } else {
                        $errorText = $status->getWikiText();
+                       wfProfileOut( __METHOD__ );
                        $this->apiModule->dieUsage( $errorText, 
'invalid-snak-value' );
                }
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6acf7e53e31ebaaaecf1d31dd7eab25dddafbded
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to