Make $wgEmailConfirmToEdit only affect edit actions.
[lhc/web/wiklou.git] / includes / Title.php
index b771477..91d8de4 100644 (file)
@@ -207,8 +207,8 @@ class Title implements LinkTarget {
         * Create a new Title from a prefixed DB key
         *
         * @param string $key The database key, which has underscores
-        *      instead of spaces, possibly including namespace and
-        *      interwiki prefixes
+        *      instead of spaces, possibly including namespace and
+        *      interwiki prefixes
         * @return Title|null Title, or null on an error
         */
        public static function newFromDBkey( $key ) {
@@ -784,11 +784,8 @@ class Title implements LinkTarget {
         * @return int Result of string comparison, or namespace comparison
         */
        public static function compare( LinkTarget $a, LinkTarget $b ) {
-               if ( $a->getNamespace() == $b->getNamespace() ) {
-                       return strcmp( $a->getText(), $b->getText() );
-               } else {
-                       return $a->getNamespace() - $b->getNamespace();
-               }
+               return $a->getNamespace() <=> $b->getNamespace()
+                       ?: strcmp( $a->getText(), $b->getText() );
        }
 
        /**
@@ -2556,7 +2553,10 @@ class Title implements LinkTarget {
                        return $errors;
                }
 
-               if ( $wgEmailConfirmToEdit && !$user->isEmailConfirmed() ) {
+               if ( $wgEmailConfirmToEdit
+                       && !$user->isEmailConfirmed()
+                       && $action === 'edit'
+               ) {
                        $errors[] = [ 'confirmedittext' ];
                }
 
@@ -3089,9 +3089,7 @@ class Title implements LinkTarget {
                if ( !$this->mRestrictionsLoaded ) {
                        $this->loadRestrictions();
                }
-               return isset( $this->mRestrictions[$action] )
-                               ? $this->mRestrictions[$action]
-                               : [];
+               return $this->mRestrictions[$action] ?? [];
        }
 
        /**
@@ -3119,7 +3117,7 @@ class Title implements LinkTarget {
                if ( !$this->mRestrictionsLoaded ) {
                        $this->loadRestrictions();
                }
-               return isset( $this->mRestrictionsExpiry[$action] ) ? $this->mRestrictionsExpiry[$action] : false;
+               return $this->mRestrictionsExpiry[$action] ?? false;
        }
 
        /**
@@ -4694,9 +4692,12 @@ class Title implements LinkTarget {
                }
 
                $dbw = wfGetDB( DB_MASTER );
-               $dbw->onTransactionPreCommitOrIdle( function () {
-                       ResourceLoaderWikiModule::invalidateModuleCache( $this, null, null, wfWikiID() );
-               } );
+               $dbw->onTransactionPreCommitOrIdle(
+                       function () {
+                               ResourceLoaderWikiModule::invalidateModuleCache( $this, null, null, wfWikiID() );
+                       },
+                       __METHOD__
+               );
 
                $conds = $this->pageCond();
                DeferredUpdates::addUpdate(