Jump to:

7940 Posts in 1543 Topics by 946 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, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 696 Views
  • slith
    Avatar
    Community Member
    7 Posts

    rename $pathBeforeAbs bug when adding a new Image Gallery Page Link to this post

    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.php

    Without 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?

    696 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.