Add User::equals
[lhc/web/wiklou.git] / includes / User.php
index 7ca7d80..ad4ce60 100644 (file)
@@ -4739,7 +4739,7 @@ class User implements IDBAccessObject {
                if ( $action === true ) {
                        $action = 'byemail';
                } elseif ( $action === false ) {
-                       if ( $this->getName() == $wgUser->getName() ) {
+                       if ( $this->equals( $wgUser ) ) {
                                $action = 'create';
                        } else {
                                $action = 'create2';
@@ -5024,4 +5024,15 @@ class User implements IDBAccessObject {
                        return Status::newFatal( 'badaccess-group0' );
                }
        }
+
+       /**
+        * Checks if two user objects point to the same user.
+        *
+        * @since 1.25
+        * @param User $user
+        * @return bool
+        */
+       public function equals( User $user ) {
+               return $this->getName() === $user->getName();
+       }
 }