Jeroen De Dauw has submitted this change and it was merged. Change subject: Drop/replace some pointless assert() ......................................................................
Drop/replace some pointless assert() This is related to the planned HHVM switch. assert() depends on a setting and may do nothing. I think most of these assert() are more confusing than helpful. Change-Id: I19044396ba8d6c8046aee465b505efa06ebbb140 --- M lib/includes/SnakFactory.php M lib/includes/changes/ChangeRow.php M lib/includes/formatters/EntityIdLabelFormatter.php M lib/includes/store/CachingPropertyInfoStore.php M repo/includes/LinkedData/EntityDataRequestHandler.php M repo/includes/api/EditEntity.php M repo/includes/rdf/RdfBuilder.php M repo/includes/rdf/RdfSerializer.php 8 files changed, 21 insertions(+), 32 deletions(-) Approvals: Jeroen De Dauw: Looks good to me, approved diff --git a/lib/includes/SnakFactory.php b/lib/includes/SnakFactory.php index d6a59b1..1f3e8db 100644 --- a/lib/includes/SnakFactory.php +++ b/lib/includes/SnakFactory.php @@ -50,9 +50,6 @@ throw new InvalidArgumentException( "bad snak type: $snakType" ); } - assert( isset( $snak ) ); - assert( $snak instanceof Snak ); - return $snak; } diff --git a/lib/includes/changes/ChangeRow.php b/lib/includes/changes/ChangeRow.php index c14e196..cfb5b51 100644 --- a/lib/includes/changes/ChangeRow.php +++ b/lib/includes/changes/ChangeRow.php @@ -187,8 +187,6 @@ protected function getInfo( $cache = 'no' ) { $info = $this->getField( 'info' ); - assert( !is_string( $info ) ); - if ( !is_array( $info ) ) { $info = array(); } @@ -278,4 +276,5 @@ return $info; } + } diff --git a/lib/includes/formatters/EntityIdLabelFormatter.php b/lib/includes/formatters/EntityIdLabelFormatter.php index f108ebb..d7e242b 100644 --- a/lib/includes/formatters/EntityIdLabelFormatter.php +++ b/lib/includes/formatters/EntityIdLabelFormatter.php @@ -110,7 +110,6 @@ } } - assert( is_string( $label ) ); return $label; } diff --git a/lib/includes/store/CachingPropertyInfoStore.php b/lib/includes/store/CachingPropertyInfoStore.php index 4b19dfc..d2e0074 100644 --- a/lib/includes/store/CachingPropertyInfoStore.php +++ b/lib/includes/store/CachingPropertyInfoStore.php @@ -107,7 +107,6 @@ } } - assert( is_array( $this->propertyInfo ) ); return $this->propertyInfo; } @@ -184,4 +183,5 @@ return true; } -} \ No newline at end of file + +} diff --git a/repo/includes/LinkedData/EntityDataRequestHandler.php b/repo/includes/LinkedData/EntityDataRequestHandler.php index 2dc3a78..82c467d 100644 --- a/repo/includes/LinkedData/EntityDataRequestHandler.php +++ b/repo/includes/LinkedData/EntityDataRequestHandler.php @@ -198,16 +198,12 @@ if ( $format === null || $format === '' ) { // if no format is given, apply content negotiation and return. - $this->httpContentNegotiation( $request, $output, $entityId, $revision ); return; - } else { - //NOTE: will trigger a 415 if the format is not supported - $format = $this->getCanonicalFormat( $format ); } - // we should know the format now. - assert( $format !== null && $format !== '' ); + //NOTE: will trigger a 415 if the format is not supported + $format = $this->getCanonicalFormat( $format ); if ( $doc !== null && $doc !== '' ) { // if subpage syntax is used, always enforce the canonical form diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php index c71a492..dad4565 100644 --- a/repo/includes/api/EditEntity.php +++ b/repo/includes/api/EditEntity.php @@ -496,18 +496,19 @@ foreach ( $claims as $claimArray ) { if( !array_key_exists( 'remove', $claimArray ) ){ - try { $claim = $unserializer->newFromSerialization( $claimArray ); - assert( $claim instanceof Claim ); - } catch ( IllegalValueException $illegalValueException ) { - $this->dieException( $illegalValueException, 'invalid-claim' ); - } catch ( MWException $mwException ) { - $this->dieException( $mwException, 'invalid-claim' ); - } - /** @var $claim Claim */ - $opsToReturn[] = $this->claimChangeOpFactory->newSetClaimOp( $claim ); + if ( !( $claim instanceof Claim ) ) { + throw new IllegalValueException( 'Claim serialization did not contained a Claim.' ); + } + + $opsToReturn[] = $this->claimChangeOpFactory->newSetClaimOp( $claim ); + } catch ( IllegalValueException $ex ) { + $this->dieException( $ex, 'invalid-claim' ); + } catch ( MWException $ex ) { + $this->dieException( $ex, 'invalid-claim' ); + } } } return $opsToReturn; diff --git a/repo/includes/rdf/RdfBuilder.php b/repo/includes/rdf/RdfBuilder.php index 443e5d4..bbacdd9 100644 --- a/repo/includes/rdf/RdfBuilder.php +++ b/repo/includes/rdf/RdfBuilder.php @@ -444,13 +444,11 @@ switch ( $typeId ) { case 'wikibase-item': - $rawValue = $value->getValue(); - - assert( $rawValue instanceof EntityId ); - $valueQName = $this->getEntityQName( self::NS_ENTITY, $rawValue ); - $valueResource = $this->graph->resource( $valueQName ); - $statementResource->addResource( $propertyValueQName, $valueResource ); - $this->entityMentioned( $rawValue ); + $entityId = $value->getValue(); + $entityQName = $this->getEntityQName( self::NS_ENTITY, $entityId ); + $entityResource = $this->graph->resource( $entityQName ); + $statementResource->addResource( $propertyValueQName, $entityResource ); + $this->entityMentioned( $entityId ); break; case 'commonsMedia': $statementResource->addResource( $propertyValueQName, $value ); @@ -510,4 +508,5 @@ $this->addLabels( $entity ); $this->addDescriptions( $entity ); } + } diff --git a/repo/includes/rdf/RdfSerializer.php b/repo/includes/rdf/RdfSerializer.php index c738c6f..630ceee 100644 --- a/repo/includes/rdf/RdfSerializer.php +++ b/repo/includes/rdf/RdfSerializer.php @@ -143,8 +143,6 @@ public function serializeRdf( EasyRdf_Graph $graph ) { $serialiser = $this->format->newSerialiser(); $data = $serialiser->serialise( $graph, $this->format->getName() ); - - assert( is_string( $data ) ); return $data; } -- To view, visit https://gerrit.wikimedia.org/r/155247 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I19044396ba8d6c8046aee465b505efa06ebbb140 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits