Topic on Project:Support desk

Can't delete image uploads. "Error deleting file: Could not create directory 'mwstore://local-backend/local-deleted/a/x/b'."

7
TremorAcePV (talkcontribs)

Product Version
MediaWiki 1.23.1
PHP 5.5.9-1ubuntu4.3 (apache2handler)
MySQL 5.5.38-0ubuntu0.14.04.1

Ubuntu Server is running on a Virtual Machine. My /var/www/html/mediawiki/images directory is mounted to my storage drive as the boot drive is only for the OS. The Wiki is private.

LocalSettings.php does not have $wgUploadDirectory or $wgUploadPath set, so those are the default. $wgDeletedDirectory is a mount on another file server which has the same permissions as the images directory. 755 & www-data as both owner & group.

Directory: /var/www/html/mediawiki/images (mounted to a different drive than the rest of /var/www/html/mediawiki) /mnt/fileserver/deletedwikifiles

php.ini has file_uploads set to on and my version means that safe_mode isn't the issue. I read about a bug regarding upgrading MediaWiki from 1.22 to 1.23 causing file uploads to be broken, but that was traced back to shared hosts and this server isn't shared.

Any help is appreciated.

Edit:

I just thought I'd bump this with a bit more technical information. I couldn't delete files, but I could upload them. Then I did the following commands from the root of MediaWiki:

sudo chmod 775 -R ./ [Entire MediaWiki Root has rwxrwxr-x permission set.]
sudo chmod 666 -R ./images [images * subdirectories has rw-rw-rw- permission set.]
sudo chmod 775 ./images [The directory images has rwxrwxr-x permission set.]
sudo chown root:www-data -R ./ [This means Root has full rwx for everything but files in images where it has rw- only while apache web group has rw- for images, but not the directory, and rwx for the rest of MediaWiki's root.]

Then I could delete the files, but when I tried to upload them, I got this error: 'Could not create directory "mwstore://local-backend/local-public/b/b9".' and the thumbnails were broken.

Then I did this command from the same root directory of MediaWiki:

sudo chmod 777 -R ./ [Everything has all the permission for MediaWiki's root directory.]

And once again, I can upload files, and see thumbnails/files, but I can't delete them again, getting 'Error deleting file: Could not create directory "mwstore://local-backend/local-deleted/8/d/b".' when I try.

I'm baffled as to how to troubleshoot what appears to be a permissions problem in this situation after those results.

Florianschmidtwelzow (talkcontribs)
TremorAcePV (talkcontribs)

I figured you might be on to something there because I did the following:

ls -la /mnt/fileserver/deletedwikifiles
drwxrwxrwx  4 root root 4096 Jul 29 10:09 .
drwxrwxrwx  4 root root 4096 Jul 29 10:09 public
drwxrwxrwx  4 root root 4096 Jul 29 10:09 private

So I checked and I hadn't configured /etc/fstab to mount the drive such that www-data is owner/group because it's on an NTFS volume (which means it makes root owner/user by default). I tried redefining $wgDeletedDirectory = $wgScriptPath/images/deleted as a test.

ls -la ./images/deleted

drwxrwxrwx  4 www-data www-data 4096 Jul 29 10:09 .
drwxr-xr-x 14 www-data www-data 4096 Jul 29 09:39 ..
drwxrwxrwx  2 www-data www-data 4096 Jul 29 10:08 private
drwxrwxrwx  2 www-data www-data 4096 Jul 29 10:09 public

Yet it still gives the "Creating directory" error when trying to delete a file. I tried changing the above permissions to 755 (rwxr-xr-x), just like it is for the rest of ./images, but that didn't fix it either.

Ciencia Al Poder (talkcontribs)

You may try creating the directory from the shell, directly, but as the webserver's account, using the sudo command.

If it succeeds, you may also set a debug log to see exactly the full path it's trying to access.

Ciencia Al Poder (talkcontribs)

Note that this command will render your image folders inaccessible:

sudo chmod 666 -R ./images [images * subdirectories has rw-rw-rw- permission set.]

Directories need the execute permission set to be accessible.

Setting 777 for uploaded files is also not recommended.

The recommended way to set such permissions is to use the find command:

find ./images -type d -exec chmod 755 {} \;
find ./images -type f -exec chmod 644 {} \;

Depending on who's the owner of those files, permissions may vary from 777/666 for debugging or even 700/600 for strict permissions on shared hosts.

TremorAcePV (talkcontribs)

That's good to know.

Of course. That was a test to see if I could access them correctly. A test to see if permissions is the problem.

With these permissions, set exactly how you have them written there, I cannot upload or delete files. That's the first time this result has happened. I get both errors:

Could not create directory "mwstore://local-backend/local-public/2/26".
Error deleting file: Could not create directory "mwstore://local-backend/local-deleted/8/d/b".

I figured it might be because I had done this before that:

sudo chown root:www-data ./images

So I tried changing it to this:

sudo chown www-data:www-data ./images

And that let me upload files. Found the culprit there.

Check my response to Florianschmidtwelzow above if you want to know about the deleting files error.

This post was hidden by Ciencia Al Poder (history)