0

I am trying to copy the files from a folder.

I have this function:

   private function rec_copy ($source, $dest) {
       foreach (
           $iterator = new \RecursiveIteratorIterator(
               new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
               \RecursiveIteratorIterator::SELF_FIRST) as $item
       ) {
           if ($item->isDir()) {
               mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
           } else {
               copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
           }
       }
    }

This function works perfectly with this one:

protected function copy_translation($directory,$value)
    {
        $directorio = $directory;
        $newfolder = '/var/www/vhosts/something/modules/'.$value;
        $newfolder_translation = $newfolder.'/translations/';
        mkdir($newfolder);
        mkdir($newfolder_translation);
        $this->rec_copy( $directorio,$newfolder_translation);
    }

However, it fails when I try with this one:

public function otherfunction($language){
        foreach ($this->list as $key => $value){
            $directory = '/var/www/vhosts/something/modules/'.$value.'/translations/';
            if (is_dir($directory)){
                $source = $directory.'de/';
                $destination = $directory . $language . '/';
                mkdir($destination);
                $this->rec_copy($source,$destination);
            }
        }
    }

They are all in the same class. The function otherfunction actually creates the directories with mkdir($destination), so the path and the permission of the folder cannot be the problem.

There is nothing in the log and no error display. If I execute $this->rec_copy($source,$destination); in the third function, it shows "shop is offline" up but works fine with the second, as I mentioned before.

I am using oxid 4.9.7 if that helps, but the platform itself doesn't seem to be the problem to me.

prgrm
  • 3,734
  • 14
  • 40
  • 80
  • 1
    I can suggest how to debug this issue: first of all turn of production mode (Master settings -> Core settings -> Main tab), then in config.inc.php set $this->iDebug = -1; and if you will get blank screen, change php setting to display_errors = On, so PHP would show errors. – Mantas Vaitkūnas May 18 '16 at 14:08
  • Are you positive your code even gets to loop through otherfunction's foreach? It might already fail when you try calling that function or accessing $this->list in it. I recommend you setting up Xdebug or at least throwing in some var_dump()'s and die()'s to precisely figure out how far your code gets executed. – Patchee May 21 '16 at 13:58

0 Answers0