X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FTitle.php;h=56c2ed4be9c9ae3cabf63dfa95b1726a751d2f52;hb=7ab280ca486e3fef0fd1cbdbc18017d9455f04a1;hp=8a37f68697d132e1af81c45f51dfebea547d270c;hpb=e311f6f868885ce5f85d2fe25ee798104455fdc7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Title.php b/includes/Title.php index 8a37f68697..56c2ed4be9 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1739,6 +1739,10 @@ class Title { * @return Array list of errors */ private function checkQuickPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) { + if ( !wfRunHooks( 'TitleQuickPermissions', array( $this, $user, $action, &$errors, $doExpensiveQueries, $short ) ) ) { + return $errors; + } + if ( $action == 'create' ) { if ( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) || @@ -1887,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' ); + } } } @@ -2238,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 @@ -2941,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; @@ -2970,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 ); @@ -2986,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 ) { @@ -3000,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 ); @@ -4488,8 +4467,6 @@ class Title { * @return Bool true if the update succeeded */ public function invalidateCache() { - global $wgMemc; - if ( wfReadOnly() ) { return false; } @@ -4505,18 +4482,8 @@ class Title { $method ); } ); - HTMLFileCache::clearFileCache( $this ); - // Clear page info. - $revision = WikiPage::factory( $this )->getRevision(); - if ( $revision !== null ) { - $memcKey = wfMemcKey( 'infoaction', $this->getPrefixedText(), $revision->getId() ); - $success = $wgMemc->delete( $memcKey ); - } else { - $success = true; - } - - return $success; + return true; } /** @@ -4564,7 +4531,7 @@ class Title { if ( array_key_exists( $uid, $this->mNotificationTimestamp ) ) { return $this->mNotificationTimestamp[$uid]; } - if ( !$uid || !$wgShowUpdatedMarker ) { + if ( !$uid || !$wgShowUpdatedMarker || !$user->isAllowed( 'viewmywatchlist' ) ) { return $this->mNotificationTimestamp[$uid] = false; } // Don't cache too much!