X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FTitle.php;h=9d42b2f894e02993d7249152578e437a267e26eb;hb=5ff7e6fb7a36bfcf76b8cd7083fc5ea720db6b52;hp=29e810e62a50ce2a9a8d5f00b9782d1b4d0ab4ac;hpb=7120504bb99d39809787c461b711a7ee506165d6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Title.php b/includes/Title.php index 29e810e62a..9d42b2f894 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1891,12 +1891,19 @@ class Title { # Protect css/js subpages of user pages # XXX: this might be better using restrictions # XXX: right 'editusercssjs' is deprecated, for backward compatibility only - if ( $action != 'patrol' && !$user->isAllowed( 'editusercssjs' ) - && !preg_match( '/^' . preg_quote( $user->getName(), '/' ) . '\//', $this->mTextform ) ) { - if ( $this->isCssSubpage() && !$user->isAllowed( 'editusercss' ) ) { - $errors[] = array( 'customcssprotected' ); - } elseif ( $this->isJsSubpage() && !$user->isAllowed( 'edituserjs' ) ) { - $errors[] = array( 'customjsprotected' ); + if ( $action != 'patrol' && !$user->isAllowed( 'editusercssjs' ) ) { + if ( preg_match( '/^' . preg_quote( $user->getName(), '/' ) . '\//', $this->mTextform ) ) { + if ( $this->isCssSubpage() && !$user->isAllowedAny( 'editmyusercss', 'editusercss' ) ) { + $errors[] = array( 'mycustomcssprotected' ); + } elseif ( $this->isJsSubpage() && !$user->isAllowedAny( 'editmyuserjs', 'edituserjs' ) ) { + $errors[] = array( 'mycustomjsprotected' ); + } + } else { + if ( $this->isCssSubpage() && !$user->isAllowed( 'editusercss' ) ) { + $errors[] = array( 'customcssprotected' ); + } elseif ( $this->isJsSubpage() && !$user->isAllowed( 'edituserjs' ) ) { + $errors[] = array( 'customjsprotected' ); + } } } @@ -2242,36 +2249,6 @@ class Title { return $errors; } - /** - * Protect css subpages of user pages: can $wgUser edit - * this page? - * - * @deprecated in 1.19; use getUserPermissionsErrors() instead. - * @return Bool - */ - public function userCanEditCssSubpage() { - global $wgUser; - wfDeprecated( __METHOD__, '1.19' ); - return ( ( $wgUser->isAllowedAll( 'editusercssjs', 'editusercss' ) ) - || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) ); - } - - /** - * Protect js subpages of user pages: can $wgUser edit - * this page? - * - * @deprecated in 1.19; use getUserPermissionsErrors() instead. - * @return Bool - */ - public function userCanEditJsSubpage() { - global $wgUser; - wfDeprecated( __METHOD__, '1.19' ); - return ( - ( $wgUser->isAllowedAll( 'editusercssjs', 'edituserjs' ) ) - || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) - ); - } - /** * Get a filtered list of all restriction types supported by this wiki. * @param bool $exists True to get all restriction types that apply to @@ -2945,11 +2922,13 @@ class Title { $linkCache = LinkCache::singleton(); $cached = $linkCache->getGoodLinkFieldObj( $this, 'redirect' ); if ( $cached === null ) { - // TODO: check the assumption that the cache actually knows about this title - // and handle this, such as get the title from the database. - // See https://bugzilla.wikimedia.org/show_bug.cgi?id=37209 - wfDebug( "LinkCache doesn't currently know about this title: " . $this->getPrefixedDBkey() ); - wfDebug( wfBacktrace() ); + # Trust LinkCache's state over our own + # LinkCache is telling us that the page doesn't exist, despite there being cached + # data relating to an existing page in $this->mArticleID. Updaters should clear + # LinkCache as appropriate, or use $flags = Title::GAID_FOR_UPDATE. If that flag is + # set, then LinkCache will definitely be up to date here, since getArticleID() forces + # LinkCache to refresh its data from the master. + return $this->mRedirect = false; } $this->mRedirect = (bool)$cached; @@ -2974,11 +2953,9 @@ class Title { } $linkCache = LinkCache::singleton(); $cached = $linkCache->getGoodLinkFieldObj( $this, 'length' ); - if ( $cached === null ) { # check the assumption that the cache actually knows about this title - # XXX: this does apparently happen, see https://bugzilla.wikimedia.org/show_bug.cgi?id=37209 - # as a stop gap, perhaps log this, but don't throw an exception? - wfDebug( "LinkCache doesn't currently know about this title: " . $this->getPrefixedDBkey() ); - wfDebug( wfBacktrace() ); + if ( $cached === null ) { + # Trust LinkCache's state over our own, as for isRedirect() + return $this->mLength = 0; } $this->mLength = intval( $cached ); @@ -2990,7 +2967,6 @@ class Title { * What is the page_latest field for this page? * * @param int $flags a bit field; may be Title::GAID_FOR_UPDATE to select for update - * @throws MWException * @return Int or 0 if the page doesn't exist */ public function getLatestRevID( $flags = 0 ) { @@ -3004,10 +2980,9 @@ class Title { $linkCache = LinkCache::singleton(); $linkCache->addLinkObj( $this ); $cached = $linkCache->getGoodLinkFieldObj( $this, 'revision' ); - if ( $cached === null ) { # check the assumption that the cache actually knows about this title - # XXX: this does apparently happen, see https://bugzilla.wikimedia.org/show_bug.cgi?id=37209 - # as a stop gap, perhaps log this, but don't throw an exception? - throw new MWException( "LinkCache doesn't currently know about this title: " . $this->getPrefixedDBkey() ); + if ( $cached === null ) { + # Trust LinkCache's state over our own, as for isRedirect() + return $this->mLatestID = 0; } $this->mLatestID = intval( $cached ); @@ -4492,8 +4467,6 @@ class Title { * @return Bool true if the update succeeded */ public function invalidateCache() { - global $wgMemc; - if ( wfReadOnly() ) { return false; }