From: daniel Date: Thu, 13 Dec 2012 21:16:05 +0000 (+0100) Subject: (bug 43008) Show error to user if content type doesn't support sections. X-Git-Tag: 1.31.0-rc.0~20974 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=703752db95eeb841661602b9e17772885396fc29;p=lhc%2Fweb%2Fwiklou.git (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 --- 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() ) {