Solved – InvalidArgumentException Error in Magento 2.3.5
Magento is one of the most preferred platforms for creating E-commerce stores. And that is for a reason!
The platform powered by Adobe keeps on releasing new versions frequently to stay up to date with the latest technology and increasing business demands.
It is recommended that merchants migrate their Magento 2 stores to the latest version Magento 2.4.1 in order to avail the performance and security benefits.
However, while installing Magento 2.3.5 or its above versions, you may face an error that says,
Unable to apply data patch Magento\Theme\Setup\Patch\Data\RegisterThemes for module Magento_Theme. Original exception message: Wrong file
Today, I will be talking about the solution for solving the error InvalidArgumentException error in Magento 2.3.5 or above version.
Solution for InvalidArgumentException Error in Magento 2.3.5 in Gd2.php:64
The below image shows the error that occurs while installing Magento 2.3.5.
The command prompt shows the line 64. However, if you open the file in edit mode, you need to make changes in it at line 96.
Open vendor\magento\framework\Image\Adapter\Gd2.php.
At line 96, replace:
1 2 3 4 5 6 7 8 9 10 |
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; } |
With the below code:
1 2 3 4 5 6 7 8 9 10 11 |
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; } |
All you have to do is to replace the below string:
1 |
if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes |
With:
1 |
if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) |
That’s it.
If you have questions regarding this error and its solution, feel free to ask in the Comments section below.
I would be happy to help you.
Do consider sharing this post with the Magento community via social media.
Thank you.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
Prev
How to Delete Data from Table in Magento 2
How to Import and Export Customers in Magento 2
Next