Merge "xhprof: Guard against division by 0 when computing percentages"
[lhc/web/wiklou.git] / includes / User.php
index f9f4b6a..3cbb052 100644 (file)
@@ -58,6 +58,12 @@ class User implements IDBAccessObject {
         */
        const MAX_WATCHED_ITEMS_CACHE = 100;
 
+       /**
+        * Exclude user options that are set to their default value.
+        * @since 1.25
+        */
+       const GETOPTIONS_EXCLUDE_DEFAULTS = 1;
+
        /**
         * @var PasswordFactory Lazily loaded factory object for passwords
         */
@@ -112,6 +118,7 @@ class User implements IDBAccessObject {
                'deletelogentry',
                'deleterevision',
                'edit',
+               'editcontentmodel',
                'editinterface',
                'editprotected',
                'editmyoptions',
@@ -565,10 +572,12 @@ class User implements IDBAccessObject {
         * @return int|null The corresponding user's ID, or null if user is nonexistent
         */
        public static function idFromName( $name ) {
-               // We don't want to call Title::makeTitleSafe yet, since that call path
-               // ends up needing the user language, which ends up trying to load the
-               // user object, which ends up back here (bug 54193).
-               $nt = Title::makeTitle( NS_USER, $name );
+               $nt = Title::makeTitleSafe( NS_USER, $name );
+               if ( is_null( $nt ) ) {
+                       // Illegal name
+                       return null;
+               }
+
                if ( isset( self::$idCacheByName[$name] ) ) {
                        return self::$idCacheByName[$name];
                }
@@ -2544,9 +2553,12 @@ class User implements IDBAccessObject {
        /**
         * Get all user's options
         *
+        * @param int $flags Bitwise combination of:
+        *   User::GETOPTIONS_EXCLUDE_DEFAULTS  Exclude user options that are set
+        *                                      to the default value. (Since 1.25)
         * @return array
         */
-       public function getOptions() {
+       public function getOptions( $flags = 0 ) {
                global $wgHiddenPrefs;
                $this->loadOptions();
                $options = $this->mOptions;
@@ -2563,6 +2575,10 @@ class User implements IDBAccessObject {
                        }
                }
 
+               if ( $flags & self::GETOPTIONS_EXCLUDE_DEFAULTS ) {
+                       $options = array_diff_assoc( $options, self::getDefaultOptions() );
+               }
+
                return $options;
        }
 
@@ -4416,8 +4432,8 @@ class User implements IDBAccessObject {
                global $wgImplicitGroups;
 
                $groups = $wgImplicitGroups;
-               # Deprecated, use $wgImplictGroups instead
-               wfRunHooks( 'UserGetImplicitGroups', array( &$groups ) );
+               # Deprecated, use $wgImplicitGroups instead
+               wfRunHooks( 'UserGetImplicitGroups', array( &$groups ), '1.25' );
 
                return $groups;
        }
@@ -4473,7 +4489,7 @@ class User implements IDBAccessObject {
                }
                $title = self::getGroupPage( $group );
                if ( $title ) {
-                       $page = $title->getPrefixedText();
+                       $page = $title->getFullText();
                        return "[[$page|$text]]";
                } else {
                        return $text;