Manual talk:$wgHashedUploadDirectory
Contents |
changing an existing configuration [edit]
You will receive following error (MW 1.9.2)
Warning: imagecreatefrompng(E:\Programme\xampp\htdocs\w/images/1_GrafikTest_01_1024.png) [function.imagecreatefrompng]: failed to open stream: No such file or directory in E:\Programme\xampp\htdocs\w\includes\Image.php on line 1266 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in E:\Programme\xampp\htdocs\w\includes\Image.php on line 1274 Fatal error: imagepng() [<a href='function.imagepng'>function.imagepng</a>]: gd-png: fatal libpng error: Invalid number of colors in palette in E:\Programme\xampp\htdocs\w\includes\Image.php on line 1275
Moving to the system [edit]
Does anyone have a script which runs through the uploads dir and files existing images into this new structure? I have way too many images just in the image folder, but there does not seem to be a migration path. --ThePlaz 07:14, 10 March 2010 (UTC)
Script [edit]
Thanx to Platonides !!mailarchive:mediawiki-l/2010-April/033779.html Make a backup archive of the images folder first ! Btw. this script should not touch subdirectories you may use for some extension scripts.
moveToHashed.php <?php $hashLevels = 2; $dir = opendir("."); while (($file = readdir($dir)) !== false) { if (!is_file($file)) continue; echo "$file\n"; $md5 = md5($file); $hexString = substr($md5, 0, $hashLevels ); $folder = ""; while (strlen($hexString) > 0) { $folder = "$hexString/$folder"; $hexString = substr($hexString, 0, - 1); } mkdir($folder, 0777, true); rename($file, "$folder$file"); } closedir($dir); ?>
Changes / manual work:
- You may have to modify permissions, e.g.
mkdir($folder, 0755, true); chown($folder, "www-data"); chgrp($folder, "www-data");
- then manually fix the owner of the top level directories
chown www-data:www-data *
- Then get rid of the contents of the thumb subdirectory, except "archive" ? (thumbs subdirectories will be automatically re-generated when users access pages)
- Finally make sure that the cashes you use are emptied, e.g. "TRUNCATE TABLE objectcache;" in the MySQL database and kill the files in the file-cache subdirectory.
What is the virtue of using hashed upload directories [edit]
The one-liner, "If true, use the /a/ab/foo.png directory structure." does not describe any virtues.
Given that this decision is best made before any images are uploaded to a newly created wiki, I think that this article should describe the pros and cons of specifying $wgHashedUploadDirectory = true;
Newcomers to MediaWiki installation and configuration will then be able to make a decision appropriate to the expected size and traffic for a new wiki. Najevi 17:40, 26 September 2010 (UTC)