Last modified: 2012-11-09 18:43:00 UTC
Created attachment 10420 [details] Workaround. MediaWiki 1.18.1 SemanticMedia Wiki 1.7.1 I have never seen this issue when working with MediaWiki interactively, but running maintenance/runJobs.php script often crashes: Fatal error: Call to a member function getUser() on a non-object in /var/www/oc.su/Extensions/SemanticMediaWiki-1.7.1/includes/SMW_ParseData.php on line 218 Call Stack: 0.0004 668472 1. {main}() /var/www/oc.su/MediaWiki-1.18.1/maintenance/runJobs.php:0 0.0029 1239944 2. require_once('/var/www/oc.su/MediaWiki-1.18.1/maintenance/doMaintenance.php') /var/www/oc.su/MediaWiki-1.18.1/maintenance/runJobs.php:108 0.1163 18504696 3. RunJobs->execute() /var/www/oc.su/MediaWiki-1.18.1/maintenance/doMaintenance.php:105 0.1813 19744368 4. RefreshLinksJob2->run() /var/www/oc.su/MediaWiki-1.18.1/maintenance/runJobs.php:78 0.7043 39067088 5. LinksUpdate->__construct() /var/www/oc.su/MediaWiki-1.18.1/includes/job/RefreshLinksJob.php:119 0.7048 39069280 6. wfRunHooks() /var/www/oc.su/MediaWiki-1.18.1/includes/LinksUpdate.php:98 0.7048 39069280 7. Hooks::run() /var/www/oc.su/MediaWiki-1.18.1/includes/GlobalFunctions.php:3631 0.7048 39084176 8. call_user_func_array() /var/www/oc.su/MediaWiki-1.18.1/includes/Hooks.php:216 0.7048 39084512 9. SMWParseData::onLinksUpdateConstructed() /var/www/oc.su/MediaWiki-1.18.1/includes/Hooks.php:216 0.7049 39084560 10. SMWParseData::storeData() /var/www/oc.su/Extensions/SemanticMediaWiki-1.7.1/includes/SMW_ParseData.php:481 (reported line numbers may be not fully correct because I added bunch of trace statements to the code to track down the problem.) The problem appears in SMW_ParseData.php:210: case '_LEDT' : $revision = Revision::newFromId( $title->getLatestRevID() ); $user = User::newFromId( $revision->getUser() ); $value = SMWDIWikiPage::newFromTitle( $user->getUserPage() ); break; For unknown reason, getLatestRevID() returns zero for valid title of *existing* page, $revision set to null, getUser() failed. I am not sure if it is a bug in Title, LinkCache, BacklinkCache, RefreshLinksJob2 classes, or in runJobs.php script. Roughly, the scenario is: runJobs.php calls RunJobs->execute() which calls RefreshLinksJob2->run() which calls BacklinkCache->getLinks(). The latter gets list of pages, but only titls, namespaces, and ids (no lastest rev id, no redirection, etc): // @todo FIXME: Make this a function? if ( !isset( $this->fullResultCache[$table] ) ) { wfDebug( __METHOD__ . ": from DB\n" ); $res = $this->getDB()->select( array( $table, 'page' ), array( 'page_namespace', 'page_title', 'page_id' ), // ===>>> NOTE: If I add 'page_latest' to the list, // ===>>> the problem will disappear. $this->getConditions( $table ), __METHOD__, array( 'STRAIGHT_JOIN', 'ORDER BY' => $fromField, ) ); $this->fullResultCache[$table] = $res; } This information is cached in LinkCache, and later returned by $title->getLatestRevID(). I think it is obviously a bug (but do not know where exactly). Meanwhile, Semantic MediaWiki can be fixed to workaround it: case '_LEDT' : // Do *not* use // $revision = Revision::newFromId( $title->getLatestRevID() ); // being run from maintenance/runJobs.php it causes exceptions because // `$title->getLatestRevID()' returns zero for *existing* page. // Not sure whether it is a MediaWiki bug or not, but using // `Revision::newFromTitle' helps to avid this problem. $revision = Revision::newFromTitle( $title ); $user = User::newFromId( $revision->getUser() ); $value = SMWDIWikiPage::newFromTitle( $user->getUserPage() ); break; Revision::newFromTitle() does not rely on cache, but gets last revision id directly from database. I should be less efficient, but works and does not crash.
Van de Bugger, now that the Semantic MediaWiki extension is hosted in Git and viewable via Gerrit, you can submit your patch directly into the source control system. Simply get a developer access account https://www.mediawiki.org/wiki/Developer_access and then follow this guide: https://www.mediawiki.org/wiki/Git/Workflow The Gerrit project is "mediawiki/extensions/SemanticMediaWiki" and you can view its recent commit history at https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/SemanticMediaWiki.git;a=summary .
*** Bug 41249 has been marked as a duplicate of this bug. ***
Should be fixed by https://gerrit.wikimedia.org/r/#/c/31285/
Change has been merged and issue should be fixed now.
The underlying bug in MediaWiki seems to be Bug 37209 (recording this here for future reference). It is likely that this also leads to wrong data stored about other builtin page properties whenever a refreshJob is updating a page.