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

Change subject: Show a friendly error page when requested banner does not exist
......................................................................


Show a friendly error page when requested banner does not exist

The CentralNotice admin interface parses URL path components after the
"Special:CentralNoticeBanners/" as designating an action and a banner. If the
banner specified by the URL does not exist, CentralNotice currently throws an
exception. With this patch, a friendly error page is shown instead.

Bug: 54180
Change-Id: I4d61c700ced1001a380241d657ae0341f09ce371
---
M i18n/en.json
M i18n/qqq.json
M special/SpecialCentralNoticeBanners.php
3 files changed, 12 insertions(+), 2 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index da5937d..ff4e717 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -228,5 +228,7 @@
     "centralnotice-start-date": "Start date (UTC)",
     "centralnotice-start-time": "Start time (UTC)",
     "centralnotice-end-date": "End date (UTC)",
-    "centralnotice-end-time": "End time (UTC)"
+    "centralnotice-end-time": "End time (UTC)",
+    "centralnotice-banner-not-found-title": "Banner not found",
+    "centralnotice-banner-not-found-contents": "There is no banner with this 
exact name."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 3185ef1..2f8bffd 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -251,5 +251,7 @@
        "centralnotice-start-date": "Date without time.\n\nUsed in 
[[meta:Special:CentralNotice|Central Notice]] special page. Used as table 
column header and followed by 
{{msg-mw|Centralnotice-start-time}}.\n\n{{Related|Centralnotice-th}}\n{{Identical|Start
 date}}",
        "centralnotice-start-time": "Used in Special:CentralNotice. UTC is 
\"[[w:Coordinated_Universal_Time|Coordinated Universal Time]]\"",
        "centralnotice-end-date": "Date without time.\n\nUsed in 
[[meta:Special:CentralNotice|Central Notice]] special page as table column 
header and follows 
{{msg-mw|Centralnotice-start-date}}.\n{{Related|Centralnotice-th}}\n{{Identical|End
 date}}",
-       "centralnotice-end-time": "Used in Special:CentralNotice. UTC is 
\"[[w:Coordinated_Universal_Time|Coordinated Universal Time]]\""
+       "centralnotice-end-time": "Used in Special:CentralNotice. UTC is 
\"[[w:Coordinated_Universal_Time|Coordinated Universal Time]]\"",
+       "centralnotice-banner-not-found-title": "Page title and top header of 
Special:CentralNoticeBanners when the requested banner does not exist",
+       "centralnotice-banner-not-found-contents": "Used as the body content of 
SpecialCentral:NoticeBanners when the requested banner does not exist"
 }
diff --git a/special/SpecialCentralNoticeBanners.php 
b/special/SpecialCentralNoticeBanners.php
index 743f68d..30d5600 100644
--- a/special/SpecialCentralNoticeBanners.php
+++ b/special/SpecialCentralNoticeBanners.php
@@ -420,6 +420,12 @@
                $languages = array_flip( $languages );
 
                $banner = Banner::fromName( $this->bannerName );
+               if ( !$banner->exists() ) {
+                       return $this->getOutput()->showErrorPage(
+                               'centralnotice-banner-not-found-title',
+                               'centralnotice-banner-not-found-contents'
+                       );
+               }
                $bannerSettings = $banner->getBannerSettings( 
$this->bannerName, true );
 
                $formDescriptor = array();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4d61c700ced1001a380241d657ae0341f09ce371
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to