Talk:WikiDB/Files/Hooks.php

From TestWiki
< Talk:WikiDB‎ | Files
Revision as of 11:43, 13 September 2010 by HappyDog (Talk | contribs) (Fixed this item. Going to leave it here for now, as it seems no sense moving it.)

Jump to: navigation, search

[FIXED] function wfWikiDB_ArticleSaveComplete

MediaWiki Server OS PHP MySQL WikiDB
1.15.1 W2k3 Server en 5.3.0 (apache2handler) 5.1.37 $Rev: 177 $
Symptoms
saving a page with a <data> tag shows an error
"Warning: Parameter 3 to wfWikiDB_ArticleSaveComplete() expected to be a reference [...]"
Solution
I removed the reference indicator & from all but the first two parameters of the function definition

Gonesoft 07:50, 13 November 2009 (GMT)

Hi Gonesoft. Are a file/line number for this error message reported? The fix you suggest would work fine for WikiDB, but the description of the bug implies a bug in either the core MW software, or the documentation at MediaWiki.org, so it would be good to have a bit more info in order to ensure it gets sorted out for other users. --HappyDog 21:12, 16 November 2009 (GMT)

Here goes:

Warning: Parameter 3 to wfWikiDB_ArticleSaveComplete() expected to be a reference, value given 
  in C:\xampp\htdocs\wiki\includes\Hooks.php on line 117

Detected bug in an extension! Hook wfWikiDB_ArticleSaveComplete failed to return a value; 
  should return true to continue hook processing or false to abort.

Backtrace:

#0 C:\xampp\htdocs\wiki\includes\Article.php(1779): wfRunHooks('ArticleSaveComp...', Array)
#1 C:\xampp\htdocs\wiki\includes\Article.php(1472): Article->doEdit('<data table="Co...', '', 102)
#2 C:\xampp\htdocs\wiki\includes\EditPage.php(1027): 
  Article->updateArticle('<data table="Co...', '', true, false, false, '')
#3 C:\xampp\htdocs\wiki\includes\EditPage.php(2483): EditPage->internalAttemptSave(false, false)
#4 C:\xampp\htdocs\wiki\includes\EditPage.php(449): EditPage->attemptSave()
#5 C:\xampp\htdocs\wiki\includes\EditPage.php(340): EditPage->edit()
#6 C:\xampp\htdocs\wiki\includes\Wiki.php(510): EditPage->submit()
#7 C:\xampp\htdocs\wiki\includes\Wiki.php(63): MediaWiki->performAction(Object(OutputPage), 
  Object(Article), Object(Title), Object(User), Object(WebRequest))
#8 C:\xampp\htdocs\wiki\index.php(116): MediaWiki->initialize(Object(Title), Object(Article), 
  Object(OutputPage), Object(User), Object(WebRequest))
#9 {main}

hth ... looks to me like there's a constant value passed somewhere in the caller chain. Maybe updateArticle at #2?
Gonesoft 13:10, 17 November 2009 (GMT)

Obviously, it's been some time since this was written, but here's an update:
  1. The actual error in your trace above is here: Detected bug in an extension! Hook wfWikiDB_ArticleSaveComplete failed to return a value;. This arose because wfWikiDB_ArticleSaveComplete() wasn't returning a proper result. In earlier versions of MW, returning nothing indicated everything was OK and that the calling code should continue with the next hook, and returning anything else indicated an error string to be output. At some point this was changed to allow three return values: an error string, if an error occurred; TRUE if the function completed successfully and remaining hooks should be run; and FALSE if the function completed successfully, but remaining hooks should not be run. At this point a check was added for NULL (the old default value) and an error raised in this case, to force extension writers to update to the new system. This was fixed a long time ago in my code, but it was done as part of general fix-up, so I didn't think to update the wiki.
  2. The pass-by-reference warning you were getting appears to have been a documentation problem, as the documentation for ArticleSaveComplete has now been updated to remove the reference indicator. I don't know if this is because MW changed, or whether the documentation was just wrong, but either way it has been fixed there and also in my code.
Thanks for reporting the issue (I wouldn't have spotted and fixed it without you) - sorry about the slow response! :-)
--HappyDog 12:43, 13 September 2010 (BST)