Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: Alternative architecture of EntityContent::isStub
......................................................................

Alternative architecture of EntityContent::isStub

Bug: T104895
Change-Id: I8065743021c40ec8f52c0606a44649ce73e2d937
---
M repo/includes/content/EntityContent.php
M repo/includes/content/ItemContent.php
M repo/includes/content/PropertyContent.php
3 files changed, 21 insertions(+), 28 deletions(-)


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

diff --git a/repo/includes/content/EntityContent.php 
b/repo/includes/content/EntityContent.php
index dc59568..7a8fd6c 100644
--- a/repo/includes/content/EntityContent.php
+++ b/repo/includes/content/EntityContent.php
@@ -643,9 +643,18 @@
        }
 
        /**
-        * @return bool
+        * @return bool False if the entity is a redirect, true otherwise.
         */
-       abstract public function isStub();
+       public function isEmpty() {
+               return !$this->isRedirect();
+       }
+
+       /**
+        * @return bool False if the entity is a redirect, true otherwise.
+        */
+       public function isStub() {
+               return !$this->isRedirect();
+       }
 
        /**
         * @see Content::copy
diff --git a/repo/includes/content/ItemContent.php 
b/repo/includes/content/ItemContent.php
index 4a8ccb7..65be325 100644
--- a/repo/includes/content/ItemContent.php
+++ b/repo/includes/content/ItemContent.php
@@ -208,29 +208,21 @@
        }
 
        /**
-        * @see AbstractContent::isEmpty
+        * @see EntityContent::isEmpty
         *
-        * @return bool
+        * @return bool True if this is not a redirect and the item is empty.
         */
        public function isEmpty() {
-               if ( $this->isRedirect() ) {
-                       return false;
-               }
-
-               return $this->getItem()->isEmpty();
+               return parent::isEmpty() && $this->getItem()->isEmpty();
        }
 
        /**
         * @see EntityContent::isStub
         *
-        * @return bool
+        * @return bool True if this is not a redirect and the item does not 
contain statements.
         */
        public function isStub() {
-               if ( $this->isEmpty() ) {
-                       return false;
-               }
-
-               return $this->getItem()->getStatements()->isEmpty();
+               return parent::isStub() && 
$this->getItem()->getStatements()->isEmpty();
        }
 
        /**
diff --git a/repo/includes/content/PropertyContent.php 
b/repo/includes/content/PropertyContent.php
index d3d18e5..1365979 100644
--- a/repo/includes/content/PropertyContent.php
+++ b/repo/includes/content/PropertyContent.php
@@ -113,29 +113,21 @@
        }
 
        /**
-        * @see AbstractContent::isEmpty
+        * @see EntityContent::isEmpty
         *
-        * @return bool
+        * @return bool True if this is not a redirect and the property is 
empty.
         */
        public function isEmpty() {
-               if ( $this->isRedirect() ) {
-                       return false;
-               }
-
-               return $this->getProperty()->isEmpty();
+               return parent::isEmpty() && $this->getProperty()->isEmpty();
        }
 
        /**
         * @see EntityContent::isStub
         *
-        * @return bool
+        * @return bool True if this is not a redirect and the property does 
not contain statements.
         */
        public function isStub() {
-               if ( $this->isEmpty() ) {
-                       return false;
-               }
-
-               return $this->getProperty()->getStatements()->isEmpty();
+               return parent::isStub() && 
$this->getProperty()->getStatements()->isEmpty();
        }
 
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8065743021c40ec8f52c0606a44649ce73e2d937
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

Reply via email to