Site logo

Archived topic

Array null errors with ClassicPress using PHP 8

7 replies · Started by Graham on April 9, 2023

Viewing posts 1–8 of 8

I use the last version of GP and GP Premium that worked before blocks were required with GP, because I run ClassicPress instead of WordPress.

Everything is fine using PHP 7.x but when I use 8.x I get errors saying "Trying to access array offset on value of type null...."

The two files it complains about are:
gp-premium/page-header/functions/functions.php
gp-premium/blog/functions/images.php

The types of lines it doesn't like are:
if ( '' !== $options[ 'content' ] ) {

I realize I'm using old versions, but was wondering if there is now a new way of wording the "if" statement where the array is '' meaning empty (Null) I assume.

Did some searching on Google but couldn't find any answers. Tried using the word empty instead, but that didn't work.

Thanks in advance.

Hi Graham,

Sorry, I'm not familiar with ClassicPress - What's the advantage of using that over the Classic Editor plugin?

And just to confirm, do you see the same issue when using WordPress?

ClassicPress is a fork of WordPress 4.9 and has no Gutenberg code or functions. It works the same as WP used to, with the TinyMCE editor as the only editor.

The code works fine with PHP 7.x but throws an error with PHP 8.x

The '' option appears to be incompatible with the newer PHP. It causes a PHP error as a syntax type error for a null value.

I was just hoping someone might know why and if there was a different value you need to use.

I'll forward this to our developer to check :)

Hi there,

try changing that line to:

if ( isset( $options['content'] ) ) {

That fixed the error in gp-premium/blog/functions/images.php

But there are over 25 similar errors in gp-premium/page-header/functions/functions.php

And they are all worded differently. They all have if ( '' at the start, but the rest of the line is different.

I tried the fix on one line and it produced even more errors. I'm afraid it's all a bit beyond me.

Guess I'll just have to stick with PHP 7.4

Thanks for your help anyway.

Yeah their could be a quite a lot of changes. And the old Page Headers module has been deprecated some time now, so we wont be updating that.

You could of course use the Header Element instead in the latest version of GeneratePress, that is still suppprted and that does not require blocks. The only functions that GP requires blocks for is the Block Element...

This archived topic is closed to new replies.