{"id":1347,"date":"2020-11-08T11:52:28","date_gmt":"2020-11-08T11:52:28","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/11\/08\/solved-invalid-arguement-exception-error-in-magento-2-3-5\/"},"modified":"2025-07-17T10:25:13","modified_gmt":"2025-07-17T04:55:13","slug":"solved-invalid-arguement-exception-error-in-magento-2-3-5","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/solved-invalid-arguement-exception-error-in-magento-2-3-5\/","title":{"rendered":"Solved &#8211; InvalidArgumentException Error in Magento 2.3.5"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento\u00a0is one of the most preferred platforms for creating E-commerce stores. And that is for a reason!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The platform powered by Adobe keeps on releasing new versions frequently to stay up to date with the latest technology and increasing business demands.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is recommended that merchants&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-migration-service.html\" target=\"_blank\" rel=\"noreferrer noopener\">migrate their Magento 2 stores<\/a>&nbsp;to the latest version&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-4-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2.4.8<\/a>&nbsp;in order to avail the performance and security benefits.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, while installing&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-3-5-release\/\">Magento 2.3.5<\/a>&nbsp;or its above versions, you may face an error that says,<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Unable to apply data patch MagentoThemeSetupPatchDataRegisterThemes for module Magento_Theme. Original exception message: Wrong file<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Today, I will be talking about the solution for solving the error&nbsp;<em><strong>InvalidArgumentException error in Magento 2.3.5<\/strong><\/em>&nbsp;or above version.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution for InvalidArgumentException Error in Magento 2.3.5 in Gd2.php:64<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The below image shows the error that occurs while installing Magento 2.3.5.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/11\/Solution-for-InvalidArgumentException-Error-in-Magento-2-1024x386.png\" alt=\"Solution for InvalidArgumentException Error in Magento 2\" class=\"wp-image-11405\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Open&nbsp;<strong><em>vendor\\magento\\framework\\Image\\Adapter\\Gd2.php<\/em><\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At line 96, replace:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">private function validateURLScheme(string $filename) : bool\n  {\n      $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];\n      $url = parse_url($filename);\n      if ($url &amp;&amp; isset($url['scheme']) &amp;&amp; !in_array($url['scheme'], $allowed_schemes) {\n          return false;\n      }\n\n      return true;\n  }<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With the below code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">private function validateURLScheme(string $filename) : bool\n  {\n      $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];\n      $url = parse_url($filename);\n      if ($url &amp;&amp; isset($url['scheme']) &amp;&amp; !in_array($url['scheme'], $allowed_schemes) &amp;&amp; !file_exists($filename)) \n{\n          return false;\n      }\n\n      return true;\n  }<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">All you have to do is to replace the below string:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> if ($url &amp;&amp; isset($url['scheme']) &amp;&amp; !in_array($url['scheme'], $allowed_schemes<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if ($url &amp;&amp; isset($url['scheme']) &amp;&amp; !in_array($url['scheme'], $allowed_schemes) &amp;&amp; !file_exists($filename))<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do consider sharing this post with the Magento community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento\u00a0is 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&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1347","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1347"}],"version-history":[{"count":5,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1347\/revisions"}],"predecessor-version":[{"id":14628,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1347\/revisions\/14628"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}