X-Git-Url: https://git.cyclocoop.org/admin/?a=blobdiff_plain;f=includes%2Fuser%2FUser.php;h=3e6b212097b3794bdc3375c99a36fff1b4ba528f;hb=d13aa39760f9de5ab9c638ae417f94c786244ee7;hp=3102cfcf105711ffaac4c845dc356dc9ed9ca228;hpb=cde659e4dae4a9eb6cf49521b5250b89b7f8d9d9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/user/User.php b/includes/user/User.php index 3102cfcf10..3e6b212097 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -150,10 +150,12 @@ class User implements IDBAccessObject, UserIdentity { 'editmyoptions', 'editmyprivateinfo', 'editmyusercss', + 'editmyuserjson', 'editmyuserjs', 'editmywatchlist', 'editsemiprotected', 'editusercss', + 'edituserjson', 'edituserjs', 'hideuser', 'import', @@ -885,7 +887,7 @@ class User implements IDBAccessObject, UserIdentity { return null; } - if ( !( $flags & self::READ_LATEST ) && isset( self::$idCacheByName[$name] ) ) { + if ( !( $flags & self::READ_LATEST ) && array_key_exists( $name, self::$idCacheByName ) ) { return self::$idCacheByName[$name]; } @@ -1871,7 +1873,9 @@ class User implements IDBAccessObject, UserIdentity { $this->mHideName = $block->mHideName; $this->mAllowUsertalk = !$block->prevents( 'editownusertalk' ); } else { + $this->mBlock = null; $this->mBlockedby = ''; + $this->mBlockreason = ''; $this->mHideName = 0; $this->mAllowUsertalk = false; } @@ -3082,7 +3086,7 @@ class User implements IDBAccessObject, UserIdentity { * @param string $oname The option to check * @param string $defaultOverride A default value returned if the option does not exist * @param bool $ignoreHidden Whether to ignore the effects of $wgHiddenPrefs - * @return string|null User's current value for the option + * @return string|array|int|null User's current value for the option * @see getBoolOption() * @see getIntOption() */ @@ -3967,51 +3971,9 @@ class User implements IDBAccessObject, UserIdentity { return; } - $dbw = wfGetDB( DB_MASTER ); - $asOfTimes = array_unique( $dbw->selectFieldValues( - 'watchlist', - 'wl_notificationtimestamp', - [ 'wl_user' => $id, 'wl_notificationtimestamp IS NOT NULL' ], - __METHOD__, - [ 'ORDER BY' => 'wl_notificationtimestamp DESC', 'LIMIT' => 500 ] - ) ); - if ( !$asOfTimes ) { - return; - } - // Immediately update the most recent touched rows, which hopefully covers what - // the user sees on the watchlist page before pressing "mark all pages visited".... - $dbw->update( - 'watchlist', - [ 'wl_notificationtimestamp' => null ], - [ 'wl_user' => $id, 'wl_notificationtimestamp' => $asOfTimes ], - __METHOD__ - ); - // ...and finish the older ones in a post-send update with lag checks... - DeferredUpdates::addUpdate( new AutoCommitUpdate( - $dbw, - __METHOD__, - function () use ( $dbw, $id ) { - global $wgUpdateRowsPerQuery; - - $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); - $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ ); - $asOfTimes = array_unique( $dbw->selectFieldValues( - 'watchlist', - 'wl_notificationtimestamp', - [ 'wl_user' => $id, 'wl_notificationtimestamp IS NOT NULL' ], - __METHOD__ - ) ); - foreach ( array_chunk( $asOfTimes, $wgUpdateRowsPerQuery ) as $asOfTimeBatch ) { - $dbw->update( - 'watchlist', - [ 'wl_notificationtimestamp' => null ], - [ 'wl_user' => $id, 'wl_notificationtimestamp' => $asOfTimeBatch ], - __METHOD__ - ); - $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket ); - } - } - ) ); + $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore(); + $watchedItemStore->resetAllNotificationTimestampsForUser( $this ); + // We also need to clear here the "you have new message" notification for the own // user_talk page; it's cleared one page view later in WikiPage::doViewUpdates(). } @@ -4052,76 +4014,6 @@ class User implements IDBAccessObject, UserIdentity { } } - /** - * Set a cookie on the user's client. Wrapper for - * WebResponse::setCookie - * @deprecated since 1.27 - * @param string $name Name of the cookie to set - * @param string $value Value to set - * @param int $exp Expiration time, as a UNIX time value; - * if 0 or not specified, use the default $wgCookieExpiration - * @param bool $secure - * true: Force setting the secure attribute when setting the cookie - * false: Force NOT setting the secure attribute when setting the cookie - * null (default): Use the default ($wgCookieSecure) to set the secure attribute - * @param array $params Array of options sent passed to WebResponse::setcookie() - * @param WebRequest|null $request WebRequest object to use; $wgRequest will be used if null - * is passed. - */ - protected function setCookie( - $name, $value, $exp = 0, $secure = null, $params = [], $request = null - ) { - wfDeprecated( __METHOD__, '1.27' ); - if ( $request === null ) { - $request = $this->getRequest(); - } - $params['secure'] = $secure; - $request->response()->setCookie( $name, $value, $exp, $params ); - } - - /** - * Clear a cookie on the user's client - * @deprecated since 1.27 - * @param string $name Name of the cookie to clear - * @param bool $secure - * true: Force setting the secure attribute when setting the cookie - * false: Force NOT setting the secure attribute when setting the cookie - * null (default): Use the default ($wgCookieSecure) to set the secure attribute - * @param array $params Array of options sent passed to WebResponse::setcookie() - */ - protected function clearCookie( $name, $secure = null, $params = [] ) { - wfDeprecated( __METHOD__, '1.27' ); - $this->setCookie( $name, '', time() - 86400, $secure, $params ); - } - - /** - * Set an extended login cookie on the user's client. The expiry of the cookie - * is controlled by the $wgExtendedLoginCookieExpiration configuration - * variable. - * - * @see User::setCookie - * - * @deprecated since 1.27 - * @param string $name Name of the cookie to set - * @param string $value Value to set - * @param bool $secure - * true: Force setting the secure attribute when setting the cookie - * false: Force NOT setting the secure attribute when setting the cookie - * null (default): Use the default ($wgCookieSecure) to set the secure attribute - */ - protected function setExtendedLoginCookie( $name, $value, $secure ) { - global $wgExtendedLoginCookieExpiration, $wgCookieExpiration; - - wfDeprecated( __METHOD__, '1.27' ); - - $exp = time(); - $exp += $wgExtendedLoginCookieExpiration !== null - ? $wgExtendedLoginCookieExpiration - : $wgCookieExpiration; - - $this->setCookie( $name, $value, $exp, $secure ); - } - /** * Persist this user's session (e.g. set cookies) * @@ -4667,17 +4559,6 @@ class User implements IDBAccessObject, UserIdentity { return $this->getEditTokenObject( $salt, $request )->toString(); } - /** - * Get the embedded timestamp from a token. - * @deprecated since 1.27, use \MediaWiki\Session\Token::getTimestamp instead. - * @param string $val Input token - * @return int|null - */ - public static function getEditTokenTimestamp( $val ) { - wfDeprecated( __METHOD__, '1.27' ); - return MediaWiki\Session\Token::getTimestamp( $val ); - } - /** * Check given value against the token value stored in the session. * A match should confirm that the form was submitted from the @@ -5678,78 +5559,6 @@ class User implements IDBAccessObject, UserIdentity { $dbw->insert( 'user_properties', $insert_rows, __METHOD__, [ 'IGNORE' ] ); } - /** - * Lazily instantiate and return a factory object for making passwords - * - * @deprecated since 1.27, create a PasswordFactory directly instead - * @return PasswordFactory - */ - public static function getPasswordFactory() { - wfDeprecated( __METHOD__, '1.27' ); - $ret = new PasswordFactory(); - $ret->init( RequestContext::getMain()->getConfig() ); - return $ret; - } - - /** - * Provide an array of HTML5 attributes to put on an input element - * intended for the user to enter a new password. This may include - * required, title, and/or pattern, depending on $wgMinimalPasswordLength. - * - * Do *not* use this when asking the user to enter his current password! - * Regardless of configuration, users may have invalid passwords for whatever - * reason (e.g., they were set before requirements were tightened up). - * Only use it when asking for a new password, like on account creation or - * ResetPass. - * - * Obviously, you still need to do server-side checking. - * - * NOTE: A combination of bugs in various browsers means that this function - * actually just returns array() unconditionally at the moment. May as - * well keep it around for when the browser bugs get fixed, though. - * - * @todo FIXME: This does not belong here; put it in Html or Linker or somewhere - * - * @deprecated since 1.27 - * @return array Array of HTML attributes suitable for feeding to - * Html::element(), directly or indirectly. (Don't feed to Xml::*()! - * That will get confused by the boolean attribute syntax used.) - */ - public static function passwordChangeInputAttribs() { - global $wgMinimalPasswordLength; - - if ( $wgMinimalPasswordLength == 0 ) { - return []; - } - - # Note that the pattern requirement will always be satisfied if the - # input is empty, so we need required in all cases. - - # @todo FIXME: T25769: This needs to not claim the password is required - # if e-mail confirmation is being used. Since HTML5 input validation - # is b0rked anyway in some browsers, just return nothing. When it's - # re-enabled, fix this code to not output required for e-mail - # registration. - # $ret = array( 'required' ); - $ret = []; - - # We can't actually do this right now, because Opera 9.6 will print out - # the entered password visibly in its error message! When other - # browsers add support for this attribute, or Opera fixes its support, - # we can add support with a version check to avoid doing this on Opera - # versions where it will be a problem. Reported to Opera as - # DSK-262266, but they don't have a public bug tracker for us to follow. - /* - if ( $wgMinimalPasswordLength > 1 ) { - $ret['pattern'] = '.{' . intval( $wgMinimalPasswordLength ) . ',}'; - $ret['title'] = wfMessage( 'passwordtooshort' ) - ->numParams( $wgMinimalPasswordLength )->text(); - } - */ - - return $ret; - } - /** * Return the list of user fields that should be selected to create * a new user object.