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

Change subject: Show an error if ViewEntityAction is used with non-Entity 
content
......................................................................


Show an error if ViewEntityAction is used with non-Entity content

ViewEntityAction is being called with non-Entity content eg. if a
user tries to diff wikitext content with entity content.

Bug: T73546
Change-Id: I1a5781e017df645b51b3ecdb016cd6cbd2c3d557
---
M repo/i18n/en.json
M repo/i18n/qqq.json
M repo/includes/actions/ViewEntityAction.php
3 files changed, 17 insertions(+), 3 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/i18n/en.json b/repo/i18n/en.json
index e751fb2..bb416be 100644
--- a/repo/i18n/en.json
+++ b/repo/i18n/en.json
@@ -400,5 +400,7 @@
        "right-item-merge": "Merge items",
        "right-item-redirect": "Create item redirects",
        "right-property-term": "Change property terms (labels, descriptions, 
aliases)",
-       "right-property-create": "Create properties"
+       "right-property-create": "Create properties",
+       "wikibase-entity-not-viewable-title": "Content type mismatch: Can not 
display content",
+       "wikibase-entity-not-viewable": "The given content of type \"$1\" is 
not an Entity and can not be displayed by Wikibase."
 }
diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json
index 03980e7..12ba988 100644
--- a/repo/i18n/qqq.json
+++ b/repo/i18n/qqq.json
@@ -427,5 +427,7 @@
        "right-item-merge": "{{doc-right|item-merge}}\nRight to alter the 
contents of 
[[d:Special:MyLanguage/Wikidata:Glossary#Item|items]].\n{{Identical|Merge 
item}}",
        "right-item-redirect": "{{doc-right|item-redirect}}\nRight to create 
[[d:Special:MyLanguage/Wikidata:Glossary#Item|item]] redirects after merging 
items.",
        "right-property-term": "{{doc-right|property-term}}\nRight to alter the 
[[d:Wikidata:Glossary#Term|terms]] of [[d:Wikidata:Glossary#Item|items]].",
-       "right-property-create": "{{doc-right|property-create}}\nRight to 
create new [[d:Wikidata:Glossary#Property|properties]]."
+       "right-property-create": "{{doc-right|property-create}}\nRight to 
create new [[d:Wikidata:Glossary#Property|properties]].",
+        "wikibase-entity-not-viewable-title": "Page title on the error page 
saying that content can't be displayed.",
+        "wikibase-entity-not-viewable": "Error message saying that some 
content can't be rendered. $1 is the content model of the content that can't be 
displayed (eg. wikitext)."
 }
diff --git a/repo/includes/actions/ViewEntityAction.php 
b/repo/includes/actions/ViewEntityAction.php
index 6298ef2..a747a01 100644
--- a/repo/includes/actions/ViewEntityAction.php
+++ b/repo/includes/actions/ViewEntityAction.php
@@ -95,6 +95,15 @@
                                $this->getArticle()
                        );
 
+                       if ( !( $content instanceof EntityContent ) ) {
+                               $this->getOutput()->showErrorPage(
+                                               
'wikibase-entity-not-viewable-title',
+                                               'wikibase-entity-not-viewable',
+                                               $content->getModel()
+                               );
+                               return;
+                       }
+
                        $this->displayEntityContent( $content );
                }
        }
@@ -123,8 +132,9 @@
         *
         * @param EntityContent $content
         */
-       protected function displayEntityContent( EntityContent $content ) {
+       private function displayEntityContent( EntityContent $content ) {
                $outputPage = $this->getOutput();
+
                $editable = $this->isEditable();
 
                // NOTE: page-wide property, independent of user permissions

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1a5781e017df645b51b3ecdb016cd6cbd2c3d557
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <h...@online.de>
Gerrit-Reviewer: Adrian Lang <adrian.l...@wikimedia.de>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: JanZerebecki <jan.wikime...@zerebecki.de>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to