Page MenuHomePhabricator

Make "Error creating thumbnail: File missing" error message cover potential other reasons (such as incorrectly set $wg variables)
Open, Needs TriagePublic

Description

As outlined in https://www.mediawiki.org/w/index.php?title=Topic:Vr8hvb7abjg5n17m&topic_showPostId=vr8x3i7wss5ysbgp&fromnotif=1#flow-post-vr8x3i7wss5ysbgp

The message "Error creating thumbnail: File missing" is misleading in cases where it is shown for all files e.g. via "Brows Files". More often than not the reason then is not that the File is missing but that the relevant configuration variables in LocalSettings.php point to the wrong directory or have not been set correctly.

To improve the situation it would be good if the error would include "probably there is a misconfiguration - please contact your administrator" if the message occurs too often and has a link to the appropriate FAQ section in the Manual (which might habe to be added since the link in the support desk reply did not have information about the needed $wg variables.

In my concrete scenario the solution was to add

global $wgWikiFarmSite;
global $wgUploadDirectory;
global $wgUploadPath;
global $wgScriptPath;
$wgUploadDirectory = "/var/www/wikifarm/sites/$wgWikiFarmSite/images";
$wgUploadPath = "$wgScriptPath/images/$wgWikiFarmSite";

to LocalSettings.php or to be more precsise to one of the include files being picked up by the WikiFarm configuration.

Situation
Need for migrating a wiki farm from MediaWiki 1.27.3 to 1.33.4
Action

  • Copy SQL database
  • Copy Image directory
  • Create new code directory with untar of mediawiki-1.33.4.tar.gz
  • Create new LocalSettings.php with installation procedure
  • Split LocalSettings.php with Farm approach so that MyFarmSettings.php is holding the common settings for the farm.
  • Try getting the wiki to run step by step by copying LocalSettings.php code e.g. for extensions from the old MediaWiki 1.27.3 farm

Expected Result
Even if misconfigured e.g. forgetting to set the $wgUploadDirectory or $wgUploadPath properly error messages should indicate where the problem is.
Seen Result
"File Missing" message for each and every file shown in "Browse Files"

LocalSettings.php

php
<?php 
/**
 * MediaWiki wikifarm handling code
 *
 * Taken from Drupal code to tap multisite configuration.
 */

// returns true if $needle is a substring of $haystack
function contains($needle, $haystack)
{
    return strpos($haystack, $needle) !== false;
}

/**
 * Find the appropriate configuration directory for the current request
 */
function findConfiguration($confdir,$domain) {
  if (isset($_SERVER['SERVER_PORT'])) {
    $port = $_SERVER['SERVER_PORT'];
    switch ($port) {
      case 8900: return "wiki1";
      case 8901: return "wiki2";
      case 8902: return "wiki3";  
    }   
  }
  global $wgServer;
  $host=parse_url($wgServer,PHP_URL_HOST);
  if ($host) return $host; else return NULL;
}

/**
 * optionally add the given settings
 */
function optionalRequireSettings($settings) {
  if (file_exists($settings)) {
     require_once($settings);		 
  }
}

# the main configuration directory in which all wiki farm member sites are configured
$confdir = '/var/www/wikifarm/sites';
# The Prefix to use for local/specialized configuration files
$prefix="MyFarm";
# find the configuration for the current request
$domain="my-domain.org";
$conf=findConfiguration($confdir,$domain);
#$conf=NULL;
# if we found a configuration then use it
if ($conf) {
  # make sure all farm members use the same .smw.json file
  # https://www.semantic-mediawiki.org/wiki/Help:$smwgConfigFileDir
  global $smwgConfigFileDir;
  global $wgWikiFarmSite;
  $wgWikiFarmSite=$conf;
  $wgShowExceptionDetails=true;
  $smwgConfigFileDir = $confdir;
  #
  # first use the specific LocalSettings for the site 
  require_once( "$confdir/$conf/LocalSettings.php" );
  # then use the global settings for the farm 
  optionalRequireSettings("$confdir/{$prefix}Settings.php");
  # if there are further specific settings for the site  use them
  optionalRequireSettings("$confdir/$conf/{$prefix}Settings.php");
} else {
    $IP = '.';
    require_once( './includes/DefaultSettings.php' ); # used for printing the version
    require_once( './includes/NoLocalSettings.php' );
    die("wikifarm could not find configuration for $wgServer");
}
?>

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

The issue is in the confusing message "File missing" - it's not true that the file is missing. The configuration is wrong and the pointer to the directory of files is not configured correctly. For a single such message it would not be a problem but if in "browse files" every single image shows the same misleading message "File missing" than that is an issue which should be fixed to allow administrators to get informed about the problem by their users much more quickly and more detailed than is the case right now.

Hi @Seppl2013, please always follow https://www.mediawiki.org/wiki/How_to_report_a_bug and provide

  • a clear and complete list of exact steps to reproduce the situation, step by step, so that nobody needs to guess or interpret how you performed each step,
  • what happens after performing these steps to reproduce,
  • what you expected to happen instead.

In separate sections.

Is this requesting a clearer error message for the thumbnail_error parameter in https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/Linker.php ?
Is this a request to edit https://www.mediawiki.org/wiki/Manual:Errors_and_symptoms#Image_Thumbnails_not_working_and/or_appearing ? If so, feel free to go ahead.
Why is there "again" in the subject line?

You can edit the task description by clicking Edit Task. Ideally, a good description should allow any other person to follow these steps (without having to interpret steps) and see the same results. Thanks.

Is this a request to edit https://www.mediawiki.org/wiki/Manual:Errors_and_symptoms#Image_Thumbnails_not_working_and/or_appearing ? - yes thats's part of the issue and I added a section.

Why is there "again" in the subject line?
A search for ""Error creating thumbnail: File missing"" in your favorite search engine will show quite a few (IMHO mostly not so helpful) entries:

it's not so helpful to have to wade thru all these cases where there have been problems with Thumbnail creation and not have the original error message point to the proper configuration steps.

Seppl2013 updated the task description. (Show Details)
Seppl2013 updated the task description. (Show Details)

Maybe this could be a step in the update.php file to check that there is a reasonable file configuration if lots of files are pointed to in the SQL file but do not properly resolve ..

This comment was removed by Urbanecm.

Bawolff asked on project support desk:
How would mediawiki distinguish between the config being wrong and the file just happening to be missing?

My answer was:

by the sheer numbers. If it happens only a few times it might be by chance. If it happens for all files then the configuration is wrong. The trigger could be something like "at least 20 files" and at least 75% considered missing. So the check would only have to be done for a few dozen files. Changing the message for all cases does also not hurt. It could be "File missing or wiki misconfigured see ..."

Aklapper renamed this task from Error creating thumbnail: File missing - again to Make "Error creating thumbnail: File missing" error message cover potential other reasons (such as incorrectly set $wg variables).Sep 24 2020, 5:53 PM

As it's unclear to me what exactly this task is asking for I took a guess and edit the task summary. Feel free to correct.

The trigger could be something like "at least 20 files" and at least 75% considered missing.

This is way too complicated and very unlikely to happen. I suggest declining, or maybe converting it into a use case for some kind of configuration-checker special page (the idea of a MediaWiki admin/status page was thrown around a lot, although I can't find a task right now). But checks based on data that needs to be averaged across many requests are unlikely to happen.

Still the message could be improved into "File missing or config error" and having a pointer to the FAQ and may be such a checking code or extension.

For future reference, please cover only one single thing per one single task: https://www.mediawiki.org/wiki/How_to_report_a_bug . Thanks.