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

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"
    }
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 81 (8 by maintainers)

Most upvoted comments

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

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.

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.

Same here on nginx and PHP-FPM, you have to add include_path = “.:/yourpathtomagento/vendor/magento/zendframework1/library”, then it works.

Same problem on 2.2.2 (fresh Demo install). Solution with include_path = "." worked.

@Kipperlenny thanks for the solution with the direct path to the library, that worked finally for me!

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

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"

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

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;
}

it still a thing with your include_path - perhaps your server or sandbox have zend framework globally included (and the other env not). My Magento 2.2.1 needed this include_path:

include_path = ".:/var/www/...url.../web/vendor/magento/zendframework1/library"

@ShapesGraphicStudio we need to find out first what is exact problem in PLESK configuration.

By the way,

"config": {
        "use-include-path": true
    },

section was removed in Magento 2.2 due to performance reasons, will default PLESK value for include_path instead of . cause troubles if you remove this section from composer.json?

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