Jump to content

Emptycache Error Code


Blesta Addons

Recommended Posts

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);
  }

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 .

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...