Topic on Extension talk:Auth remoteuser

MWException CAS update failed on user_touched

8
193.54.50.250 (talkcontribs)

Heelo,

after migration to Mediwaki 1.38.0 and upgradin extension too, I run into this message :

MWException: CAS update failed on user_touched. The version of the user to be saved is older than the current version.


Backtrace: from ../includes/user/User.php(2813)

  1. 0 ../includes/libs/rdbms/database/Database.php(4428): User->{closure}()
  2. 1 ../includes/libs/rdbms/database/DBConnRef.php(69): Wikimedia\Rdbms\Database->doAtomicSection()
  3. 2 ../includes/libs/rdbms/database/DBConnRef.php(645): Wikimedia\Rdbms\DBConnRef->__call()
  4. 3 ../includes/user/User.php(2825): Wikimedia\Rdbms\DBConnRef->doAtomicSection()
  5. 4 ../extensions/Auth_remoteuser/src/UserNameSessionProvider.php(846): User->saveSettings()
  6. 5 ../extensions/Auth_remoteuser/src/UserNameSessionProvider.php(630): MediaWiki\Extension\Auth_remoteuser\UserNameSessionProvider->setUserPrefs()
  7. 6 ../includes/session/SessionManager.php(843): MediaWiki\Extension\Auth_remoteuser\UserNameSessionProvider->refreshSessionInfo()
  8. 7 ../includes/session/SessionManager.php(544): MediaWiki\Session\SessionManager->loadSessionInfoFromStore()
  9. 8 ../includes/session/SessionManager.php(247): MediaWiki\Session\SessionManager->getSessionInfoForRequest()
  10. 9 ../includes/WebRequest.php(837): MediaWiki\Session\SessionManager->getSessionForRequest()
  11. 10 ../includes/session/SessionManager.php(168): WebRequest->getSession()
  12. 11 ../includes/Setup.php(861): MediaWiki\Session\SessionManager::getGlobalSession()
  13. 12 ../includes/WebStart.php(93): require_once(string)
  14. 13 ../index.php(44): require(string)


Any idea ?


Thanks

Ciencia Al Poder (talkcontribs)

You may look at the user_touched field of the user table for that particular user, if it contains a "sane" value. It should be a number-like, "YYYYMMDDHHmmss" (year month day hour minute second), in the past, not null nor empty

For example: 20000101000000

2A01:E0A:29:9430:DB7:33C3:D4BF:80C1 (talkcontribs)

Thanks for your answer, the value stored is 20220603142256 that seems good to me.

I managed to get the extension working again (my configuration below):

 // Load extension
 wfLoadExtension( 'Auth_remoteuser' );
 
 // If account creation by anonymous users is forbidden, then allow
 // it to be created automatically.
 $wgGroupPermissions['*']['createaccount'] = false;
 $wgGroupPermissions['*']['autocreateaccount'] = true;
 
 // Remote source for user name
 $wgAuthRemoteuserUserName = $login;
 
 // Apply once on user creation
 $wgAuthRemoteuserUserPrefs = [
   'realname'    => $name,
   'language'    => 'fr',
   'email'       => $email
 ];
 
 // Apply on each request
 $wgAuthRemoteuserUserPrefsForced = [
   'realname'    => $undefined,
   'email'       => $undefined
 
 ];

in $wgAuthRemoteuserUserPrefsForced I used $undefined which is an undefined var. If I put everything that exist (such as a real var, a string or empty string) I trigger the error. The only way to make it work is to provide a variable that doesn't exist ... but it work as expected in the user profile ...

Martin schilliger (talkcontribs)

Yeah it works if I stop using `$wgAuthRemoteuserUserPrefsForced`, but that's not really a solution because I need to use it. It also only happens with one user, and the user table looks totally ordinary.

Any idea what triggers the warning and how to avoid it?

Martin schilliger (talkcontribs)

I found out that it only happens if `$wgAuthRemoteuserUserPrefsForced` contains something different than the database, eg. if it has to change something. Runnung in PHP 7.4 right now, maybe this is the reason? Would be suprised if yes…

Martin schilliger (talkcontribs)

OMG! I believe I've found the solution! After allowing sysop to change userrights it works:

`$wgGroupPermissions['sysop']['userrights'] = true`

I don't really understand why it doesn't have this right the first place, but…

That solved another problem I had, but not the one we face here. No idea what's happening. I will try to find another solution for updating the user realname and email in the Wiki DB though. :-/

Ciencia Al Poder (talkcontribs)

There's a "bureaucrat" user group that has the userrights right by default. sysops usually can do administrative tasks but not change other users' groups, unless you choose to give them that right.

Martin schilliger (talkcontribs)

I ended up commenting out in includes/user/User.php the lines 2600-2602 and now everything works like a charm:

throw new MWException( "CAS update failed on user_touched. ". 

"The version of the user to be saved is older than the current version."

);

I don't really understand why, but $dbw->affectedRows() returns 0 even the changes get written to the database this way. It sounds silly to remove the error throwing, but this way the extension works as intended.

Reply to "MWException CAS update failed on user_touched"