7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » rename $pathBeforeAbs bug when adding a new Image Gallery Page
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 563 Views |
-
rename $pathBeforeAbs bug when adding a new Image Gallery Page

12 August 2010 at 9:37pm Last edited: 12 August 2010 10:12pm
I'm running SS 2.4.1 with the latest SVN builds of DataObjectManager, SWFUpload, and Image Gallery.
After creating my initial Image Gallery Page, I tried adding a new Image Gallery Page and Firebug was giving me this error :
ERROR [Warning]: rename(/MYPATH/public_html/assets/image-gallery/New-ImageGalleryPage-2/,/MYPATH/public_html/assets/image-gallery/New-ImageGalleryPage/) [<a href='function.rename'>function.rename</a>]: No such file or directory
IN POST /admin/AddPageOptionsForm
Line 402 in /MYPATH/public_html/sapphire/filesystem/File.phpWithout Firebug, I wasn't seeing any error, so it appeared like nothing was happening when I hit "Go" but the page was there if i refreshed my /admin page.
When I hit "Go" a third time it worked fine but since it had already created my second New Image Gallery Page and the "New-ImageGalleryPage-2" directory in assets/image-gallery, it would trigger the error because $pathBeforeAbs was still set to "New-ImageGalleryPage-2"
If I continued adding pages, it would continue incrementing the number after "image-gallery/New-ImageGalleryPage-#", but $pathBeforeAbs was still looking for New-ImageGalleryPage-2.
I got around this problem by running a clean install and then editing sapphire/filesystem/File.php and changing the rename() code on line 402 to first check if $pathBeforeAbs exists.
So on line 402, I changed:
// Rename file or folder
$success = rename($pathBeforeAbs, $pathAfterAbs);
if(!$success) throw new Exception("Cannot move $pathBeforeAbs to $pathAfterAbs");to
// Rename file or folder
if(file_exists($pathBeforeAbs)){
$success = rename($pathBeforeAbs, $pathAfterAbs);
if(!$success) throw new Exception("Cannot move $pathBeforeAbs to $pathAfterAbs");
}this appears to have fixed the problem... but perhaps there is a better solution for this?
| 563 Views | ||
|
Page:
1
|
Go to Top |

