From bbad085453d92adc82e38832235040ff8df0f0c9 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Thu, 25 Nov 2010 23:12:05 +0000 Subject: [PATCH] * Show "skin does not exist error" only when the skin is inputted in the wrong case. This seems to be the original intention. Otherwise it renders the warning on the completely legitimate subpages with user scripts. * Deprecate isValidUserCssJSSubpage() as having a very confusing title. User scripts *are* valid user JS subpages. --- RELEASE-NOTES | 2 ++ includes/EditPage.php | 22 ++++++++++++++++++++-- includes/Title.php | 13 ++----------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ce6b501772..7a237c21f1 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -438,6 +438,8 @@ LocalSettings.php. The specific bugs are listed below in the general notes. * Fixed PHP warnings when updating a broken MySQL database. * (bug 26023) Corrected deleteBacth.php's documentation * (bug 25451) Improved datetime representation in 32 bit php >= 5.2. +* Show "skin does not exist error" only when the skin is inputted in the wrong + case. === API changes in 1.17 === * (bug 22738) Allow filtering by action type on query=logevent. diff --git a/includes/EditPage.php b/includes/EditPage.php index 1182ef7995..77dc174393 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -274,6 +274,24 @@ class EditPage { return $this->deletedSinceEdit; } + /** + * Checks whether the user entered a skin name in uppercase, + * e.g. "User:Example/Monobook.css" instead of "monobook.css" + */ + protected function isWrongCaseCssJsPage() { + if( $this->mTitle->isCssJsSubpage() ) { + $name = $this->mTitle->getSkinFromCssJsSubpage(); + $skins = array_merge( + array_keys( Skin::getSkinNames() ), + array( 'common' ) + ); + return !in_array( $name, $skins ) + && in_array( strtolower( $name ), $skins ); + } else { + return false; + } + } + function submit() { $this->edit(); } @@ -360,7 +378,7 @@ class EditPage { $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage(); $this->isCssSubpage = $this->mTitle->isCssSubpage(); $this->isJsSubpage = $this->mTitle->isJsSubpage(); - $this->isValidCssJsSubpage = $this->mTitle->isValidCssJsSubpage(); + $this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage(); # Show applicable editing introductions if ( $this->formtype == 'initial' || $this->firsttime ) @@ -1407,7 +1425,7 @@ HTML } else { if ( $this->isCssJsSubpage ) { # Check the skin exists - if ( !$this->isValidCssJsSubpage ) { + if ( $this->isWrongCaseCssJsPage ) { $wgOut->wrapWikiMsg( "
\n$1\n
", array( 'userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage() ) ); } if ( $this->formtype !== 'preview' ) { diff --git a/includes/Title.php b/includes/Title.php index 13ea7d909c..6c0ddb4890 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1898,21 +1898,12 @@ class Title { /** * Is this a *valid* .css or .js subpage of a user page? - * Check that the corresponding skin exists * * @return \type{\bool} + * @deprecated */ public function isValidCssJsSubpage() { - if ( $this->isCssJsSubpage() ) { - $name = $this->getSkinFromCssJsSubpage(); - if ( $name == 'common' ) { - return true; - } - $skinNames = Skin::getSkinNames(); - return array_key_exists( $name, $skinNames ); - } else { - return false; - } + return $this->isCssJsSubpage(); } /** -- 2.20.1