Page MenuHomePhabricator

Avatar upload page broken
Closed, ResolvedPublic

Description

Author: gerard

Description:
Using MW 1.19-svn and having updated SocialProfile to current svn version, the Special:UploadAvatar page produces the following error:

Warning: Missing argument 1 for SpecialUploadAvatar::loadRequest(), called in [site]/includes/specials/SpecialUpload.php on line 177 and defined in [site]/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php on line 35

Fatal error: Call to a member function getUpload() on a non-object in [site]/includes/upload/UploadFromFile.php on line 21

See: http://www.grandtheftwiki.com/Special:UploadAvatar


Version: unspecified
Severity: major

Details

Reference
bz30953

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:49 PM
bzimport added a project: SocialProfile.
bzimport set Reference to bz30953.

I suppose the most obvious question here would be: why on Earth are you running trunk on a production wiki? :)

IIRC the issue you're seeing is related to the RequestContext stuff and its (more) widespread use in trunk; r96249 and the like. If you're feeling adventurous, feel free to try your hand at fixing it; if not, I'll look at this later on. [[mw:Manual:RequestContext.php]] suggests that RequestContext is available in 1.18, so maybe this can be fixed without coming up with awful backwards-compatibility hacks.

Created attachment 9068
Proposed patch that converts Special:UploadAvatar to use more RequestContext stuff

Maybe you could try the attached patch. I whipped it together really quick, based on r96249, and didn't test it. It looks like it should work, but I'm not too familiar with the RequestContext stuff yet. Please let me know whether it fixes the reported issue or not so that I can consider committing it.

Attached:

gerard wrote:

We like to live on the edge? Using trunk is historical for us, as we needed to up to trunk to fix an issue a while back, and since then every time we see an issue, the first thing I try is svn up to see if it's been fixed since. Never had any huge problems, just little things like this.

Thanks for this - that patch seems to work at least partially, avatars upload fine but the page still throws the same error:

Warning: Missing argument 1 for SpecialUploadAvatar::loadRequest(), called in [site]/includes/specials/SpecialUpload.php on line 177 and defined in [site]/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php on line 32

You should be able to fix that by changing the function definition so that it doesn't take the $request parameter. So change line 32 of extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php from:

protected function loadRequest( $request ) {

to:

protected function loadRequest() {

sumanah wrote:

Inferring that Jack Phoenix has reviewed this patch & marking patch as reviewed. Gerard, have you tried Jack's suggestion in comment 4 ?

scott wrote:

I am also running MW 1.19.0 and have applied the posted patch. I also change the function definition. I no longer get an error, but the upload doesn't do anything either. There are no errors in my logs. What can I do to diagnose this?

Thanks!

In my defense the patch I posted here worked perfectly...when I posted it. Which was many, many months ago.

The big deal here was that as of MediaWiki 1.19.0, the SpecialUpload class (the base class for Special:Upload, which Special:UploadAvatar also extends, because extending is easier than duplicating lots and lots of code) unconditionally requires that the edit token is present. UploadAvatar was not passing the edit token as it wasn't required before, and what you were seeing was an upload silently failing.

I've fixed this in SVN r115379 by applying the patch I posted here and by copypasting a few lines of code from includes/HTMLForm.php. Nasty, but it did the trick.