• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Not a bug Possible bug with avatars

Romchik®

Well-known member
#1
I'm not sure this is a bug in the XF or the server.
One user complains. He has in the error log:
Code:
rename(/***/forum/data/avatars/l/0/1.jpg) [<a href='function.rename'>function.rename</a>]: Operation not permitted

File: library/XenForo/Model/Avatar.php:302
Stack Trace
Code:
#0 [internal function]: XenForo_Application::handlePhpError(2, 'rename(/var/tmp...', '/usr/home/pva...', 302, Array)
#1 /***/forum/library/XenForo/Model/Avatar.php(302): rename('/var/tmp/phpj2C...', '/usr/home/pva...')
#2 /***/forum/library/XenForo/Model/Avatar.php(189): XenForo_Model_Avatar->_writeAvatar(1, 'l', '/var/tmp/phpj2C...')
#3 /***/forum/library/XenForo/Model/Avatar.php(67): XenForo_Model_Avatar->applyAvatar(1, '/var/tmp/phpj2C...', 3, 152, 155, Array)
#4 /***/forum/library/XenForo/ControllerPublic/Account.php(482): XenForo_Model_Avatar->uploadAvatar(Object(XenForo_Upload), 1, Array)
#5 /***/forum/library/XenForo/FrontController.php(303): XenForo_ControllerPublic_Account->actionAvatarUpload()
#6 /***/forum/library/XenForo/FrontController.php(132): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#7 /***/forum/index.php(15): XenForo_FrontController->run()
#8 {main}
chmod - 777.
With attachments he did not have a problems or errors.

And this change fixes his problem.
library/XenForo/Model/Avatar.php:302 :
PHP:
            $success = rename($tempFile, $filePath);
>>>>>>>>
            $success = @rename($tempFile, $filePath);
 

Mike

XenForo developer
Staff member
#2
That just silences the error - that's an error coming from the OS itself, so it's indicating that the rename doesn't work. If the rename goes through, then that's very misleading and may be an issue in the file system (permissions, perhaps in the temp area).

In very old versions, apparently rename couldn't move across partitions and this error could happen, but that was changed many years ago. I do see that move_uploaded_file (which can be used for attachments) uses some different code, but the same thing should be used for both attachment thumbs and avatars. If image attachments work, I suspect that there is a permission issue at play.
 

Brandon

Active member
#4
I was having the same issue on my server. it's a permissions issue where the file copied has a different user than my vhost. adding the @ solved it.
 

Arkshine

Active member
#8
Debian 6 "squeeeze" + XF 1.1.4 + correct persmission, and it still happens. I had to edit again to add a @ to get it working. Well just saying/confirming the issue and I would hope something will be done because it's going to be a pain to redo always the same modification again and again.
 
#9
I just ran into this as well on XF 1.1.5, with the correct permissions, etc. In our case, it will try to rename the tmp file (in /tmp), to the data directory which resides on an NFS share. I am not sure if it is a cross filesystems issue or what, but suppressing the error as suggested does indeed allow it to function as expected. I realize that's not a proper fix but this is in my opinion an issue still.