Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/223563
Change subject: Avoid a little bit of code duplication in EntityContent classes ...................................................................... Avoid a little bit of code duplication in EntityContent classes Bug: T104895 Change-Id: I0f0342b4609e5d8da968f59cb5343e1fc8531556 --- M repo/includes/content/EntityContent.php M repo/includes/content/ItemContent.php M repo/includes/content/PropertyContent.php 3 files changed, 10 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/63/223563/1 diff --git a/repo/includes/content/EntityContent.php b/repo/includes/content/EntityContent.php index 7323170..55c0531 100644 --- a/repo/includes/content/EntityContent.php +++ b/repo/includes/content/EntityContent.php @@ -292,7 +292,6 @@ $output = $outputGenerator->getParserOutput( $entityRevision, $options, $generateHtml ); - // register page properties $this->applyEntityPageProperties( $output ); return $output; @@ -726,8 +725,11 @@ * @param ParserOutput $output */ private function applyEntityPageProperties( ParserOutput $output ) { - $properties = $this->getEntityPageProperties(); + if ( $this->isRedirect() ) { + return; + } + $properties = $this->getEntityPageProperties(); foreach ( $properties as $name => $value ) { $output->setProperty( $name, $value ); } @@ -745,13 +747,9 @@ * @return array A map from property names to property values. */ public function getEntityPageProperties() { - if ( $this->isRedirect() ) { - return array(); - } - $properties = array(); - $status = $this->getEntityStatus(); + $status = $this->getEntityStatus(); if ( $status !== self::STATUS_NONE ) { $properties['wb-status'] = $status; } diff --git a/repo/includes/content/ItemContent.php b/repo/includes/content/ItemContent.php index 99fc14c..f627d77 100644 --- a/repo/includes/content/ItemContent.php +++ b/repo/includes/content/ItemContent.php @@ -215,13 +215,11 @@ * @return array A map from property names to property values. */ public function getEntityPageProperties() { - if ( $this->isRedirect() ) { - return array(); - } - $properties = parent::getEntityPageProperties(); - $properties['wb-claims'] = $this->getItem()->getStatements()->count(); - $properties['wb-sitelinks'] = $this->getItem()->getSiteLinkList()->count(); + + $item = $this->getItem(); + $properties['wb-claims'] = $item->getStatements()->count(); + $properties['wb-sitelinks'] = $item->getSiteLinkList()->count(); return $properties; } diff --git a/repo/includes/content/PropertyContent.php b/repo/includes/content/PropertyContent.php index c8f7c51..26beaa5 100644 --- a/repo/includes/content/PropertyContent.php +++ b/repo/includes/content/PropertyContent.php @@ -99,11 +99,8 @@ * @return array A map from property names to property values. */ public function getEntityPageProperties() { - if ( $this->isRedirect() ) { - return array(); - } - $properties = parent::getEntityPageProperties(); + $properties['wb-claims'] = $this->getProperty()->getStatements()->count(); return $properties; -- To view, visit https://gerrit.wikimedia.org/r/223563 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0f0342b4609e5d8da968f59cb5343e1fc8531556 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits