Last modified: 2013-06-13 02:10:19 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T50838, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 48838 - Semantic Forms sfautoedit (and #autoedit) broken in 1.21
Semantic Forms sfautoedit (and #autoedit) broken in 1.21
Status: VERIFIED FIXED
Product: MediaWiki extensions
Classification: Unclassified
SemanticForms (Other open bugs)
master
All All
: Unprioritized major with 2 votes (vote)
: ---
Assigned To: s7eph4n
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-26 14:10 UTC by Jamie Thingelstad
Modified: 2013-06-13 02:10 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jamie Thingelstad 2013-05-26 14:10:55 UTC
When attempting to use the action=sfautoedit API either directly or via the {{#autoedit}} method it fails with a 400 error and the following error message is delivered:

{"errors":[{"level":0,"message":"Format json is not supported for content model wikitext"}],"responseText":"Modifying <a href=\"\/wiki\/From_Here_You_Can_See_Everything\" title=\"From Here You Can See Everything\">From Here You Can See Everything<\/a> failed.","status":400,"form":{"title":"Bookmark"},"target":"From Here You Can See Everything"}

I assume this is related to the new content model work in 1.21.
Comment 1 Yaron Koren 2013-05-26 18:39:53 UTC
Re-assigning to f.trott.
Comment 2 Jamie Thingelstad 2013-05-29 16:17:48 UTC
*bump*

Hoping that this can get some attention soonish. I looked at the code myself but it's a bit mysterious. This breaks all #autoedit functionality in Semantic Forms.
Comment 3 Jamie Thingelstad 2013-06-02 02:29:11 UTC
Digging a little further (this bug is causing me troubles, want to try and fix) and I don't see this error message anywhere in Semantic Forms. It is however in the core codebase in AbstractContent.php at

https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blob;f=includes/content/AbstractContent.php;hb=41bd1fee921eeb802ed2cea9431be479eb51a0ba#l140

and ContentHandler.php at

https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blob;f=includes/content/ContentHandler.php;hb=41bd1fee921eeb802ed2cea9431be479eb51a0ba#l550

Not sure if that helps, but that is where the stack trace is going to end.
Comment 4 Jamie Thingelstad 2013-06-02 04:41:24 UTC
It does seem that one issue is in setupEditPage in SF_AutoeditAPI.php on line 324. The call to $wgUser->editToken() is deprecated and appears like it should be $wgUser->getEditToken() instead.

- 'wpEditToken' => $wgUser->isLoggedIn() ? $wgUser->editToken() : EDIT_TOKEN_SUFFIX,
+ 'wpEditToken' => $wgUser->isLoggedIn() ? $wgUser->getEditToken() : EDIT_TOKEN_SUFFIX,

However, I'm still getting errors but they are different now.
Comment 5 Jamie Thingelstad 2013-06-02 04:42:17 UTC
(In reply to comment #4)
> It does seem that one issue is in setupEditPage in SF_AutoeditAPI.php on line
> 324. The call to $wgUser->editToken() is deprecated and appears like it
> should
> be $wgUser->getEditToken() instead.
> 
> - 'wpEditToken' => $wgUser->isLoggedIn() ? $wgUser->editToken() :
> EDIT_TOKEN_SUFFIX,
> + 'wpEditToken' => $wgUser->isLoggedIn() ? $wgUser->getEditToken() :
> EDIT_TOKEN_SUFFIX,
> 
> However, I'm still getting errors but they are different now.

Just to clarify, I determined that from this stack trace captured in the JSON encoded error from MW.


<div class=\"mw-debug-backtrace\">
Backtrace:
<ul>
    <li>Debug.php line 221 calls wfBacktrace()</li>
    <li>GlobalFunctions.php line 1091 calls MWDebug::deprecated()</li>
    <li>User.php line 3473 calls wfDeprecated()</li>
    <li>SF_AutoeditAPI.php line 324 calls User->editToken()</li>
    <li>SF_AutoeditAPI.php line 879 calls SFAutoeditAPI->setupEditPage()</li>
    <li>SF_AutoeditAPI.php line 116 calls SFAutoeditAPI->doAction()</li>
    <li>ApiMain.php line 840 calls SFAutoeditAPI->execute()</li>
    <li>ApiMain.php line 380 calls ApiMain->executeAction()</li>
    <li>ApiMain.php line 351 calls ApiMain->executeActionWithErrorHandling()</li>
    <li>api.php line 77 calls ApiMain->execute()</li>
</ul>
</div>

type":"deprecated","caller":"SFAutoeditAPI::setupEditPage",
Comment 6 Jamie Thingelstad 2013-06-02 05:34:28 UTC
After making the above change I'm no longer getting a stack trace in the error output, however, the error remains the same message:

  "message": "Format json is not supported for content model wikitext"

with a 400 error. Some further debugging here. The error message sf_autoedit_fail that is thrown is only referenced in two places in SF_AutoeditAPI.php. The one that is triggered is the one on line 557.

Also worth noting that there is another editToken reference that needs changing in SF_Utils.php on line 226.
Comment 7 Jamie Thingelstad 2013-06-02 06:28:15 UTC
Okay, after adding a lot of wfDebug calls in SF_AutoeditAPI.php I've tracked down that an exception is being thrown in doStore() on the call

    $status = $editor->internalAttemptSave( $resultDetails, $bot );

Once this line is hit an exception is thrown. Now I need to sleep. :-)
Comment 8 Jamie Thingelstad 2013-06-02 12:45:39 UTC
FWIW, this is the actual stack trace once it hit me that I should just remove the try/catch that was hiding it.

#0 /srv/www/mediawiki/public_html/w/includes/content/WikitextContentHandler.php(38): ContentHandler->checkFormat('json')
#1 /srv/www/mediawiki/public_html/w/includes/content/ContentHandler.php(159): WikitextContentHandler->unserializeContent('{{Bookmark?|Tit...', 'json')
#2 /srv/www/mediawiki/public_html/w/includes/EditPage.php(2071): ContentHandler::makeContent('{{Bookmark?|Tit...', Object(Title), 'wikitext', 'json')
#3 /srv/www/mediawiki/public_html/w/includes/EditPage.php(1360): EditPage->toEditContent('{{Bookmark?|Tit...')
#4 /srv/www/mediawiki/public_html/w/extensions/SemanticForms/includes/SF_AutoeditAPI.php(432): EditPage->internalAttemptSave(false, false)
#5 /srv/www/mediawiki/public_html/w/extensions/SemanticForms/includes/SF_AutoeditAPI.php(908): SFAutoeditAPI->doStore(Object(EditPage))
#6 /srv/www/mediawiki/public_html/w/extensions/SemanticForms/includes/SF_AutoeditAPI.php(118): SFAutoeditAPI->doAction()
#7 /srv/www/mediawiki/public_html/w/includes/api/ApiMain.php(840): SFAutoeditAPI->execute()
#8 /srv/www/mediawiki/public_html/w/includes/api/ApiMain.php(380): ApiMain->executeAction()
#9 /srv/www/mediawiki/public_html/w/includes/api/ApiMain.php(351): ApiMain->executeActionWithErrorHandling()
#10 /srv/www/mediawiki/public_html/w/api.php(77): ApiMain->execute()
#11 {main}

Also worth noting Bug 41497, which is the only other instance Google can find of this issue.
Comment 9 Jamie Thingelstad 2013-06-02 18:21:24 UTC
Just noting here this line from the Content Handler manual page [1]:

"For editing however, non-text content is not supported per default. EditPage and the respective handlers in the web API are changed to fail for non-textual content."

Seems like a hint to the issue since the exception that is thrown follows a path through EditPage.

[1] http://www.mediawiki.org/wiki/Manual:ContentHandler
Comment 10 Jamie Thingelstad 2013-06-10 20:31:09 UTC
*bump* this is still outstanding and causes issues for anyone using Semantic Forms on the newest release.
Comment 11 Gerrit Notification Bot 2013-06-12 21:12:06 UTC
Related URL: https://gerrit.wikimedia.org/r/68287 (Gerrit Change Ia0b5dcb1e0a7c75fca1479b719ddf59fb9a79358)
Comment 12 Gerrit Notification Bot 2013-06-12 21:14:12 UTC
https://gerrit.wikimedia.org/r/68287 (Gerrit Change Ia0b5dcb1e0a7c75fca1479b719ddf59fb9a79358) | change APPROVED and MERGED [by Foxtrott]
Comment 13 s7eph4n 2013-06-12 21:18:31 UTC
Should be fixed. Please re-open if not.
Comment 14 Jamie Thingelstad 2013-06-13 02:10:19 UTC
Applied diff and confirmed fixed! And there was mass cheering! :-)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links