getDefaultOptions( $userIdentity ); return $defaultOptions[$opt] ?? null; } /** * Get the user's current setting for a given option. * * @param UserIdentity $user The user to get the option for * @param string $oname The option to check * @param mixed|null $defaultOverride A default value returned if the option does not exist * @param bool $ignoreHidden Whether to ignore the effects of $wgHiddenPrefs * @param int $queryFlags A bit field composed of READ_XXX flags * @return mixed|null User's current value for the option, * Note that while option values retrieved from the database are always strings, default * values and values set within the current request and not yet saved may be of another type. * @see getBoolOption() * @see getIntOption() */ abstract public function getOption( UserIdentity $user, string $oname, $defaultOverride = null, bool $ignoreHidden = false, int $queryFlags = IDBAccessObject::READ_NORMAL ); /** * Get all user's options * * @param UserIdentity $user The user to get the option for * @param int $flags Bitwise combination of: * UserOptionsManager::EXCLUDE_DEFAULTS Exclude user options that are set * to the default value. Options * that are set to their conditionally * default value are not excluded. * @param int $queryFlags A bit field composed of READ_XXX flags * @return array */ abstract public function getOptions( UserIdentity $user, int $flags = 0, int $queryFlags = IDBAccessObject::READ_NORMAL ): array; /** * Get the user's current setting for a given option, as a boolean value. * * @param UserIdentity $user The user to get the option for * @param string $oname The option to check * @param int $queryFlags A bit field composed of READ_XXX flags * @return bool User's current value for the option * @see getOption() */ public function getBoolOption( UserIdentity $user, string $oname, int $queryFlags = IDBAccessObject::READ_NORMAL ): bool { return (bool)$this->getOption( $user, $oname, null, false, $queryFlags ); } /** * Get the user's current setting for a given option, as an integer value. * * @param UserIdentity $user The user to get the option for * @param string $oname The option to check * @param int $defaultOverride A default value returned if the option does not exist * @param int $queryFlags A bit field composed of READ_XXX flags * @return int User's current value for the option * @see getOption() */ public function getIntOption( UserIdentity $user, string $oname, int $defaultOverride = 0, int $queryFlags = IDBAccessObject::READ_NORMAL ): int { $val = $this->getOption( $user, $oname, $defaultOverride, false, $queryFlags ); if ( $val == '' ) { $val = $defaultOverride; } return intval( $val ); } /** * Determine if a user option came from a source other than the local store * or the defaults. If this is true, setting the option will be ignored * unless GLOBAL_OVERRIDE or GLOBAL_UPDATE is passed to setOption(). * * @param UserIdentity $user * @param string $key * @return bool */ public function isOptionGlobal( UserIdentity $user, string $key ) { return false; } } /** @deprecated class alias since 1.42 */ class_alias( UserOptionsLookup::class, 'MediaWiki\\User\\UserOptionsLookup' );