Breakage on PHP 7.4? (E_NOTICE - Trying to access array offset on value of type null)

I upgraded to PHP Version 7.4.3 on Ubuntu 18.04. Grav is at v1.6.21. All plugins are up-to-date, and I’ve tried disabling them all but the problem persist.

When loading the front page I get:

E_NOTICE - Trying to access array offset on value of type null

The log says:
[2020-02-20 21:51:58] grav.CRITICAL: Trying to access array offset on value of type null - Trace:
#0 /var/www/infoscreen/system/src/Grav/Common/Debugger.php(352): Whoops\Run->handleError()
#1 /var/www/infoscreen/vendor/erusev/parsedown-extra/ParsedownExtra.php(241): Grav\Common\Debugger->deprecatedErrorHandler()
#2 /var/www/infoscreen/vendor/erusev/parsedown/Parsedown.php(206): ParsedownExtra->blockSetextHeader()
#3 /var/www/infoscreen/vendor/erusev/parsedown/Parsedown.php(39): Parsedown->lines()
#4 /var/www/infoscreen/vendor/erusev/parsedown-extra/ParsedownExtra.php(46): Parsedown->text()
#5 /var/www/infoscreen/system/src/Grav/Common/Page/Page.php(849): ParsedownExtra->text()
#6 /var/www/infoscreen/system/src/Grav/Common/Page/Page.php(692): Grav\Common\Page\Page->processMarkdown()
#7 /var/www/infoscreen/system/src/Grav/Common/Twig/Twig.php(366): Grav\Common\Page\Page->content()
#8 /var/www/infoscreen/system/src/Grav/Common/Service/OutputServiceProvider.php(28): Grav\Common\Twig\Twig->processSite()
#9 /var/www/infoscreen/vendor/pimple/pimple/src/Pimple/Container.php(118): Grav\Common\Service\OutputServiceProvider->Grav\Common\Service{closure}()
#10 /var/www/infoscreen/system/src/Grav/Common/Processors/RenderProcessor.php(28): Pimple\Container->offsetGet()
#11 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\RenderProcessor->process()
#12 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#13 /var/www/infoscreen/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle()
#14 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\DebuggerAssetsProcessor->process()
#15 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#16 /var/www/infoscreen/system/src/Grav/Common/Processors/PagesProcessor.php(69): Grav\Framework\RequestHandler\RequestHandler->handle()
#17 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\PagesProcessor->process()
#18 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#19 /var/www/infoscreen/system/src/Grav/Common/Processors/TwigProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle()
#20 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\TwigProcessor->process()
#21 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#22 /var/www/infoscreen/system/src/Grav/Common/Processors/AssetsProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle()
#23 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\AssetsProcessor->process()
#24 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#25 /var/www/infoscreen/system/src/Grav/Common/Processors/SchedulerProcessor.php(29): Grav\Framework\RequestHandler\RequestHandler->handle()
#26 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\SchedulerProcessor->process()
#27 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#28 /var/www/infoscreen/system/src/Grav/Common/Processors/BackupsProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle()
#29 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\BackupsProcessor->process()
#30 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#31 /var/www/infoscreen/system/src/Grav/Common/Processors/TasksProcessor.php(59): Grav\Framework\RequestHandler\RequestHandler->handle()
#32 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\TasksProcessor->process()
#33 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#34 /var/www/infoscreen/system/src/Grav/Common/Processors/RequestProcessor.php(52): Grav\Framework\RequestHandler\RequestHandler->handle()
#35 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\RequestProcessor->process()
#36 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#37 /var/www/infoscreen/system/src/Grav/Common/Processors/ThemesProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle()
#38 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\ThemesProcessor->process()
#39 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#40 /var/www/infoscreen/system/src/Grav/Common/Processors/PluginsProcessor.php(30): Grav\Framework\RequestHandler\RequestHandler->handle()
#41 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\PluginsProcessor->process()
#42 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#43 /var/www/infoscreen/system/src/Grav/Common/Processors/InitializeProcessor.php(95): Grav\Framework\RequestHandler\RequestHandler->handle()
#44 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\InitializeProcessor->process()
#45 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#46 /var/www/infoscreen/system/src/Grav/Common/Processors/DebuggerProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle()
#47 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\DebuggerProcessor->process()
#48 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#49 /var/www/infoscreen/system/src/Grav/Common/Processors/ErrorsProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle()
#50 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\ErrorsProcessor->process()
#51 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#52 /var/www/infoscreen/system/src/Grav/Common/Processors/LoggerProcessor.php(48): Grav\Framework\RequestHandler\RequestHandler->handle()
#53 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\LoggerProcessor->process()
#54 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#55 /var/www/infoscreen/system/src/Grav/Common/Processors/ConfigurationProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle()
#56 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\ConfigurationProcessor->process()
#57 /var/www/infoscreen/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle()
#58 /var/www/infoscreen/system/src/Grav/Common/Grav.php(272): Grav\Framework\RequestHandler\RequestHandler->handle()
#59 /var/www/infoscreen/index.php(54): Grav\Common\Grav->process()
#60 {main} [] []

How do I trouble-shoot this? Thanks. :slight_smile:

@ulfben, This issue seems to be related to post Grav admin plugin/theme page prompts error

Working temporary solution seems to be to downgrade from PHP 7.4.

I’ve noticed your issue on Grav’s github repo. Thanks!

1 Like

Downgrading to php7.3 helped. Here’s a step-by-step guide for anyone else that might run into this problem:

Install php7.3:

sudo apt-get update
sudo apt-get install -y php7.3
sudo apt-get install libapache2-mod-php7.3

Add some common modules:

sudo apt install php7.3-common php7.3-xml php7.3-curl php7.3-imagick php7.3-mbstring php7.3-zip php7.3-intl -y

Add the additional GRAV requirements:

sudo apt-get install php7.3-gd php7.3-opcache php7.3-json  -y

Configure the new PHP:
Add your custom settings to the end of php.ini:

sudo tee -a /etc/php/7.3/apache2/php.ini > /dev/null <<EOT 

;these limits are arbitrary, adjust to whatever suits your server
upload_max_filesize = 192M
max_file_uploads = 20
post_max_size = 256M
memory_limit = 256M
max_execution_time = 180
max_input_vars = 3000
max_input_time = 60

;optional security measure - disable "dangerous" functions.
disable_functions = exec, passthru, shell_exec, system, proc_open, popen, show_source, apache_child_terminate, apache_get_modules, apache_get_version, apache_getenv, apache_note, apache_setenv, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, posix_getpwuid, posix_uname, pclose, dl, disk_free_space, diskfreespace, disk_total_space, pcntl_exec, proc_close, proc_get_status, proc_nice, proc_terminate, symlink, link, putenv, opcache_get_configuration, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority

EOT

Note: multiple definitions of these variables are not a problem. PHP uses whatever value is last seen. By adding our customizations to the end of the file we save a lot of time versus manually finding and editing the defaults each and every time we install PHP.

Enable the new PHP:

sudo a2enmod php7.3

Disable the problematic PHP version:

sudo a2dismod php7.4

Check that Apache is happy with your new config before reloading the server:

sudo apachectl configtest

Restart Apache:

sudo apachectl restart

Visit /admin/tools/reports on your GRAV-site to confirm that it’s running on the correct PHP-version and that all modules are loaded correctly. You can also get this information from /admin/config/info.

Once GRAV is patched for php7.3 you can repeat these steps with the new version number.

Optional: clean up unused PHP versions:

sudo apt purge php7.4 libapache2-mod-php7.4
sudo apt purge php7.2 libapache2-mod-php7.2
sudo apt purge php7.1 libapache2-mod-php7.1
sudo apt purge php7.0 libapache2-mod-php7.0
sudo apt purge php5.6 libapache2-mod-php5.6

etc…

1 Like

Downgrading PHP to get around an E_NOTICE is kind of silly. If you’re stuck on an older version of Grav, you can simply disable notice reporting in your php.ini until you can get around to updating Grav:

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

In production, you should probably suppress reporting of notices all the time and only enable it in development.