When we want to rename a file in the root IMCE folder it seems to work fine, however when I want to rename a file in a subfolder I get the following error:

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /imce?jsop=rename&dir=lessons
StatusText: Service unavailable (with message)
ResponseText: Recoverable fatal error: Argument 1 passed to file_move() must be an instance of stdClass, boolean given, called in mysite.com/web/sites/all/modules/imce_rename/imce_rename.module on line 101 and defined in file_move() (line 999 of mysite.com/web/includes/file.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anthony Gaudino’s picture

FileSize
1.16 KB

I think I solved this issue. See the attached patch for the 7.x-1.x-dev version.

This problem was caused by not having a file entry in the file_managed table.
Every time you try to rename/move a file the module get a file object from this table, since theres no entry to the table, there will not have any data in the generated $file object.

I didn't notice this problem with folders, because they don't have a entry and the rename/move operation is different.

Jochen Wendebaum’s picture

The patch works fine, I would recommend to add it to the release! :-)

The only minor thing is that it jumps you back to the root folder. But this is not really a problem.

hefox’s picture

Status: Active » Needs review
FileSize
1.05 KB

Patch has some malformed characters at bottom

hefox’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community
hefox’s picture

fixing file name so applies with -p1

jmuzz’s picture

Issue summary: View changes

I got this error even for files in root of public:// .

#5 worked for me.

hefox’s picture

Status: Reviewed & tested by the community » Needs work

if( needs a space

jmuzz’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
994 bytes

Yes.

Maedi’s picture

Priority: Normal » Critical
FileSize
1.06 KB

I've updated the patch to properly create the file object before assigning property values to it. Which fixes this warning:
Warning: Creating default object from empty value in imce_rename_file() (line 116

The module hasn't been updated in 5 years and this patch is 3 years old. Please someone apply this! The module doesn't work without it.

Xoruna’s picture

I applied the patch in #9 but it failed at line 36. Then I tried the patch in #8, it works nice. Thanks.