On Sun, May 23, 2010 at 6:58 PM, Bryan Tong Minh <bryan.tongminh@gmail.com> wrote:
On Sun, May 23, 2010 at 6:27 PM, Alexander Kanterakis
<makeabitm@gmail.com> wrote:
> Hi,
> I 've setup mediawiki-1.15.1 with the following hook in LocalSettings.php:
> $wgHooks['EditPage::attemptSave'][] = 'foo';
> Foo is a simple function:
> function foo($editpage) {
> return true;
> }
> With this setup I 've noticed that I cannot save any page with mwclient (ver
> 0.6.4). The call:
> page.save(newText)
> raises the following exception:
>   File "/lib/python2.6/json/decoder.py", line 338, in raw_decode
>     raise ValueError("No JSON object could be decoded")
> ValueError: No JSON object could be decoded
> When I comment out the hook then the save command works properly. Any
> suggestions?
> My system is a OSX 10.6.3
> Thank you
> Alex.
>
> _______________________________________________
> Mediawiki-api mailing list
> Mediawiki-api@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
>
>

Presumably some debug or error message is outputted by MediaWiki. Try
adding a print json_data on line 252 of client.py to see what
mediawiki outputs exactly.


Bryan

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

Indeed, you are right!
The print command revealed a 

<b>Warning</b>:  call_user_func_array() expects parameter 1 to be a valid callback, function 'foo' not found or invalid function name in <b>/Users/alexanderkanterakis/Sites/mediawiki/includes/Hooks.php</b> on line <b>117</b><br />
MediaWiki internal error.<br />

the foo function was included (require_once) in index.php but not in LocalSettings.php. I changed the require_once location and works fine.

Thanks again
Alex