1

While installing Magento 2.3.5 in windows, I got this Error:

[Progress: 698 / 1369] Module 'Magento_Theme':

In PatchApplier.php line 170:

Unable to apply data patch Magento\Theme\Setup\Patch\Data\RegisterThemes for module Magento_Theme. Original exception message: Wrong file

In Gd2.php line 64:

Wrong file

3 Answers 3

9

I found a workaround for Windows OS. Image Adapter try opens to image files ('open function in Gd2.php line 63). validateURLScheme function return false always because it checking 'URL' format but local files not valid for this format, so it returns false.

Find validateURLScheme function in vendor\magento\framework\Image\Adapter\Gd2.php file. at line 96. Replace function with this:

private function validateURLScheme(string $filename) : bool   {
          $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
          $url = parse_url($filename);
          if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) {
              return false;
          }

          return true;   
}
2
  • 1
    Update. Works also for Magento 2.4.1
    – Rostyslav
    Commented Oct 18, 2020 at 19:09
  • @tejas which image file it is trying to open and why it fails to open? Commented Feb 19, 2021 at 16:18
3

Make sure GD2 extension is installed and enabled in the php.ini file.

Replace the function validateURLScheme with below code https://github.com/magento/magento2/blob/2.3.5-p2/lib/internal/Magento/Framework/Image/Adapter/Gd2.php#L96

Before:

private function validateURLScheme(string $filename) : bool
{
    $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
    $url = parse_url($filename);
    if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes)) {
        return false;
    }

    return true;
}

After:

private function validateURLScheme(string $filename) : bool
{
    $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
    $url = parse_url($filename);
    if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) {
        return false;
    }

    return true;
}
1

enter image description hereadd this line as && !file_exists($filename)

Not the answer you're looking for? Browse other questions tagged or ask your own question.