CMF Wiki - CAS update failed on user_touched for user ID

Discussion in 'General Discussion and Feedback' started by Scharesoft, Jun 8, 2016.

  1. Scharesoft

    Scharesoft New Member

    There is an other problem with the CMF Media Wiki bridge. If I try to use the Visual Editor with a user which is created by the XenForo for the mediaWiki often an error message appears:

    Code:
    [009cbac7] /wiki/index.php?title=Online:Circimure&veaction=edit MWException from line 3704 of /var/www/wiki/includes/User.php: CAS update failed on user_touched for user ID '223' (read from master); the version of the user to be saved is older than the current version.
    
    Backtrace:
    
    #0 /var/www/dev.elderscrollsportal.de/library/CMF/MediaWiki/Hook.php(101): User->saveSettings()
    #1 [internal function]: CMF_MediaWiki_Hook::userLoadFromSession(User, NULL)
    #2 /var/www/wiki/includes/Hooks.php(201): call_user_func_array(string, array)
    #3 /var/www/wiki/includes/User.php(1114): Hooks::run(string, array)
    #4 /var/www/includes/User.php(365): User->loadFromSession()
    #5 /var/www/includes/User.php(2028): User->load()
    #6 /var/www/wiki/includes/User.php(3203): User->getId()
    #7 /var/www/wiki/includes/MediaWiki.php(659): User->isLoggedIn()
    #8 /var/www/wiki/includes/MediaWiki.php(508): MediaWiki->main()
    #9 /var/www/wiki/index.php(41): MediaWiki->run()
    #10 {main}
    
    
     
    Yoskaldyr likes this.
  2. Scharesoft

    Scharesoft New Member

    Sometimes saving article is working, sometimes this message appears.

    And it seems that sometimes the session is also lost.
     
  3. Scharesoft

    Scharesoft New Member

    Additional error message from the console:

    Code:
    XenForo.activate(#document)
    XenForo.init() 49ms. jQuery 1.11.3/1.2.8-dev
    Use of "addOnloadHook" is deprecated. Use jQuery instead.
    exception 'MWException' with message 'CAS update failed on user_touched for user ID '2234' (read from master); the version of the user to be saved is older than the current version.' in /var/www/wiki/includes/User.php:3704
    Stack trace:
    #0 /var/www/library/CMF/MediaWiki/Hook.php(101): User->saveSettings()
    #1 [internal function]: CMF_MediaWiki_Hook::userLoadFromSession(Object(User), NULL)
    #2 /var/www/wiki/includes/Hooks.php(201): call_user_func_array('CMF_MediaWiki_H...', Array)
    #3 /var/www/wiki/includes/User.php(1114): Hooks::run('UserLoadFromSes...', Array)
    #4 /var/www/wiki/includes/User.php(365): User->loadFromSession()
    #5 /var/www/wiki/includes/User.php(5033): User->load()
    #6 /var/www/wiki/includes/User.php(2616): User->loadOptions()
    #7 /var/www/wiki/includes/context/RequestContext.php(342): User->getOption('language')
    #8 /var/www/wiki/includes/StubObject.php(204): RequestContext->getLanguage()
    #9 /var/www/wiki/includes/StubObject.php(160): StubUserLang->_newObject()
    #10 /var/www/wiki/includes/parser/ParserOptions.php(595): StubObject->_unstub()
    #11 /var/www/wiki/includes/cache/MessageCache.php(172): ParserOptions->__construct()
    #12 /var/www/wiki/includes/cache/MessageCache.php(1014): MessageCache->getParserOptions()
    #13 /var/www/wiki/includes/Message.php(1130): MessageCache->transform('{{ns:project}}:...', false, Object(Language), NULL)
    #14 /var/www/wiki/includes/Message.php(797): Message->transformText('{{ns:project}}:...')
    #15 /var/www/wiki/includes/Message.php(860): Message->toString()
    #16 /var/www/wiki/extensions/VisualEditor/VisualEditorDataModule.php(91): Message->text()
    #17 /var/www/wiki/extensions/VisualEditor/VisualEditorDataModule.php(28): VisualEditorDataModule->getMessageInfo()
    #18 /var/www/wiki/extensions/VisualEditor/VisualEditorDataModule.php(148): VisualEditorDataModule->getScript(Object(DerivativeResourceLoaderContext))
    #19 /var/www/wiki/includes/resourceloader/ResourceLoaderModule.php(607): VisualEditorDataModule->getDefinitionSummary(Object(DerivativeResourceLoaderContext))
    #20 /var/www/wiki/includes/resourceloader/ResourceLoader.php(643): ResourceLoaderModule->getVersionHash(Object(ResourceLoaderContext))
    #21 [internal function]: ResourceLoader->{closure}('ext.visualEdito...')
    #22 /var/www/wiki/includes/resourceloader/ResourceLoader.php(644): array_map(Object(Closure), Array)
    #23 /var/www/wiki/includes/resourceloader/ResourceLoader.php(696): ResourceLoader->getCombinedVersion(Object(ResourceLoaderContext), Array)
    #24 /var/www/wiki/load.php(47): ResourceLoader->respond(Object(ResourceLoaderContext))
    #25 {main}
    XHR finished loading: GET "http://www.wiki/api.php?action=query&format=json&…=disambiguation&titles=Schriftrollen%7CPreis%7CPapier%7CChronist&continue=".
    
     
  4. Yoskaldyr

    Yoskaldyr Administrator Staff Member

    @Scharesoft I can look into the code in the weekends and will write here about results.
     
    Scharesoft likes this.
  5. Scharesoft

    Scharesoft New Member

    Thanks, that would be great. Let me know if you need further information.
     
  6. Scharesoft

    Scharesoft New Member

    If you need access to our page, write me a private message. In the moment it's not visible for guests.
     
  7. Yoskaldyr

    Yoskaldyr Administrator Staff Member

    @Scharesoft Right now I'm slightly busy and I do not have a time for it. But I can look into the code when I be free. It will be in a few days.
     
    Scharesoft likes this.
  8. Scharesoft

    Scharesoft New Member

    Ok, thanks for the information. In the moment we had to remove the Visual Editor. I hope you will find a solution for the problem.
     
  9. Scharesoft

    Scharesoft New Member

    Are there any news? It seems the error occurs also on other parts of the mediawiki.

    Often there is an error message like "Login timeout". For example here a user reports this error. It's just a temporary error, but it often appears.
     
    Last edited: Jun 30, 2016
  10. Yoskaldyr

    Yoskaldyr Administrator Staff Member

    @Scharesoft I've looked into the code a several times and can not find why this error appears on your installation.
    This error can appear only if your server has a time or timezone configuration issues. Or maybe issue from other mediawiki add-on.
    And this is not an issue of xenforo or my add-on.

    Because error appears in such situation:
    My addon loads mediawiki user by using media wiki methods and after that tries to update it using saveSettings mediawiki method. But user will been updated only if 'user_touched' field is not changed in the db before saving. But this field is changed by something (maybe by some add-on I do not know) or maybe checking of user_touched field fails because of incorrect timestamp generation (it can be from incorrect timezone configuration on the server).

    In this part my add-on has a too little lines of code needed to check. So right now I do not know to fix this issue on the side of my add-on.

    P.S. Session lost issue can appears because of incorrect timezone or time configuration.
     
    Scharesoft likes this.
  11. Yoskaldyr

    Yoskaldyr Administrator Staff Member

    I do not know but maybe this fix can help.
    find in the library\CMF\MediaWiki\Hook.php
    PHP:
            else
             {
               
    $newUser->loadFromDatabase();
             }
             
    $user $newUser;
             
    $user->setOption('rememberpassword'1);
             
    $user->saveSettings();

    replace with
    PHP:
            else
             {
               
    $newUser->loadFromDatabase(User::READ_EXCLUSIVE);
             }
             
    $user $newUser;
             
    $user->setOption('rememberpassword'1);
             
    $user->saveSettings(User::READ_EXCLUSIVE);

     
  12. Yoskaldyr

    Yoskaldyr Administrator Staff Member

    Also I suggest to increase session.gc_maxlifetime in the php.ini and check that the session.cookie_lifetime = 0
     
  13. Scharesoft

    Scharesoft New Member

    Thanks for the help, but unfortunately this doesn't help.

    The server timezone is "Europe/Berlin", also the one of the MediaWiki with these options in the LocalSettings:
    On XenForo it's Central European Time (UTC+01:00) which is the timezone of Germany.

    An other function which isn't working is the wachtlist and the abovementioned saving of an article. Then the session fail message appears. Sometimes editing is working, but several tries are necessary. Without the bridge it's working with users from MediaWiki.

    I also tried deactivate all other addons (except the require_once "$IP.'/../library/CMF/MediaWiki/LocalSettings.php") but it's still not working.

    For completeness, these are my addons:
    These are the settings of my php.ini
     
  14. Yoskaldyr

    Yoskaldyr Administrator Staff Member

    @Scharesoft
    I do not know why you have these errors.
    Because on my installation I do have these errors at all.
    Mediawiki uses standard php sessions and xenforo uses own realization of the sessions. So both of them works well at the same time.
    Maybe some of xenforo add-ons, installed on your forum, uses standard php sessions? You can find it by searching session_start word.

    P.S. Also you can increase session.gc_maxlifetime.
     
  15. Scharesoft

    Scharesoft New Member

    I've increased the maxlifetime to 14400 togehter with a restart of apache and disabled all other addons (except of CMF Core and CMF MediaWiki), but the problem is still there.

    Can you maybe show me a link to your installation? Maybe I can find something out with the help of the developer console of Chrome.
     
  16. Sperber

    Sperber New Member

    Another session problem coming up here, too:
    Code:
    Warning: session_destroy(): Trying to destroy uninitialized session in /var/www/vhosts/myost.com/httpdocs/wiki/includes/GlobalFunctions.php on line 3473 
    Appears visible for every visitor / user, when he clicks the wiki the next day for the first time. Is this already been solved?

    Scharesoft, wenn Du mit dem VE durch bist, schreib doch mal bitte eine Workaround-Anleitung - so wie das momentan bei euch aussieht, trau ich mich da lieber nicht ran und so ein Tutorial wäre sicher für alle hilfreich.
     
  17. Scharesoft

    Scharesoft New Member

    @Yoskaldyr
    We have tested a lot and it seems that no user is working correct. On my account it works only because of an old session from the MediaWiki where the bridge was not active. But after removing all session data from the browser this account has the same problems. When deactivating the bridge, login into the MediaWiki and than activate the Bridge again it's working for my account, but only as long as the old cookies are there. With a new browser or after removing the browser data it's not working again.

    For testing we have set all time zones to UTC (server, XenForo and MediaWiki), but also without a success.

    @Sperber When it's working I will do this. But I hope a workaround is then not necessary anymore.
     
    Last edited: Jul 5, 2016
    Sperber likes this.
  18. Yoskaldyr

    Yoskaldyr Administrator Staff Member

    @Scharesoft, thank you about your investigation. I will try to test with all cookies removed.
     
    Scharesoft likes this.
  19. Yoskaldyr

    Yoskaldyr Administrator Staff Member

    @Scharesoft try to use this new file. And if it works I will release a new version.
     

    Attached Files:

    • Hook.zip
      File size:
      962 bytes
      Views:
      10
    Scharesoft likes this.
  20. Scharesoft

    Scharesoft New Member

    Great, nice work! Thanks, it seems to work! :)
     
    Yoskaldyr likes this.

Share This Page