Verify the existence of the old imagePath in update_com.woltlab.wcf_5.3_style.php
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 17 Nov 2020 09:13:42 +0000 (10:13 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 17 Nov 2020 09:13:42 +0000 (10:13 +0100)
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3_style.php

index e1898371671634472ed48e930ace817a3362aff5..27fe4cfe2ba46ced987d092f8b2c067183171ca1 100644 (file)
@@ -55,20 +55,22 @@ foreach ($styleList as $style) {
                        $srcPath = $assetBackupPath;
                }
                
-               $iterator = new \RecursiveIteratorIterator(
-                       new \RecursiveDirectoryIterator(
-                               $srcPath,
-                               \FilesystemIterator::SKIP_DOTS
-                       ), 
-                       \RecursiveIteratorIterator::SELF_FIRST
-               );
-               foreach ($iterator as $file) {
-                       /** @var \SplFileInfo $file */
-                       if (!$file->isFile()) continue;
-                       
-                       $relative = FileUtil::getRelativePath($srcPath, $file->getPath());
-                       FileUtil::makePath($style->getAssetPath() . $relative);
-                       copy($file->getPathname(), $style->getAssetPath() . $relative . $file->getBasename());
+               if (file_exists($srcPath)) {
+                       $iterator = new \RecursiveIteratorIterator(
+                               new \RecursiveDirectoryIterator(
+                                       $srcPath,
+                                       \FilesystemIterator::SKIP_DOTS
+                               ),
+                               \RecursiveIteratorIterator::SELF_FIRST
+                       );
+                       foreach ($iterator as $file) {
+                               /** @var \SplFileInfo $file */
+                               if (!$file->isFile()) continue;
+                               
+                               $relative = FileUtil::getRelativePath($srcPath, $file->getPath());
+                               FileUtil::makePath($style->getAssetPath() . $relative);
+                               copy($file->getPathname(), $style->getAssetPath() . $relative . $file->getBasename());
+                       }
                }
        }
        $styleEditor->update([