Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.2.0 Checkout - Unable to save address. Validate class not found from basename 'Email Address #10821

Closed
ravibhoraniya opened this issue Sep 8, 2017 · 81 comments
Assignees
Labels
Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update

Comments

@ravibhoraniya
Copy link

ravibhoraniya commented Sep 8, 2017

exception 'Zend_Validate_Exception' with message 'Validate class not found from basename 'EmailAddress''

html/magento/vendor/magento/zendframework1/library/Zend/Validate.php:244

Preconditions

updated from 2.1.9 to 2.2 by update version in composer file and composer update, cache clearing and reindex shop looks working.

Steps to reproduce

put item in shopping chart to to checkout, enter address, all JS validators are fine, click next. then it shows up the "Payment Methods" page, when i click here on "Place Order" a notification messages says "Unable to save address. Please check input data."

Expected result

Go to next screen and confirm order is submitted.

Actual result

REST call https://www.tarnava.ro/ro/rest/ro/V1/guest-carts/6c5eba65da84bff14b2xxxxxxx/payment-information gets response
{"message":"Unable to save address. Please check input data."}

Log files shows also error

[2017-10-01 10:48:13] main.CRITICAL: Unable to save address. Please check input data. {"exception":"[object] (Magento\\Framework\\Exception\\InputException(code: 0): Unable to save address. Please check input data. at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/module-quote/Model/ShippingAddressManagement.php:119)"} []
[2017-10-01 10:48:23] main.CRITICAL: Validate class not found from basename 'Magento\Framework\Validator\EmailAddress' {"exception":"[object] (Zend_Validate_Exception(code: 0): Validate class not found from basename 'Magento\\Framework\\Validator\\EmailAddress' at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/zendframework1/library/Zend/Validate.php:244)"} []
[2017-10-01 10:48:23] main.CRITICAL: Unable to save address. Please check input data. {"exception":"[object] (Magento\\Framework\\Exception\\InputException(code: 0): Unable to save address. Please check input data. at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/module-quote/Model/ShippingAddressManagement.php:119)"} []
[2017-10-01 10:48:37] main.CRITICAL: Validate class not found from basename 'Magento\Framework\Validator\EmailAddress' {"exception":"[object] (Zend_Validate_Exception(code: 0): Validate class not found from basename 'Magento\\Framework\\Validator\\EmailAddress' at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/zendframework1/library/Zend/Validate.php:244)"} []
[2017-10-01 10:48:37] main.CRITICAL: Unable to save address. Please check input data. {"exception":"[object] (Magento\\Framework\\Exception\\InputException(code: 0): Unable to save address. Please check input data. at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/module-quote/Model/ShippingAddressManagement.php:119)"} []
[2017-10-01 10:49:46] main.CRITICAL: Validate class not found from basename 'Magento\Framework\Validator\EmailAddress' {"exception":"[object] (Zend_Validate_Exception(code: 0): Validate class not found from basename 'Magento\\Framework\\Validator\\EmailAddress' at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/zendframework1/library/Zend/Validate.php:244)"} []
[2017-10-01 10:56:56] main.CRITICAL: Validate class not found from basename 'Magento\Framework\Validator\EmailAddress' {"exception":"[object] (Zend_Validate_Exception(code: 0): Validate class not found from basename 'Magento\\Framework\\Validator\\EmailAddress' at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/zendframework1/library/Zend/Validate.php:244)"} []

Composer file from my initial magento 2.x version i only updated
"magento/product-community-edition": "2.2",

composer.json

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "version": "2.1.9",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "repositories":[
        {
            "type": "composer",
            "url": "https://repo.magento.com/"
        }
    ],
    "require": {
        "magento/product-community-edition": "2.2",
        "composer/composer": "1.4.1",
        "splendidinternet/mage2-locale-de-de": "^1.6",
        "magento/magento-composer-installer": "^0.1.8",
        "magefan/module-blog": "^2.4",
        "magepal/magento2-gmailsmtpapp": "^1.4"
    },
    "require-dev": {
        "phpunit/phpunit": "4.1.0",
        "squizlabs/php_codesniffer": "1.5.3",
        "phpmd/phpmd": "2.3.*",
        "pdepend/pdepend": "2.2.2",
        "sjparkinson/static-review": "~4.1",
        "fabpot/php-cs-fixer": "~1.2",
        "lusitanian/oauth": "~0.3 <=0.7.0"
    },
    "config": {
        "use-include-path": true
    },
    "autoload": {
        "psr-4": {
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/",
            "Magento\\": "app/code/Magento/"
        },
        "psr-0": {
            "": "app/code/"
        },
        "files": [
            "app/etc/NonComposerComponentRegistration.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\\Tools\\": "dev/tools/Magento/Tools/",
            "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
            "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "magento-force": "override"
    }
}
@orlangur
Copy link
Contributor

orlangur commented Sep 8, 2017

Please use the issue reporting guidelines to report an issue. Include the steps required to reproduce, the actual result, and the expected result.

@ravibhoraniya
Copy link
Author

ravibhoraniya commented Sep 8, 2017

Magento2 in any email address field not working means forgot password the user then this error Log create and not send message or Email Address class not found error give.

exception 'Zend_Validate_Exception' with message 'Validate class not found from basename 'EmailAddress''

@orlangur
Copy link
Contributor

orlangur commented Sep 8, 2017

Please just edit issue description according to template: https://github.com/magento/magento2/blob/develop/.github/ISSUE_TEMPLATE.md

@magento-engcom-team
Copy link
Contributor

@ravibhoraniya thank you for your report.
Please use the issue reporting guidelines to report an issue. Please, edit issue description and include the preconditions, the steps required to reproduce, the actual result, and the expected result.
Please, add the following information:

  • Preconditions: Magento version
  • Steps to reproduce
  • Expected result
  • Actual result

@magento-engcom-team magento-engcom-team added Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update labels Sep 11, 2017
@magento-engcom-team magento-engcom-team self-assigned this Sep 13, 2017
@PhiIipp
Copy link

PhiIipp commented Oct 1, 2017

Hello.
have same problem.

Precondition
updated from 2.1.9 to 2.2 by update version in composer file and composer update, cache clearing and reindex shop looks working.

Steps to reproduce
put item in shopping chart to to checkout, enter address, all JS validators are fine, click next. then it shows up the "Payment Methods" page, when i click here on "Place Order" a notification messages says "Unable to save address. Please check input data."

Expected result
Go to next screen and confirm order is submitted.

Actual result
REST call https://www.tarnava.ro/ro/rest/ro/V1/guest-carts/6c5eba65da84bff14b2xxxxxxx/payment-information gets respons
{"message":"Unable to save address. Please check input data."}

Log files shows also error

[2017-10-01 10:48:13] main.CRITICAL: Unable to save address. Please check input data. {"exception":"[object] (Magento\\Framework\\Exception\\InputException(code: 0): Unable to save address. Please check input data. at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/module-quote/Model/ShippingAddressManagement.php:119)"} [] [2017-10-01 10:48:23] main.CRITICAL: Validate class not found from basename 'Magento\Framework\Validator\EmailAddress' {"exception":"[object] (Zend_Validate_Exception(code: 0): Validate class not found from basename 'Magento\\Framework\\Validator\\EmailAddress' at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/zendframework1/library/Zend/Validate.php:244)"} [] [2017-10-01 10:48:23] main.CRITICAL: Unable to save address. Please check input data. {"exception":"[object] (Magento\\Framework\\Exception\\InputException(code: 0): Unable to save address. Please check input data. at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/module-quote/Model/ShippingAddressManagement.php:119)"} [] [2017-10-01 10:48:37] main.CRITICAL: Validate class not found from basename 'Magento\Framework\Validator\EmailAddress' {"exception":"[object] (Zend_Validate_Exception(code: 0): Validate class not found from basename 'Magento\\Framework\\Validator\\EmailAddress' at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/zendframework1/library/Zend/Validate.php:244)"} [] [2017-10-01 10:48:37] main.CRITICAL: Unable to save address. Please check input data. {"exception":"[object] (Magento\\Framework\\Exception\\InputException(code: 0): Unable to save address. Please check input data. at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/module-quote/Model/ShippingAddressManagement.php:119)"} [] [2017-10-01 10:49:46] main.CRITICAL: Validate class not found from basename 'Magento\Framework\Validator\EmailAddress' {"exception":"[object] (Zend_Validate_Exception(code: 0): Validate class not found from basename 'Magento\\Framework\\Validator\\EmailAddress' at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/zendframework1/library/Zend/Validate.php:244)"} [] [2017-10-01 10:56:56] main.CRITICAL: Validate class not found from basename 'Magento\Framework\Validator\EmailAddress' {"exception":"[object] (Zend_Validate_Exception(code: 0): Validate class not found from basename 'Magento\\Framework\\Validator\\EmailAddress' at /var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/zendframework1/library/Zend/Validate.php:244)"} []

Composer file from my initial magento 2.x version i only updated
"magento/product-community-edition": "2.2",

composer.json

{ "name": "magento/project-community-edition", "description": "eCommerce Platform for Growth (Community Edition)", "type": "project", "version": "2.1.9", "license": [ "OSL-3.0", "AFL-3.0" ], "repositories":[ { "type": "composer", "url": "https://repo.magento.com/" } ], "require": { "magento/product-community-edition": "2.2", "composer/composer": "1.4.1", "splendidinternet/mage2-locale-de-de": "^1.6", "magento/magento-composer-installer": "^0.1.8", "magefan/module-blog": "^2.4", "magepal/magento2-gmailsmtpapp": "^1.4" }, "require-dev": { "phpunit/phpunit": "4.1.0", "squizlabs/php_codesniffer": "1.5.3", "phpmd/phpmd": "2.3.*", "pdepend/pdepend": "2.2.2", "sjparkinson/static-review": "~4.1", "fabpot/php-cs-fixer": "~1.2", "lusitanian/oauth": "~0.3 <=0.7.0" }, "config": { "use-include-path": true }, "autoload": { "psr-4": { "Magento\\Framework\\": "lib/internal/Magento/Framework/", "Magento\\Setup\\": "setup/src/Magento/Setup/", "Magento\\": "app/code/Magento/" }, "psr-0": { "": "app/code/" }, "files": [ "app/etc/NonComposerComponentRegistration.php" ] }, "autoload-dev": { "psr-4": { "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/", "Magento\\Tools\\": "dev/tools/Magento/Tools/", "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/", "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/", "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/" } }, "minimum-stability": "dev", "prefer-stable": true, "extra": { "magento-force": "override" } }

@ravibhoraniya did you get your error fixed ? Anyone else a hint ?

Thanks
Philipp

@oewean
Copy link

oewean commented Oct 1, 2017

Same issue, fresh installation, tried twice both from downloaded zip file and via composer.

Setting mail addresses for the shop also fails.

Ubuntu 16.04
Mysql 5.7.19
PHP 7.1.9
Apache 2.4.18

Best regards
Ørjan

@PhiIipp
Copy link

PhiIipp commented Oct 2, 2017

@orjan
did you do any progress?
Fyi i use Ubuntu, with Plesk and PHP fastcgi 7.0.23 , opcache on...
Think must be System specific else more ppl would have this problem.

Thanks
Philipp

@oewean
Copy link

oewean commented Oct 2, 2017

Haven't had time to check any more,
I'm using plesk as well.

-Orjan

@ghost
Copy link

ghost commented Oct 2, 2017

I am also experiencing this same issue. Cannot check out after upgrading from 2.1.9 -> 2.2.0.

Using:
PHP 7.1.10
MySQL 5.6
Plesk

@orlangur
Copy link
Contributor

orlangur commented Oct 2, 2017

That's pretty strange error, looks like something happened to autoloading mechanism.

Could somebody please debug what is actually happening in \Zend_Validate::is method?

@ShapesGraphicStudio
Copy link

Also experiencing the same issue

Magento 2.2.0
PHP 7.0.23
MySQL 5.6.36-2.el6
Plesk
Just updated from 2.1.9 to 2.2.0

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Oct 3, 2017

@ravibhoraniya We have updated issue description with information from @PhiIipp's comment to simplify search of the same issues.

@magento-engcom-team magento-engcom-team added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Oct 3, 2017
@magento-engcom-team magento-engcom-team changed the title Validate class not found from basename 'Email Address 2.2.0 Checkout - Unable to save address. Validate class not found from basename 'Email Address Oct 3, 2017
@ferraramax
Copy link

I have the same problem, in a fresh installation of Magento 2.2

Php 7.1
Mariadb
Plesk 17

@PhiIipp
Copy link

PhiIipp commented Oct 5, 2017

Hello,
installed xdebug and debugged a bit. Looks like its an issue with a class path it cant find EmailAddress.php validator..

EmailAddress.php validator can be found here
`tarnava-ro@mail:/opt/plesk/php/7.0/share/pear$ locate EmailAddress.php|grep tarnava.ro

/var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/framework/Validator/EmailAddress.php
/var/www/vhosts/tarnava.ro/httpdocs/vendor/magento/zendframework1/library/Zend/Validate/EmailAddress.php
/var/www/vhosts/tarnava.ro/httpdocs/vendor/zendframework/zend-validator/src/EmailAddress.php

but it search in completly wrong directory and there is no EmailAddress.php

/opt/plesk/php/7.0/share/pear/Zend/Validate/Magento/Framework/Validator

capture_root

Hope this info helps to find the rootcause.

Thanks
Philipp

@PhiIipp
Copy link

PhiIipp commented Oct 5, 2017

Hello All,
good news !! found the root cause :-)

Prolem with the PLESK PHP seetings. Plesk includes per default some wired zend directories ..
In the option "include_path"

plesk

before

after

After i switched the include path to "." it works.

Greets
Philipp

@orlangur
Copy link
Contributor

orlangur commented Oct 5, 2017

@PhiIipp great finding! But after 0b659d2#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780L220 Magento is not using include_path at all, why ZF1 was not found in vendor with regenerated composer autoloader? Maybe some manual changes needed in composer.json to make 2.2 upgrade seamless on Plesk?

@ravibhoraniya please check if it solves problem for you.

@mslabko @okorshenko @vrann considering previously reported #10985 (comment) maybe it makes sense to add such information into http://devdocs.magento.com/guides/v2.2/release-notes/backward-incompatible-changes.html?

@AgentGod
Copy link

AgentGod commented Oct 9, 2017

The solution provided by @PhiIipp worked for me too. Thanks.

@NodokaMurmevent
Copy link

NodokaMurmevent commented Oct 10, 2017

working for me too i use plesk php 7.0.24 and magento 2.2.0

@ferraramax
Copy link

in first time, soluton of @philipp worded. Now, 3 days later, i have the same problem, and in plesk is setted "." as path

@Hoszi
Copy link

Hoszi commented Mar 14, 2018

don't need to restart apache only if u changed the php.ini. maybe u should flush cache.

@MiomenteMUC
Copy link

MiomenteMUC commented Mar 14, 2018

So, I cleaned and flushed and so on.
This is not working for me. I´m going to try something else.

I´m also not getting any quotes if I´m a registered user. Maybe there is something wrong there with shipping-information or stuff, but I triple checked this also. I don´t know. This error didn´t let me sleep for one week ^^

@MiomenteMUC
Copy link

MiomenteMUC commented Mar 15, 2018

So I figured out, that he searches in the Loader.php for the EmailAddress.php in
"/vendor/magento/zendframework1/library/Zend/Validate/Magento\Framework\Validator\EmailAddress.php"
where he never finds that file.
When I give him the path to:
"/vendor/magento/framework/Validator/Magento\Framework\Validator\EmailAddress.php" he can validate and everything is fine.

I wonder why your edit in the Loader.php works, because if you just give im back that he is true, he normally shouldn´t find that file in that directory he is looking for.

So in about line 186 in the Loader.php I have the normal code:
$file = $path . '/' . $filename;
and I edit it with
$file = "{web-path}/{magento-folder}/vendor/magento/framework/Validator". '/' . $filename"

So he is looking in the magento/framework and not the magento/zendframework1 Folder.

Maybe someone is facing the same problem. Don´t know if this is some kind of weird rights-problem (I checked it twice and all rights are set correctly) or just some problem with a wrong namespace or stuff.

Edit: you can also set the path to
"{web-path}/{magento-folder}/vendor/magento/zendframework1/library/Zend/Validate". '/' . $filename;"
this is also working. Don´t know if this has any sideeffects if I hardcode the path like that, but it works for now.
Maybe it´s the problem, that @ShapesGraphicStudio mentioned that I have a sub-folder and I now give him the subfolder in my {web-path} so he can find the EmailAddress.php

@Hoszi
Copy link

Hoszi commented Mar 20, 2018

I did another solution:
In Loader.php make a new function:

private static function is_readable2($filename) {
    try {
        return is_readable($filename);
    } catch (Exception $ex) {
        return false;
    }
}

and call this from isReadable function:

public static function isReadable($filename)
{
    if (self::is_readable2($filename)) {
        // Return early if the filename is readable without needing the
        // include_path
        return true;
    }

    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'
        && preg_match('/^[a-z]:/i', $filename)
    ) {
        // If on windows, and path provided is clearly an absolute path,
        // return false immediately
        return false;
    }

    foreach (self::explodeIncludePath() as $path) {
        if ($path == '.') {
            if (self::is_readable2($filename)) {
                return true;
            }
            continue;
        }
        $file = $path . '/' . $filename;
        if (self::is_readable2($file)) {
            return true;
        }
    }
    return false;
}

@GeorgeBogdanA
Copy link

GeorgeBogdanA commented May 17, 2018

Philipp solution worked also on Magento 2.2.4 PHP 7.1.17 Debian 8.10 Plesk 17.8.11. Thanks

@nikidexa
Copy link

nikidexa commented May 21, 2018

Philip solution worked for me... but now Im facing with another issue ....
when I'm trying to save something in backend: store>attributes>products get this error message :

Validate class not found from basename 'StringLength'

Im not completely sure that depend from changing " include_path ", but after this change Im gfacing this error and I cannot save anything in store>attributes>products

someone have this issue ??

@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Jun 6, 2018

jwohlfeil's solution worked for me, but why can't zend autoload from vendor first?

@micheleo
Copy link

Reporting the same problem after upgrading from 2.2.3 to 2.2.5 on a dedicated server.

@nikidexa
Copy link

For me the real problem was installation in dedicated server: same stuff in a standar and shared one worls perfectly, but when I move everything in dedicated one, many issue!

@gab4mad
Copy link

gab4mad commented Aug 5, 2018

It's not only a problem with Plesk and it's not a Magento-Problem! - create a php file with:
echo get_include_path();
and place it in your web-root to check your path...
I use for development a Serversetup with several v-servers hosted on a debian-engine using qemu... - The ISP-Backend used on th v-servers is ispconfig and the problems are the same, and the solution is the same, very easy... - just adding the path to the zend library.
When using ispconfig 3.1 in the optional hosting settings -> individual php settings
It looks like:
include_path = ".:/var/www/clients/yourclient/yourwebdirectory/pathtowebrootdirectoy/vendor/magento/zendframework1/library"
When using Plesk in the php-Settings of the domain -> additional config
It looks very similar, like:
include_path = ".:/var/www/vhosts/pathtoyourwebrootdirectory/vendor/magento/zendframework1/library"
This helped and causes no other Problems in my cases...

@nirvaat
Copy link

nirvaat commented Aug 28, 2018

I am using ISPConfig and adding include_path = "." in the custom php.ini options worked for me too. Thank you @PhiIipp for solution.

@sebastianrothbucher
Copy link

to throw in some more pieces of clarity (after long debugging - thanks for the pointers above): the problem seems to occur when the include_path contains directories that are not in open_basedir - so adjusting either (or leaving out open_basedir) would work

@elsdeniep
Copy link

@PhiIipp solution worked for me in PHP 7.1

@lalitmalav
Copy link

@PhiIipp thanks , works for me.

@Flipmediaco
Copy link

Flipmediaco commented Oct 1, 2019

Leaving my findings for others on the issue we had initially how this progressed following the @philipp fix in this thread and what we found and did to FIX :-)

MAGENTO 2.2.9
PHP 7.1.32

Initial Error: Validate class not found from basename 'EmailAddress'

Followed @philipp fix, set php_value include_path "."
Followed @sebastianrothbucher observation and added "." to php_value open_basedir

Implementing the above resolved the "EmailAddress" error, but I then received a new error: Validate class not found from basename 'NotEmpty'

Having cleared the composer cache, deleted and rebuilt the vendor directory, the error persisted... So added debug code to the vendor/magento/zendframework1/library/Zend/Validate.php

From the debug it was established that "Zend_Loader::isReadable($file)" was throwing the error when supplied $file = Zend/Validate/NotEmpty.php

There does seem to be a namespace issue with NotEmpty, I'm guessing this is all translating to is_readable "./Zend/Validate/NotEmpty.php" in "vendor/magento/zendframework1/library/Zend/", translating to "vendor/magento/zendframework1/library/Zend/Zend/Validate/NotEmpty.php"

The suggested fix for "Validate class not found from basename 'EmailAddress'" appears to actually create this issue.

BUT in order to Fix we added
".:/(full path from server root)/vendor/magento/zendframework1/library/"
to the include_path and open_basedir

The additional path in the php configuration resolves the issues as the validator file is checked to exist in all include_paths prior to throwing an error.

I guess this is a bug in certain environments... Hope this helps someone.

@blob84
Copy link

blob84 commented Nov 11, 2019

Leaving my findings for others on the issue we had initially how this progressed following the @philipp fix in this thread and what we found and did to FIX :-)

MAGENTO 2.2.9
PHP 7.1.32

Initial Error: Validate class not found from basename 'EmailAddress'

Followed @philipp fix, set php_value include_path "."
Followed @sebastianrothbucher observation and added "." to php_value open_basedir

Implementing the above resolved the "EmailAddress" error, but I then received a new error: Validate class not found from basename 'NotEmpty'

Having cleared the composer cache, deleted and rebuilt the vendor directory, the error persisted... So added debug code to the vendor/magento/zendframework1/library/Zend/Validate.php

From the debug it was established that "Zend_Loader::isReadable($file)" was throwing the error when supplied $file = Zend/Validate/NotEmpty.php

There does seem to be a namespace issue with NotEmpty, I'm guessing this is all translating to is_readable "./Zend/Validate/NotEmpty.php" in "vendor/magento/zendframework1/library/Zend/", translating to "vendor/magento/zendframework1/library/Zend/Zend/Validate/NotEmpty.php"

The suggested fix for "Validate class not found from basename 'EmailAddress'" appears to actually create this issue.

BUT in order to Fix we added
".:/(full path from server root)/vendor/magento/zendframework1/library/"
to the include_path and open_basedir

The additional path in the php configuration resolves the issues as the validator file is checked to exist in all include_paths prior to throwing an error.

I guess this is a bug in certain environments... Hope this helps someone.

This doesn't work for magento 2.3.3 .

@Flipmediaco
Copy link

This doesn't work for magento 2.3.3 .

I agree, the workaround of adding "vendor/magento/zendframework1/library/" to include_path appears to not be required as of M 2.3.X

The workaround of adding "." to the Include path and open base directory remains a requirement.

@chdzma
Copy link

chdzma commented Mar 31, 2020

The solution of @blob84 worked for me on Magento 2.3.4.

Thanks

@delve-game-studios
Copy link

The solution with the dot worked for me on one of the servers. On the second server is not working. The servers are identical.

@teokolo
Copy link

teokolo commented May 9, 2020

Using workaround from @blob84 solved the problem.

Magento 2.3.5-p1
Dedicated server with php7.3-fpm

Original settings:

open_basedir = "/srv/www/MYSITE"
include_path = ".:/usr/share/php"

New settings:

open_basedir = "/usr/share/php:/srv/www/MYSITE"
include_path = ".:/usr/share/php:/srv/www/MYSITE/vendor/magento/zendframework1/library"

@Flipmediaco
Copy link

I have come up against this issue with M2.3.5

I believe this issue is caused by a combination of open_basedir and include_path.

When open_basedir is set and does not include the PHP include_path default e.g ".:/usr/share/php", Magento will fail to find Zend Validate classes.

The workaround solution is, either:-

  1. Remove open_basedir configuration completely

  2. Add the include_path default ie "/usr/share/php" to open_basedir

In both, the above solutions include_path should not be set.

The problem is caused by Magento loader.php taking the value of get_include_path adding the path it needs and setting back with set_include_path. The result is the PHP include_path default is retained, along with the paths required by Magento.

<?php
$pathToLib = realpath(dirname(__FILE__));
set_include_path(implode(PATH_SEPARATOR, array(
        get_include_path(),
        $pathToLib,
)));

When this behaviour combined with open_basedir configuration that does not include the PHP include_path default, Magento will fail to find the zendframework1/library.

This I think is compounded further on Plesk type systems as these use open_basedir to limit the scope of PHP access. Also when include_path is set via virtualhost directive in some environments I have seen Magento can no longer set the include_path - which causes other issues.

I suspect the reason that this issue can not be replicated on the test instance is either open_basedir is not set or include_path default is not outside the scope of the value set to open_basedir.

This could be completely avoided if the /lib/internal/loader.php set the include_path to empty when it is called for the first time.

I am yet to test setting include_path to "" or "." in the php.ini as this would also fix the issue without the need to remove or adjust open_basedir.

@KM-HM
Copy link

KM-HM commented Aug 3, 2020

I have come up against this issue with M2.3.5

I can confirm this to be the case in M2.4.0

When open_basedir is set via PHP FPM pool config I'm unable to get the admin "Forgot your password?" functionality to work it will error with "Validate class not found from basename 'Magento\Framework\Validator\EmailAddress'"

Therefor I'm unable to set open_basedir for PHP which is a problem in shared hosting and in general a security risk.

When I include the path"[...]/vendor/magento/zendframework1/library" via "include_path" PHP in my PHP FPM pool configuration, it seems to work.

@jgryn
Copy link

jgryn commented Jul 27, 2021

So as of now.. the options are
(a) updating the php config to change the include_path [this fixes the issue but causes issues with any file trying to use set_include_path in php]
(b) updating php config open_basedir
(c) editing the core zend framework code.

To the best of my understanding, none of these are proper solutions to the issue. Why was this closed?

@jgryn
Copy link

jgryn commented Jul 27, 2021

@Hoszi 's solution of editing the core seemed to be more durable than changing my php config, I'm using that for now, but I'm not so happy about editing core files.

@Flipmediaco
Copy link

Flipmediaco commented Jul 27, 2021

So as of now.. the options are
(a) updating the php config to change the include_path [this fixes the issue but causes issues with any file trying to use set_include_path in php]
(b) updating php config open_basedir
(c) editing the core magento code.

To the best of my understanding, none of these are proper solutions to the issue. Why was this closed?

(d) delete open_basedir. do not set leave unset
(e) Add the initial default value of include path to open_basedir ".:path"

The issue is a conflict between include_path having a location that is outside open_basedir. In most cases this will be the include_path default value ".:some/path" - view phpinfo to see the default value for your environment. If you set include_path it blocks M2 from updating it but if you set ".:some/path" and leave include_path blank this normally works.

If you are not using shared hosting with other websites on the same server just remove open_basedir

Hope this helps... it is mad this is still an issue even up to M2.4 but this is more of a PHP issue

@benjaminv
Copy link

but the default .:/opt/plesk/php/7.4/share/pear should include both, . for Magento 2 and /opt/plesk/php/7.4/share/pear for others systems.
Does . : /opt/plesk/php/7.4/share/pear make sense at all? I added space in the between it works now, no idea why.

@Flipmediaco
Copy link

Flipmediaco commented Mar 2, 2022

but the default .:/opt/plesk/php/7.4/share/pear should include both, . for Magento 2 and /opt/plesk/php/7.4/share/pear for others systems. Does . : /opt/plesk/php/7.4/share/pear make sense at all? I added space in the between it works now, no idea why.

Either the "space" breaks the open_basedir configuration or everything after the "space" is ignored and thus your include path is "." - allow includes from current working directory... I suppose it remains to be seen if the "other systems" that require the "pear" part of the open_basedir configuration continue to work.

The main issue is that your include_path configuration will likely have a value, either set in php config or by Magento that is outside of the scope of the open_basedir, this causes all includes to be denied.

Ideally you would echo the value of include_path and open_basedir at the end of the index.php and then reconcile the scope in the paths. As soon as the include_path as a value that is outside the scope of open_basedir then all includes will break. Adding the missing "scope" to the open_basedir will fix the issue.

Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update
Projects
None yet
Development

No branches or pull requests