I set auto refresh to refresh every 2 seconds. When returning to the main page I get an error 500.
With debug mode on, this is shown:
Fatal error: Uncaught LogicException: Unable to add global "auto_refresh" as the runtime or the extensions have already been initialized. in /home/username/public_html/admin/monitor/vendor/twig/twig/lib/Twig/Environment.php:882 Stack trace: #0 /home/username/public_html/admin/monitor/src/psm/Module/Server/Controller/StatusController.php(98): Twig_Environment->addGlobal('auto_refresh', true) #1 /home/username/public_html/admin/monitor/src/psm/Module/AbstractController.php(193): psm\Module\Server\Controller\StatusController->executeIndex() #2 /home/username/public_html/admin/monitor/src/psm/Module/AbstractController.php(164): psm\Module\AbstractController->runAction('index') #3 /home/username/public_html/admin/monitor/src/psm/Router.php(102): psm\Module\AbstractController->run('index') #4 /home/username/public_html/admin/monitor/index.php(42): psm\Router->run('server') #5 {main} thrown in /home/username/public_html/admin/monitor/vendor/twig/twig/lib/Twig/Environment.php on line 882
Which version of PSM and PHP are you on?
I tried it myself (PSM 3.2.2, PHP 7.2.4), but no error 500.
I am on the release version of PSM, PHP version 7.1
I am getting same issue
PHP 7.2.5
PSM 3.3.0
I will get debug info soon.
getting the same issue
PHP: 7.1.11
PSM: 3.3.0
twig: 2.4.7
Message:
Unable to add global "auto_refresh" as the runtime or the extensions have already been initialized.
Stack Trace:
#0 phpservermon\src\psm\Module\Server\Controller\StatusController.php(98): Twig_Environment->addGlobal('auto_refresh', true)
#1 phpservermon\src\psm\Module\AbstractController.php(193): psm\Module\Server\Controller\StatusController->executeIndex()
#2 phpservermon\src\psm\Module\AbstractController.php(164): psm\Module\AbstractController->runAction('index')
#3 phpservermon\src\psm\Router.php(102): psm\Module\AbstractController->run('index')
#4 phpservermon\index.php(42): psm\Router->run('server')
#5 {main}
Looks like its a problem with twig >= v2.0.0.
As i tried it with twig v1.24.0 and it works perfectly fine.
Edit: see here
It seems that now I can set a global, and then /_override_/ it later on
in the render() part. I still can't initialise a/_new_ /global, though.Is this the desired behaviour? Regardless, this is very workable, so
thanks for looking into it.Yes, this is on purpose to avoid any side effect. So, all globals must
be registered before runtime initialization.
This is a great short term solution, but on the long term we need to find a way that we can update twig.
@Engineer-of-Stuff @juzsingleton please confirm that the problem is fixed.
Yes this fixed the issue.
Great!
From: juzsingleton notifications@github.com
Sent: Saturday, May 26, 2018 1:20:05 AM
To: phpservermon/phpservermon
Cc: Tim; State change
Subject: Re: [phpservermon/phpservermon] Error 500 on Auto Refresh Setting (#583)
Yes this fixed the issue.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHubhttps://github.com/phpservermon/phpservermon/issues/583#issuecomment-392211779, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AOg8ktNhE8QxBQmuGwMFp4gs8m3ZnUTkks5t2JGlgaJpZM4Trn_H.
@TimZ99 Issue fixed with Twig version 1.24.0
Thanks for the help.
Most helpful comment
This is a great short term solution, but on the long term we need to find a way that we can update twig.