Third party Register page throwing `DateTimeZone::__construct(): Unknown or bad timezone ()` php errors

jeffwidman

Active member
NewRelic is reporting that domain.com/forum/register/register threw 57 of these errors in the last 24 hours:

Code:
DateTimeZone::__construct(): Unknown or bad timezone ()

There are no entries in the Xenforo server logs.

But the registration form automatically detects the time on the client computer and sets an appropriate default time zone.

If this is still true, I'm guessing it's caused by bots hitting the registration form with messed up timezone info so it throws an error.

But probably the exception should be caught within the app?
 
Last edited:
You don't have a line number or back trace?

There is a case where this can happen, but it's explicitly caught, so I'm thinking that the report may be invalid. If XF were generating this, it should be logged by XF.
 
Sorry, forgot to include the stack trace:

Code:
domain.com/public/forum/library/XenForo/DataWriter/User.php (738)
in XenForo_DataWriter_User::_verifyTimezone called at ? (?)
domain.com/public/forum/library/XenForo/DataWriter.php (982)
domain.com/public/forum/library/XenForo/DataWriter.php (725)
domain.com/public/forum/library/XenForo/DataWriter.php (643)
domain.com/public/forum/library/XenForo/DataWriter.php (995)
domain.com/public/forum/library/XenForo/ControllerPublic/Register.php (370)
domain.com/public/forum/library/XenForo/FrontController.php (347)
domain.com/public/forum/library/XenForo/FrontController.php (134)
domain.com/public/forum/index.php (13)

I'm a bit confused that NewRelic says the error happens at index.php, but when I pull up the list of all the errors, it says the url is /forum/register/register

Let me know if you want anything else.
 
Yes, this is a mis-reported error. We convert PHP warnings into exceptions and the code is:
Code:
        try
        {
            new DateTimeZone($timezone);
        }
        catch (Exception $e)
        {
            $this->error(new XenForo_Phrase('please_select_valid_time_zone'), 'timezone');
            return false;
        }
So the error is always caught; we expect an error to happen there.

This isn't an error that New Relic should be capturing, though I don't know how their tooling connects to PHP exactly.
 
Actually, this may be a result of a change they made in a recent release: PHP Agent 4.23.0.102 Release Notes - New Relic Community Forum

New Features
  • Exceptions that are uncaught and handled only by a last resort exception handler installed viaset_exception_handler() will now generate errors that can be viewed in the APM UI. Previously they wouldnot be sent to New Relic at all.
As a result of this, some customers will see more errors in the APM UIthan they had previously seen.
 
Top Bottom