From 703752db95eeb841661602b9e17772885396fc29 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 13 Dec 2012 22:16:05 +0100 Subject: [PATCH] (bug 43008) Show error to user if content type doesn't support sections. When trying to edit a page that does not support sections (like a JS or CSS page) with section=new or so, show an informative error page instead of dying with a fatal error. Change-Id: I3d2901b715c10b52fab4fdc6b5e9ab5d887610bd --- includes/EditPage.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index f3c0237f76..3538a32506 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -577,13 +577,15 @@ class EditPage { } /** - * Does this EditPage class support section editing? - * This is used by EditPage subclasses to indicate their ui cannot handle section edits + * Returns whether section editing is supported for the current page. + * Subclasses may override this to replace the default behavior, which is + * to check ContentHandler::supportsSections. * - * @return bool + * @return bool true if this edit page supports sections, false otherwise. */ protected function isSectionEditSupported() { - return true; + $contentHandler = ContentHandler::getForTitle( $this->mTitle ); + return $contentHandler->supportsSections(); } /** @@ -597,6 +599,11 @@ class EditPage { # Section edit can come from either the form or a link $this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) ); + + if ( $this->section !== null && $this->section !== '' && !$this->isSectionEditSupported() ) { + throw new ErrorPageError( 'sectioneditnotsupported-title', 'sectioneditnotsupported-text' ); + } + $this->isNew = !$this->mTitle->exists() || $this->section == 'new'; if ( $request->wasPosted() ) { -- 2.20.1