#10877 Fedora Wiki image upload not working (fatal internal error)
Closed: Fixed 2 years ago by jflory7. Opened 2 years ago by jflory7.

Summary

Uploading an image using the Fedora MediaWiki image uploader triggers a PHP error

Background

I am trying to upload a new version of this image file on the Fedora Wiki. However, whenever I go to upload a new revision, I get a fatal error and the image is not updated. I also noted that the current image does not show up in the file history as a revision. I think the previous upload may have been interrupted and there could be an issue with database schema. The exact trigger is unknown. I have not tried this with other images to see if it is just this image or for all images.

Details

This is the stacktrace I get from MediaWiki after uploading:

[YxDoZEytQnGTQO2AYItznwAAAMo] /wiki/Special:Upload TypeError: ParserOptions::newFromUserAndLang(): Argument #2 ($lang) must be of type Language, null given, called in /usr/share/mediawiki/includes/filerepo/file/LocalFile.php on line 2553

Backtrace:

from /usr/share/mediawiki/includes/parser/ParserOptions.php(1100)
#0 /usr/share/mediawiki/includes/filerepo/file/LocalFile.php(2553): ParserOptions::newFromUserAndLang()
#1 /usr/share/mediawiki/extensions/fedmsg-emit.php(267): LocalFile->getDescriptionText()
#2 /usr/share/mediawiki/includes/HookContainer/HookContainer.php(338): upload_complete()
#3 /usr/share/mediawiki/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook()
#4 /usr/share/mediawiki/includes/HookContainer/HookRunner.php(3979): MediaWiki\HookContainer\HookContainer->run()
#5 /usr/share/mediawiki/includes/upload/UploadBase.php(966): MediaWiki\HookContainer\HookRunner->onUploadComplete()
#6 /usr/share/mediawiki/includes/specials/SpecialUpload.php(613): UploadBase->performUpload()
#7 /usr/share/mediawiki/includes/specials/SpecialUpload.php(244): SpecialUpload->processUpload()
#8 /usr/share/mediawiki/includes/specialpage/SpecialPage.php(647): SpecialUpload->execute()
#9 /usr/share/mediawiki/includes/specialpage/SpecialPageFactory.php(1366): SpecialPage->run()
#10 /usr/share/mediawiki/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#11 /usr/share/mediawiki/includes/MediaWiki.php(930): MediaWiki->performRequest()
#12 /usr/share/mediawiki/includes/MediaWiki.php(564): MediaWiki->main()
#13 /usr/share/mediawiki/index.php(53): MediaWiki->run()
#14 /usr/share/mediawiki/index.php(46): wfIndexMain()
#15 {main}

Outcome

Successfully add a new revision to an existing file on the Fedora Wiki


Metadata Update from @phsmoura:
- Issue priority set to: Waiting on Assignee (was: Needs Review)
- Issue tagged with: low-gain, low-trouble, ops

2 years ago

I was investigating this and seems that $wgLanguageCode is never defined, receiving NULL instead and generating this error.

I might be wrong on this, did some tests uploading images before reading the code. So if anyone else is interested solving this feel free to do it, otherwise I'll keep working on this next week

Hi all, I ran into this again while trying to update an image on the Fedora Wiki. Was there any success in triaging this further?

So I have been working with phsmoura on this. I think it is a 'bug' in mediawiki from code which was valid in PHP7 but acts different in PHP8. We are tickling it with some even older code in our fedmsg call.

The routine with the problem is /usr/share/mediawiki/includes/filerepo/file/LocalFile.php and has this declaration:

        public function getDescriptionText( Language $lang = null ) {

Our older code is /usr/share/mediawiki/extensions/fedmsg-emit.phpwhich has

    "description" => $image->getLocalFile()->getDescriptionText(),

which would work with older PHP. Somewhere in how the Language type is declared no longer allows 'null' as a subtype so we can try a different declaration. My suggestion is to change the emit to:

    "description" => $image->getLocalFile()->getDescriptionText(new Language()),

which should create an empty object of Language type. It may also blow up other things.. the other fix would be to change the original mediawiki call to be:

        public function getDescriptionText( Language|null $lang ) {

Thanks for the quick follow-up! Once this is deployed, please ping again and I can try updating the problematic image where I keep bumping into this.

@jflory7 can you please try updating again? Should work this time

No luck. When I update my profile picture in the wiki, this is the stacktrace I received:

[Y8lTUD0XTcBzNp5qyIG_lgAAABU] /wiki/Special:Upload TypeError: ParserOptions::newFromUserAndLang(): Argument #2 ($lang) must be of type Language, null given, called in /usr/share/mediawiki/includes/filerepo/file/LocalFile.php on line 2560

Backtrace:

from /usr/share/mediawiki/includes/parser/ParserOptions.php(1100)
#0 /usr/share/mediawiki/includes/filerepo/file/LocalFile.php(2560): ParserOptions::newFromUserAndLang()
#1 /usr/share/mediawiki/extensions/fedmsg-emit.php(267): LocalFile->getDescriptionText()
#2 /usr/share/mediawiki/includes/HookContainer/HookContainer.php(338): upload_complete()
#3 /usr/share/mediawiki/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook()
#4 /usr/share/mediawiki/includes/HookContainer/HookRunner.php(3979): MediaWiki\HookContainer\HookContainer->run()
#5 /usr/share/mediawiki/includes/upload/UploadBase.php(966): MediaWiki\HookContainer\HookRunner->onUploadComplete()
#6 /usr/share/mediawiki/includes/specials/SpecialUpload.php(613): UploadBase->performUpload()
#7 /usr/share/mediawiki/includes/specials/SpecialUpload.php(244): SpecialUpload->processUpload()
#8 /usr/share/mediawiki/includes/specialpage/SpecialPage.php(647): SpecialUpload->execute()
#9 /usr/share/mediawiki/includes/specialpage/SpecialPageFactory.php(1366): SpecialPage->run()
#10 /usr/share/mediawiki/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#11 /usr/share/mediawiki/includes/MediaWiki.php(932): MediaWiki->performRequest()
#12 /usr/share/mediawiki/includes/MediaWiki.php(563): MediaWiki->main()
#13 /usr/share/mediawiki/index.php(53): MediaWiki->run()
#14 /usr/share/mediawiki/index.php(46): wfIndexMain()
#15 {main}

OK looking at things I think this is a bug in mediawiki but I am not sure. The entry into the function says it should accept either an empty object or NULL. It however does not. Three paths forward:

  1. find someone who knows PHP to figure out what we are doing wrong.
  2. change
    "description" => $image->getLocalFile()->getDescriptionText(new Language()),
    to
    "description" => $image->getLocalFile()->getDescriptionText(new Language( 'en' )),
  3. change that line to
    "description" => "Unknown due to us not knowing PHP"

Maybe the error is not affetcting all users anymore. I tryed to upload a new version of a file in both wikis stg and prod and it worked after updating fedmsg-emit.php.

@jflory7 Asking just to understand how you're doing it and reproduce the error. Are you using fedora wiki in english or you changed the language? To upload a new version are you clicking in Upload a new version of this file?

@jflory7 before answering these questions, can you please try again?

I forgot to apply the changes to all wiki servers, maybe that's why it worked when I tested it, but it didn't work for you. Sorry about that.

But if the error persists, we will need more information to continue investigating.

@phsmoura I tried again and received a new stacktrace (below). Also, I was thinking, this specific file seems to have a corrupt file history, i.e. I cannot see updates to this image yet somehow it does seem to change after some time, when I upload an image. Perhaps there is something fishy with this particular file?

For the record, I am using the Fedora Wiki in English and to upload a new version, I am clicking Upload a new version of this file.

[Y86WOSm0yraVpqhqO5-zNgAAAA0] /wiki/File:Jwf_wiki.jpeg TypeError: imagesx(): Argument #1 ($image) must be of type GdImage, bool given

Backtrace:

from /usr/share/mediawiki/includes/media/BitmapHandler.php(477)
#0 /usr/share/mediawiki/includes/media/BitmapHandler.php(477): imagesx()
#1 /usr/share/mediawiki/includes/media/TransformationalImageHandler.php(260): BitmapHandler->transformGd()
#2 /usr/share/mediawiki/includes/filerepo/file/File.php(1320): TransformationalImageHandler->doTransform()
#3 /usr/share/mediawiki/includes/filerepo/file/File.php(1272): File->generateAndSaveThumb()
#4 /usr/share/mediawiki/includes/page/ImageHistoryList.php(304): File->transform()
#5 /usr/share/mediawiki/includes/page/ImageHistoryList.php(240): ImageHistoryList->getThumbForLine()
#6 /usr/share/mediawiki/includes/page/ImageHistoryPseudoPager.php(137): ImageHistoryList->imageHistoryLine()
#7 /usr/share/mediawiki/includes/page/ImagePage.php(838): ImageHistoryPseudoPager->getBody()
#8 /usr/share/mediawiki/includes/page/ImagePage.php(183): ImagePage->imageHistory()
#9 /usr/share/mediawiki/includes/actions/ViewAction.php(80): ImagePage->view()
#10 /usr/share/mediawiki/includes/MediaWiki.php(542): ViewAction->show()
#11 /usr/share/mediawiki/includes/MediaWiki.php(320): MediaWiki->performAction()
#12 /usr/share/mediawiki/includes/MediaWiki.php(932): MediaWiki->performRequest()
#13 /usr/share/mediawiki/includes/MediaWiki.php(563): MediaWiki->main()
#14 /usr/share/mediawiki/index.php(53): MediaWiki->run()
#15 /usr/share/mediawiki/index.php(46): wfIndexMain()
#16 {main}

While I was able to update the image, now I receive an error any time I open this file. I am no longer able to update it.

https://fedoraproject.org/wiki/File:Jwf_wiki.jpeg

Sigh.. this looks like a bunch of type errors due to the mediawiki we are using not fully transitioning to PHP-8.x and Fedora using PHP-8.x. This is a lot of whack-a-mole development needed to make the 1.37 on the wiki boxes to work properly. The current LTS mediawiki is 1.39 which is only in rawhide.

Options:
1. Rebuild mediawiki-1.39 from rawhide onto Fedora 37. Update wiki01.stg to Fedora 37 and install that version of mediawiki and plugins
2. Update wiki01.stg to rawhide and install the version of mediawiki and plugins there.
3. Wait until F38 is branched for beta or released and move wiki01.stg to that
4. Try and rebuild mediawiki-1.39 to Fedora 36. Update wiki01.stg to this infra version of mediawiki.

Then test to see if it fixes the issues Justin is running into. If they are still there, then open these as upstream bugs with mediawiki and fix. If not, start plan to update main wiki to a workable solution.

I have no idea how widespread this is or not (I still suspect that I put this file into an odd state many moons ago), but I can't imagine it is that urgent. If we suspect 1.39 will fix this problem and the package update is already in Rawhide, I see no harm for just waiting until F38 to branch and then testing.

I choose the option that is the least work! :smiley:

Looking in /mnt/web/attachments I see you have various archived versions of the jpeg and they all seem to be ok in regular permissions

-rw-r--r--. 1 apache apache  39893 Oct 18  2020 './archive/f/f4/20201018182635!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache 265419 Oct 18  2020 './archive/f/f4/20201018183350!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache  23410 Apr  8  2021 './archive/f/f4/20210408204803!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache  38277 Apr  8  2021 './archive/f/f4/20210408214300!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache 121228 Aug  7 17:09 './archive/f/f4/20220807170959!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache 979847 Aug  7 17:10 './archive/f/f4/20220807171028!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache  59343 Aug  7 17:10 './archive/f/f4/20220807171037!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache  59343 Sep  1 17:13 './archive/f/f4/20220901171327!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache  38601 Sep  1 17:14 './archive/f/f4/20220901171412!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache  38601 Jan 19 14:27 './archive/f/f4/20230119142729!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache  59343 Jan 23 14:14 './archive/f/f4/20230123141415!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache 167061 Jan 23 14:17 './archive/f/f4/20230123141719!Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache  38601 Jan 23 14:17  ./f/f4/Jwf_wiki.jpeg
-rw-r--r--. 1 apache apache   3280 Oct 18  2020 './thumb/archive/f/f4/20201018182635!Jwf_wiki.jpeg/120px-Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache   2968 Oct 18  2020 './thumb/archive/f/f4/20201018183350!Jwf_wiki.jpeg/120px-Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache   2933 Apr  8  2021 './thumb/archive/f/f4/20210408204803!Jwf_wiki.jpeg/120px-Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache   4161 Apr  8  2021 './thumb/archive/f/f4/20210408214300!Jwf_wiki.jpeg/120px-Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache   3911 Jan 23 14:17 './thumb/archive/f/f4/20230123141719!Jwf_wiki.jpeg/120px-Jwf_wiki.jpeg'
-rw-r--r--. 1 apache apache   3857 Jan 23 14:17  ./thumb/f/f4/Jwf_wiki.jpeg/120px-Jwf_wiki.jpeg

Sigh.. this looks like a bunch of type errors due to the mediawiki we are using not fully transitioning to PHP-8.x and Fedora using PHP-8.x. This is a lot of whack-a-mole development needed to make the 1.37 on the wiki boxes to work properly. The current LTS mediawiki is 1.39 which is only in rawhide.

We don't care about LTS here since we run on Fedora. ;)

Is it fixed in 1.38? (the version in F37)?

Options:
...

  1. Upgrade to f37 and hopefully it's fixed in 1.38? :) ?

I don't know if it is fixed.. The main reason for looking at the LTS was that they seem to focus more fixes on that then non-LTS code so my hope was these sorts of type errors would get fixed there versus 'new' feature items which later versions have.

Metadata Update from @phsmoura:
- Issue assigned to phsmoura

2 years ago

I was thinking about this, and I think there is an easyfix we can apply here unless this issue is a catchall for other similar issues for the Fedora Wiki.

Could someone delete the following image from MediaWiki, and then I can upload a new file from scratch to this filename? I want to preserve this filename because I use the Fedora Wiki as a base to update my avatar on other sites and services, so keeping this filename saves me trouble from updating other sites and some wiki pages with a new filename. The historical images from past revisions are not important to me and could be purged.

https://fedoraproject.org/wiki/File:Jwf_wiki.jpeg

If this file can be deleted and then I reupload, this addresses my need from the original ticket comment.

@jflory7 sorry I didnt see your message earlier. Sure, we can try that!

Along this week until yesterday I tryed to remove your image, change its format a few times, uploaded again and the issue persists.

Seems that you are the only user with that error, because I tryed to upload a new version like you and it worked fine. Also, other users dont have errors when trying to access their page. So, lets try your suggestion. I just removed your image and you can try to reupload on your side. Also I have no more ideas what could be done to fix this

I still get the TypeError message when I open this image page. I guess there is not much more that MediaWiki provides for purging this file, is there?

If the file was deleted and nothing more can be done, I will accept that this file path is lost and I will re-upload to a new one. It is annoying that MediaWiki does not have a way to purge the file but I can update the other places on the Internet where this file was being embedded.

I don't see where it was deleted. I just deleted it. Maybe it will work now?

@nb++ Woohoo! Looks like it worked. I was able to upload a new image, the file history isn't corrupted like before, and all seems well.

https://fedoraproject.org/wiki/File:Jwf_wiki.jpeg

I am satisfied and I think this can be closed. I will close it unless anyone objects otherwise.

Metadata Update from @jflory7:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Log in to comment on this ticket.

Metadata
Boards 1
ops Status: Backlog