joe_g Posted September 13, 2012 Share Posted September 13, 2012 Hi there, seems like I got the same issue. Files arent deleted in the file structure after deleting in the cms. server has PHP Version 5.3.2-1ubuntu4.17 Link to comment Share on other sites More sharing options...
netcarver Posted September 13, 2012 Share Posted September 13, 2012 Ryan, looks like you have some hard-coded assumptions of unix path separators in the codebase that might better be swapped for the DS constant. Take a look at _copyFiles() in PagefilesManager.php for one example (there might be more)... protected function _copyFiles($fromPath, $toPath) { if(!is_dir($toPath)) return 0; $numCopied = 0; $fromPath = rtrim($fromPath, '/') . '/'; $toPath = rtrim($toPath, '/') . '/'; foreach(new DirectoryIterator($fromPath) as $file) { if($file->isDot()) continue; if($file->isDir()) { $newPath = $toPath . $file->getFilename() . '/'; $this->_createPath($newPath); $numCopied += $this->_copyFiles($file->getPathname(), $newPath); continue; } if($file->isFile()) { if(copy($file->getPathname(), $toPath . $file->getFilename())) $numCopied++; } } return $numCopied; Where you are doing trims + replaces with forward slashes (unix-specific) rather than the OS-neutral DS. Check out this post of mine from waaaayyyy back in my Textpattern days for more background. I'm not suggesting this is the exact source of the problem being reported in this thread but I think it does represent a code portability issue for PW. Link to comment Share on other sites More sharing options...
ryan Posted September 13, 2012 Share Posted September 13, 2012 joe_g or DaveP -- can you try replacing your /wire/core/Pagefile.php with the file attached, and let me know if it corrects the issue? Pagefile.php Thanks, Ryan 1 Link to comment Share on other sites More sharing options...
netcarver Posted September 13, 2012 Share Posted September 13, 2012 Forgot to mention that DS is (effectively) a Textpattern alias for DIRECTORY_SEPARATOR. Link to comment Share on other sites More sharing options...
DaveP Posted September 13, 2012 Share Posted September 13, 2012 @ryan That sorted it out. 1 Link to comment Share on other sites More sharing options...
ryan Posted September 13, 2012 Share Posted September 13, 2012 Thanks Steve. We normalize to forward '/' slashes internally, and I normalize them as soon as anything comes from the OS (see /wire/core/Paths.php). I don't think that function is involved in this particular case, but like you pointed out, that function does assume it's dealing with paths in an expected format that have already been normalized. The setFilename() function also assumes it's dealing with filenames in an expected format, so that extra slash must be finding its way in there before the function call. What I'm looking for is any native PHP that would return a path, like a DirectoryIterator loop where maybe I'm doing something like in that function you pointed out -- a trim($dir, '/') rather than a trim($dir, DIRECTORY_SEPARATOR). So far I haven't found it, but the hunt is on. 1 Link to comment Share on other sites More sharing options...
ryan Posted September 13, 2012 Share Posted September 13, 2012 Might have just found it: the getVariations() function in /wire/core/Pageimage.php calls setFilename() with a non-normalized path from DirectoryIterator. Though still not clear why the $file->getPathname() from DirectoryIterator would be returning a file in the format with both types of slashes (/path/to/file\file.jpg). But that bit of code in Pageimage.php is a problem either way, as it doesn't consider the slashes and it needs to. Luckily an easy fix. 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 13, 2012 Author Share Posted September 13, 2012 Great to hear !!, also saw on Github you fixed the sessionLoginThrottle as well... Nice work ryan. 1 Link to comment Share on other sites More sharing options...
joe_g Posted September 26, 2012 Share Posted September 26, 2012 Tried replacing Pagefile.php, and it works for me thanks! =) J Link to comment Share on other sites More sharing options...
ryan Posted September 26, 2012 Share Posted September 26, 2012 Tried replacing Pagefile.php, and it works for me This was actually fixed in the current version's source code about 10 days ago, so it's better just to grab the latest version of ProcessWire rather than replacing Pagefile.php. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now