Blesta Addons Posted October 27, 2014 Report Posted October 27, 2014 the emptyCache function is not working , when i have make a look at it , i found a mistake in the code , the actual code while ($item = @readdir($dir)) { if (is_file(CACHEDIR . $item)) @unlink(CACHEDIR . $item); } the correct code should be while ($item = @readdir($dir)) { if (is_file(CACHEDIR . $path . $item)) @unlink(CACHEDIR . $path . $item); }
Tyson Posted October 27, 2014 Report Posted October 27, 2014 Can you provide some context to the code? Affected file? Why the original does not work, and why your fix resolves it?
Blesta Addons Posted October 27, 2014 Author Report Posted October 27, 2014 Hello Tyson . to understand what i mean , you should look at the whole function . the unlink is target a error path and not the corrrect . the correct path is (CACHEDIR . $path . $item) and not (CACHEDIR . $item) public static final function emptyCache($path=null) let say we have a directory inside cache directory called "yaya" . if we want to empty this directory the command is Cache::emptyCache($this->company_id . DS . "yaya" . DS) normally the code public static final function emptyCache($path=null) { if (!($dir = @opendir(CACHEDIR . $path))) // here we are in /path/to/blesta/cache/1/yaya/ return; while ($item = @readdir($dir)) { // we get the files inside that directory , let say wqkjwhqkjwhq.html if (is_file(CACHEDIR . $item)) // this function is chekingthe file in error path /path/to/blesta/cache/wqkjwhqkjwhq.html // the correct path shold be /path/to/blesta/cache/1/yaya/wqkjwhqkjwhq.html // we shoudl add the $path var to the fucntion @unlink(CACHEDIR . $item); // the same incorrect path . } } i hope this is has more sense . best regards
Blesta Addons Posted October 28, 2014 Author Report Posted October 28, 2014 to see it in action , create a new group staff , add staff to this group . log in with the new staff login , goto /cache/1/nav/ , you should found 2 file , 1 for your administrator group and other for this new staff . at this point all is ok . now from administrator account try to emptycache (NOT clearCache() function ) . in ftp you will find the two file still exist . change to my code and empty cache , goto ftp and you will find just 1 file , is for the active staff (is you) . i hope i have well explained now .
Recommended Posts