A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.

All images are inaccessible

freephile

Continuing the discussion from [MediaWiki-l] Mod_rewrite broke my images?: (because I can’t reply to nor edit the original)

As described above, images are stored outside document root, and thus I’m using img_auth.php to access all images. However all images are ‘missing’. I’m at a loss as to why none of these images are available. I’ve tried all sorts of combinations of $wgUploadDirectory and $wgUploadPath. I’ve gone through the documentation on configuring file uploads. I’ve checked obvious things like directory ownership (www-data on Debian) and permissions.

Ultimately, the challenge is to have 11 language wikis (with 11 databases) all accessible on a farm with ‘Pretty URLS’ like so:

https://www.familysearch.org/wiki/en/Main_Page
protocol      domain          ^   ^     article
                              |   | wikiId
                    placeholder
freephile

Here’s an example of a page view trying to render thumbnails on the fly, but it can’t because it can’t get a handled on the original file.

File::transform: Doing stat for mwstore://local-backend/local-thumb/5/59/Geographylogo.png/20px-Geographylogo.png
[FileOperation] FileBackendStore::getFileStat: File mwstore://local-backend/local-thumb/5/59/Geographylogo.png/20px-Geographylogo.png does not exist
TransformationalImageHandler::doTransform: creating 20x20 thumbnail at /tmp/transform_636897ea7385.png using scaler im
TransformationalImageHandler::doTransform: returning unscaled image
File::transform: Doing stat for mwstore://local-backend/local-thumb/5/59/Geographylogo.png/20px-Geographylogo.png
TransformationalImageHandler::doTransform: creating 20x20 thumbnail at /tmp/transform_2be09c7f9ccd.png using scaler im
TransformationalImageHandler::doTransform: returning unscaled image
File::transform: Doing stat for mwstore://local-backend/local-thumb/5/59/Geographylogo.png/20px-Geographylogo.png
TransformationalImageHandler::doTransform: creating 20x20 thumbnail at /tmp/transform_0b57301bf432.png using scaler im
TransformationalImageHandler::doTransform: returning unscaled image

My understanding is that mwstore://local-backend should equal $wgUploadDirectory. I’ve set $wgUploadDirectory to where these files are stored*, but it’s as if the wrong value is being returned for $wgUploadDirectory, because the web server can’t find the files.

  • Setting wgUploadDirectory to /opt/data-meza/uploads/en
Ciencia-Al-Poder

The log doesn’t display any error.

What happens when you open img_auth.php from the browser with a known image? Does it display any error? If it displays a cryptic error, try adding $wgShowExceptionDetails = true; in LocalSettings.php

freephile

This should work because $wgUploadDirectory is set to /opt/data-meza/uploads/en
https://fswiki.qualitybox.us/en/img_auth.php/5/59/Geographylogo.png

Alternatives do not work either:
https://fswiki.qualitybox.us/en/img_auth.php/en/5/59/Geographylogo.png
https://fswiki.qualitybox.us/en/img_auth.php/uploads/en/5/59/Geographylogo.png
https://fswiki.qualitybox.us/en/img_auth.php/data-meza/uploads/en/5/59/Geographylogo.png
https://fswiki.qualitybox.us/en/img_auth.php/opt/data-meza/uploads/en/5/59/Geographylogo.png

The file Geographylogo.png exists on the filesystem, is readable by all, owned by www-data and the filesystem is traversable:

namei -l /opt/data-meza/uploads/en/5/59/Geographylogo.png
f: /opt/data-meza/uploads/en/5/59/Geographylogo.png
drwxr-xr-x root         root     /
drwxr-xr-x root         root     opt
lrwxrwxrwx root         root     data-meza -> /mnt/volume_nyc1_01/data/data-meza
drwxr-xr-x root         root       /
drwxr-xr-x root         root       mnt
drwxr-xr-x root         root       volume_nyc1_01
drwxr-xr-x root         root       data
drwxr-xr-x meza-ansible wheel      data-meza
drwxrwxr-x www-data     www-data uploads
drwxrwxr-x www-data     www-data en
drwxrwxr-x www-data     www-data 5
drwxrwxr-x www-data     www-data 59
-rw-rw-r-- www-data     www-data Geographylogo.png

freephile

I intentionally try to avoid any issues with mod_rewrite with the following:

    RewriteCond %{REQUEST_URI} /img_auth\.php/ 
    RewriteRule ^ - [env=WIKI:en,L] 
freephile

I used the maintenance script to check images WIKI=en php /opt/htdocs/mediawiki/maintenance/checkImages.php

(output trimmed)
Good images: 0/52307

I modified checkImages.php to show me the ‘path’ that it’s using to retrieve images
Geographylogo.png: missing at <$path>
Geographylogo.png: missing at mwstore://local-backend/local-public/5/59/Geographylogo.png

freephile

I’ve looked into includes/libs/filebackend/FileBackend

All “storage paths” are of the format “mwstore://<backend>/<container>/<path>”.
The “backend” portion is unique name for the application to refer to a backend, while
the “container” portion is a top-level directory of the backend. The “path” portion
is a relative path that uses UNIX file system (FS) notation, though any particular
backend may not actually be using a local filesystem. Therefore, the relative paths
are only virtual.

So, next I’m looking for what/how the container ‘local-public’ is handled.

freephile

for the record, this is what I get when trying to upload:

Could not open lock file for “mwstore://local-backend/local-public/a/a0/Screenshot-database-staging-stress-test.jpg”. Make sure your upload directory is configured correctly and your web server has permission to write to that directory. See https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:$wgUploadDirectory for more information.

I tried setting my upload directory to the default. Of course I checked permissions and ownership of the directory.

freephile

I found that I had another PHP file, which I was unaware of, overriding the setting for $wgUploadDirectory.