Reduce CAS errors in ApiEchoMarkSeen

* These tend to log errors many times in a row for the same few
  users in any given time period. There is probably some usage
  pattern issue in JS on top of the abuse of preferences for
  such tracking state. In any case, this should help.

Bug: T95839
Change-Id: I4d57b1db43a63300a412a5de220b66081da754f1
This commit is contained in:
Aaron Schulz 2015-08-11 12:18:00 -07:00
parent d072a9a47b
commit 2a0e98e9a9

9
includes/api/ApiEchoMarkSeen.php Normal file → Executable file
View file

@ -11,9 +11,14 @@ class ApiEchoMarkSeen extends ApiBase {
$this->dieUsage( 'Login is required', 'login-required' );
}
// Load from the master to reduce CAS errors from high update frequency
$u = User::newFromId( $user->getId() );
$u->load( User::READ_LATEST );
$timestamp = wfTimestamp( TS_MW );
$user->setOption( 'echo-seen-time', $timestamp );
$user->saveSettings();
// @TODO: do not abuse user preferences for "last seen"
$u->setOption( 'echo-seen-time', $timestamp );
$u->saveSettings();
$this->getResult()->addValue( 'query', $this->getModuleName(), array(
'result' => 'success',