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

Fatal error: Call to a member function format() on null in magento2/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php on line 260 #1427

Closed
supravatm opened this issue Jun 30, 2015 · 7 comments

Comments

@supravatm
Copy link

After the install Magento2 on localhost, its working file. But when I try to re-index, its getting the following error.

Fatal error: Call to a member function format() on null in /var/www/html/magento2/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php on line 260

Have any idea for this?

@rganin
Copy link
Contributor

rganin commented Jun 30, 2015

Issue is related to https://bugs.php.net/bug.php?id=66323. Created an internal ticket MAGETWO-39421

@vpelipenko vpelipenko added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development PS bug report labels Jun 30, 2015
@vpelipenko
Copy link
Contributor

@supravatweb, the issue was fixed in 1.0.0-beta. Please, check the issue on this version.

@ivanweiler
Copy link

Problem still exists on my side on certain server/php, CentOS with php 5.5.24 to be exact. Intl version 1.1.0, ICU version 4.2.1. Everything is working on Windows and Ubuntu with latest 5.5.x php, so it's most likely usual problem when different/older intl is behaving differently.

In my case IntlDateFormatter excepts this:
object(DateTimeZone)#3271 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(15) "Europe/Belgrade"
}

But crashes on this:
object(DateTimeZone)#3271 (2) {
["timezone_type"]=> int(1)
["timezone"]=> string(6) "+00:00"
}
Fatal error: Call to a member function format() on a non-object in /home/magento2/public_html/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php on line 261

It seems it only excepts DateTimeZone with timezone identifier.

One more thing, it's possible last fallback added in 1.0.0-beta is also wrong:
$timezone ?: $date->getTimezone() ?: new \DateTimeZone(\DateTimeZone::UTC),

new \DateTimeZone(\DateTimeZone::UTC)
Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone

new \DateTimeZone("UTC") - working

Hope it helps.

@piotrekkaminski
Copy link
Contributor

The issue should be already fixed.

@sadashivdalvi
Copy link

I am getting this issue in magento 2.1.1. I can see this when I go to index page or when I try to checkout. The checkout doesn't complete showing error as

Call to a member function format() on null in /var/www/html/magento/vendor/magento/framework/Stdlib/DateTime/Timezone.php on line 284, referer: http://mysite/checkout/

would like to know how can I fix this or debug this?

Thanks,
Sadashiv

@Federkun
Copy link

Federkun commented Jan 1, 2017

IntlDateFormatter may returns null instead of throwing an exception, see bug #66323

Usually, something like this is done:

$intlDateFormatter = new \IntlDateFormatter( ... );

if (!$intlDateFormatter) {
    throw new \RuntimeException(intl_get_error_message(), intl_get_error_code());
}

@nadeem0035
Copy link

There is a known PHP issue with versions:
5.5.10–5.5.16
5.6.0

Update PHP version and it will be fixed.

magento-team pushed a commit that referenced this issue Aug 22, 2017
[Performance] Add seed for JMeter scenarios
drashmk pushed a commit to drashmk/magento2 that referenced this issue Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants