Merge "LockManagerGroupFactory to replace singletons"
[lhc/web/wiklou.git] / includes / Title.php
index 674767d..eb19076 100644 (file)
@@ -2506,8 +2506,9 @@ class Title implements LinkTarget, IDBAccessObject {
                global $wgNamespaceProtection;
 
                if ( isset( $wgNamespaceProtection[$this->mNamespace] ) ) {
+                       $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
                        foreach ( (array)$wgNamespaceProtection[$this->mNamespace] as $right ) {
-                               if ( $right != '' && !$user->isAllowed( $right ) ) {
+                               if ( !$permissionManager->userHasRight( $user, $right ) ) {
                                        return true;
                                }
                        }
@@ -3183,7 +3184,7 @@ class Title implements LinkTarget, IDBAccessObject {
        public static function capitalize( $text, $ns = NS_MAIN ) {
                $services = MediaWikiServices::getInstance();
                if ( $services->getNamespaceInfo()->isCapitalized( $ns ) ) {
-                       return MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $text );
+                       return $services->getContentLanguage()->ucfirst( $text );
                } else {
                        return $text;
                }
@@ -3432,10 +3433,12 @@ class Title implements LinkTarget, IDBAccessObject {
 
        /**
         * Purge all applicable CDN URLs
-        * @deprecated 1.34 Use HtmlCacheUpdater
         */
        public function purgeSquid() {
-               MediaWikiServices::getInstance()->getHtmlCacheUpdater()->purge( $this->getCdnUrls() );
+               DeferredUpdates::addUpdate(
+                       new CdnCacheUpdate( $this->getCdnUrls() ),
+                       DeferredUpdates::PRESEND
+               );
        }
 
        /**
@@ -3459,7 +3462,7 @@ class Title implements LinkTarget, IDBAccessObject {
                        return [ [ 'badtitletext' ] ];
                }
 
-               $mp = new MovePage( $this, $nt );
+               $mp = MediaWikiServices::getInstance()->getMovePageFactory()->newMovePage( $this, $nt );
                $errors = $mp->isValidMove()->getErrorsArray();
                if ( $auth ) {
                        $errors = wfMergeErrorArrays(
@@ -3491,7 +3494,7 @@ class Title implements LinkTarget, IDBAccessObject {
 
                global $wgUser;
 
-               $mp = new MovePage( $this, $nt );
+               $mp = MediaWikiServices::getInstance()->getMovePageFactory()->newMovePage( $this, $nt );
                $method = $auth ? 'moveIfAllowed' : 'move';
                $status = $mp->$method( $wgUser, $reason, $createRedirect, $changeTags );
                if ( $status->isOK() ) {
@@ -4243,21 +4246,12 @@ class Title implements LinkTarget, IDBAccessObject {
         * on the number of links. Typically called on create and delete.
         */
        public function touchLinks() {
-               $jobs = [];
-               $jobs[] = HTMLCacheUpdateJob::newForBacklinks(
-                       $this,
-                       'pagelinks',
-                       [ 'causeAction' => 'page-touch' ]
-               );
+               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks', 'page-touch' ) );
                if ( $this->mNamespace == NS_CATEGORY ) {
-                       $jobs[] = HTMLCacheUpdateJob::newForBacklinks(
-                               $this,
-                               'categorylinks',
-                               [ 'causeAction' => 'category-touch' ]
+                       DeferredUpdates::addUpdate(
+                               new HTMLCacheUpdate( $this, 'categorylinks', 'category-touch' )
                        );
                }
-
-               JobQueueGroup::singleton()->lazyPush( $jobs );
        }
 
        /**