0

Here is the original core file https://github.com/phpbb/phpbb-core/blob/master/user.php Looks the same as mine...

From symfony

/**
 * Sets the Date header.
 *
 * @return $this
 *
 * @final since version 3.2
 */
public function setDate(\DateTime $date)
{
    $date->setTimezone(new \DateTimeZone('UTC'));
    $this->headers->set('Date', $date->format('D, d M Y H:i:s').' GMT');

    return $this;
}

This was running fine and then all a sudden it crashed. [16-Sep-2022 15:21:12 UTC] PHP Fatal error: Uncaught ArgumentCountError: DateTime::__construct() expects at most 2 parameters, 3 given in /home/groomlake/public_html/engine/user.php:629

I'm looking but I can't see what is causing it. Can someone point it out? Maybe I have been awake too long and I do not see it...

/**
* Format user date
*
* @param int $gmepoch unix timestamp
* @param string $format date format in date() notation. | used to indicate relative dates, for example |d m Y|, h:i is translated to Today, h:i.
* @param bool $forcedate force non-relative date format.
*
* @return mixed translated date
*/


function format_date($gmepoch, $format = false, $forcedate = false)
{
    global $engine_dispatcher;
    static $utc;

    if (!isset($utc))
    {
        $utc = new \DateTimeZone('UTC');
    }

    $format_date_override = false;
    $function_arguments = func_get_args();
    /**
    * Execute code and/or override format_date()
    *
    * To override the format_date() function generated value
    * set $format_date_override to new return value
    *
    * @event core.user_format_date_override
    * @var DateTimeZone utc Is DateTimeZone in UTC
    * @var array function_arguments is array comprising a function's argument list
    * @var string format_date_override Shall we return custom format (string) or not (false)
    * @since 3.2.1-RC1
    */
    $vars = array('utc', 'function_arguments', 'format_date_override');
    extract($engine_dispatcher->trigger_event('core.user_format_date_override', compact($vars)));

    if (!$format_date_override)
    {
        /*error is on the following  line*/         
        $time = new $this->datetime($this, '@' . (int) $gmepoch, $utc);
        
        $time->setTimezone($this->create_timezone());

        return $time->format($format, $forcedate);
    }
    else
    {
        return $format_date_override;
    }
}
13
  • Can you show us the datetime() function in that class.. I see you are calling that function on that line.. Commented Sep 16, 2022 at 15:58
  • You're passing in 3 parameters, apparently you're only supposed to pass in 2. But you didn't show your datetime() function in that class. Commented Sep 16, 2022 at 15:59
  • it's from symfony I will add it at the top Commented Sep 16, 2022 at 16:36
  • That is the system date time from PHP 7.4 Commented Sep 16, 2022 at 16:42
  • It is throwing the error in Linux, maybe it's a php-fpm time bug Commented Sep 16, 2022 at 16:45

1 Answer 1

1

You have a problem with your dynamic namespace system. More than likely you have changed the name of a dynamic global namespace.

Backtrack, go back, and restore your changes before you changed your dynamic namespace name. i.e. (engine)

I looked at phpBB and I can see your namespace is (engine) instead of the PhpBB original dynamic namespace name which was (phpbb). That is where your problem is stemming from.

You also may have changed your directory depth somewhere and the dynamic namespace function will cause the pages to not load.

phpBB is one of the very few that have a dynamic namespace system and it is a bit complicated for the average person to traverse in their mind.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.