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

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