Rename WikiMap DB domain ID methods to reduce confusion with web domains
[lhc/web/wiklou.git] / includes / user / User.php
index 65fc4b4..73c12de 100644 (file)
@@ -1579,7 +1579,7 @@ class User implements IDBAccessObject, UserIdentity {
 
                if ( is_array( $data ) ) {
                        if ( isset( $data['user_groups'] ) && is_array( $data['user_groups'] ) ) {
-                               if ( !count( $data['user_groups'] ) ) {
+                               if ( $data['user_groups'] === [] ) {
                                        $this->mGroupMemberships = [];
                                } else {
                                        $firstGroup = reset( $data['user_groups'] );
@@ -1645,7 +1645,7 @@ class User implements IDBAccessObject, UserIdentity {
                }
 
                $toPromote = Autopromote::getAutopromoteOnceGroups( $this, $event );
-               if ( !count( $toPromote ) ) {
+               if ( $toPromote === [] ) {
                        return [];
                }
 
@@ -2305,14 +2305,25 @@ class User implements IDBAccessObject, UserIdentity {
                                // Special handling for a user's own talk page. The block is not aware
                                // of the user, so this must be done here.
                                if ( $title->equals( $this->getTalkPage() ) ) {
-                                       // If the block is sitewide, then whatever is set is what is honored.
                                        if ( $block->isSitewide() ) {
+                                               // If the block is sitewide, whatever is set is what is honored.
+                                               // This must be checked here, because Block::appliesToPage will
+                                               // return true for a sitewide block.
                                                $blocked = $block->prevents( 'editownusertalk' );
                                        } else {
-                                               // If the block is partial, ignore 'editownusertalk' unless
-                                               // there is a restriction on the user talk namespace.
-                                               // TODO: To be implemented with Namespace restrictions
-                                               $blocked = $block->appliesToTitle( $title );
+                                               // The page restrictions always take precedence over the namespace
+                                               // restrictions. If the user is explicity blocked from their own
+                                               // talk page, nothing can change that.
+                                               $blocked = $block->appliesToPage( $title->getArticleID() );
+
+                                               // If the block applies to the user talk namespace, then whatever is
+                                               // set is what is honored.
+                                               if ( !$blocked && $block->appliesToNamespace( NS_USER_TALK ) ) {
+                                                       $blocked = $block->prevents( 'editownusertalk' );
+                                               }
+
+                                               // If another type of restriction is added, it should be checked
+                                               // here.
                                        }
                                } else {
                                        $blocked = $block->appliesToTitle( $title );
@@ -2641,7 +2652,7 @@ class User implements IDBAccessObject, UserIdentity {
                $rev = $timestamp ? Revision::loadFromTimestamp( $dbr, $utp, $timestamp ) : null;
                return [
                        [
-                               'wiki' => WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ),
+                               'wiki' => WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ),
                                'link' => $utp->getLocalURL(),
                                'rev' => $rev
                        ]