jenkins-bot has submitted this change and it was merged.

Change subject: Remove code in ViewEntityAction, duplicating 
Article::isCurrent()
......................................................................


Remove code in ViewEntityAction, duplicating Article::isCurrent()

also improved code that checks if viewing a diff

Change-Id: If2e6758f113dd0897d5aab67b84a4377cce6ac65
---
M repo/includes/actions/ViewEntityAction.php
1 file changed, 9 insertions(+), 17 deletions(-)

Approvals:
  Tobias Gritschacher: Looks good to me, but someone else must approve
  Thiemo Mättig (WMDE): Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/actions/ViewEntityAction.php 
b/repo/includes/actions/ViewEntityAction.php
index 96a47f9..f5f304b 100644
--- a/repo/includes/actions/ViewEntityAction.php
+++ b/repo/includes/actions/ViewEntityAction.php
@@ -132,25 +132,18 @@
         * of the page's current revision.
         */
        private function isEditable() {
-               $article = $this->getArticle();
-
-               if ( !$article->getPage()->exists() ) {
-                       // showing non-existing entity
-                       return false;
-               }
-
-               if ( $article->getOldID() > 0
-                       &&  ( $article->getOldID() !== 
$article->getPage()->getLatest() ) ) {
-                       // showing old content
-                       return false;
-               }
-
-               if ( $this->getRequest()->getCheck( 'diff' ) ) {
-                       // showing a diff
+               if ( !$this->getArticle()->isCurrent() || $this->isDiff() ) {
                        return false;
                }
 
                return true;
+       }
+
+       /**
+        * @return boolean
+        */
+       private function isDiff() {
+               return $this->getRequest()->getCheck( 'diff' );
        }
 
        /**
@@ -178,7 +171,6 @@
                        $editable = $permissionStatus->isOK();
                }
 
-                       // View it!
                $parserOptions = 
$this->getArticle()->getPage()->makeParserOptions( 
$this->getContext()->getUser() );
 
                if ( !$editable ) {
@@ -204,7 +196,7 @@
                }
 
                // Create and set the title.
-               if ( $this->getRequest()->getCheck( 'diff' ) ) {
+               if ( $this->isDiff() ) {
                        // Escaping HTML characters in order to retain original 
label that may contain HTML
                        // characters. This prevents having characters 
evaluated or stripped via
                        // OutputPage::setPageTitle:

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If2e6758f113dd0897d5aab67b84a4377cce6ac65
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to