Page MenuHomePhabricator

Some valid MySQL database names (with a + plus sign in it) break thumbnails
Closed, DuplicatePublic

Description

I recently upgraded a MediaWiki from the 1.15 era to 1.24.2. Most things worked fine, however, all
previously existing thumbnails failed to appear, with errors indicating that the file was missing.
When MediaWiki tried to recreate the thumbnails, it also claimed that it was unable to find the
local sources for them. Debugging indicates that the mwstore:// URLs for the thumbnails are
not being converted into local filesystem paths (false ends up being returned).

A colleague has identified that the problem is in the file includes/filebackend/FileBackendStore.php
in the function isValidContainerName where it checks the container name against the following regex:

return preg_match( '/^[a-z0-9][a-z0-9-_]{0,199}$/i', $container );

My database name has a plus sign ('+') in it. This is valid in MySQL, and is required by my
hosting provider. Apparently back around MediaWiki 1.17, it was errantly thought that a plus
sign was not valid in a DB name, and that was later corrected in most places, but this
regex was missed. I'm not sure if there are other characters that cause this problem.

Steps to reproduce:

  1. Install MW 1.15
  2. Upload some files, include some thumbnails in a couple pages
  3. Upgrade to MW 1.24.2
  4. Notice that thumbnails have disappeared and can't be regenerated

This also probably happens with a fresh install and likely breaks uploads.

Adding the plus sign to the above regex remedies the problem.

Event Timeline

Mitchbmit created this task.Apr 3 2015, 6:48 PM
Mitchbmit raised the priority of this task from to Needs Triage.
Mitchbmit updated the task description. (Show Details)
Mitchbmit added a project: MediaWiki-General.
Mitchbmit added a subscriber: Mitchbmit.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 3 2015, 6:48 PM
Aklapper renamed this task from Some valid MySQL database names break thumbnails to Some valid MySQL database names (with a + plus sign in it) break thumbnails.Apr 7 2015, 3:49 PM
Aklapper triaged this task as Low priority.
Aklapper edited projects, added MediaWiki-File-management; removed MediaWiki-General.
Aklapper set Security to None.
Restricted Application added a project: Multimedia. · View Herald TranscriptApr 7 2015, 3:49 PM
Tgr added a subscriber: Tgr.Apr 7 2015, 4:34 PM

This is not related to MySQL but to the abstraction layer added in 1.19. Some backend implementations do not support non-alphanumeric container names.