Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Dave J on January 22, 2021, 06:52:09 AM

Title: Load.php error
Post by: Dave J on January 22, 2021, 06:52:09 AM
Hi All

I'm using SMF 2.0.17 with PHP 7.0

The error is

https://www.davejohnson.co.uk/index.php?action=admin;area=logs;sa=errorlog;desc
8: Trying to access array offset on value of type null
File: /******/********/public_html/Sources/Load.php
Line: 192

=>192: $utf8 = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8' && (strpos(strtolower(PHP_OS), 'win') === false || @version_compare(PHP_VERSION, '4.2.3') != -1);


I have not set the database to UTF-8.

Not sure if these are related but if you look at the attachment below the 'Error Log' reports there are 2 errors but the list only shows 1.

It doesn't matter how many errors there are it always says there 1 more than there is.

Can you help please?
Title: Re: Load.php error
Post by: tjbalon on January 22, 2021, 08:28:57 AM
I assume that either: $modSettings['global_character_set'] or $txt['lang_character_set'] are null in this case.

Optionally, to figure out which one, you could check if the two arrays are null prior to that call (remember to backup the file first).

// add before line 192 in Load.php
if (is_null($txt['lang_character_set'])){
trigger_error("$txt is null", E_USER_WARNING);
} elseif (is_null($modSettings['global_character_set'])){
trigger_error("$modSettings is null", E_USER_WARNING);
}


Reload the page, post back the results and we can go from there. I am going to assume it will be an issue with $modSettings.
Title: Re: Load.php error
Post by: Dave J on January 22, 2021, 09:20:11 AM
Ok did that now there are 3 errors, see attachment
Title: Re: Load.php error
Post by: tjbalon on January 22, 2021, 09:47:59 AM
Apologies, it is rendering the variable, change to:


// add before line 192 in Load.php
if (is_null($txt['lang_character_set'])){
trigger_error("txt is null", E_USER_WARNING);
} elseif (is_null($modSettings['global_character_set'])){
trigger_error("modSettings is null", E_USER_WARNING);
}


From the looks of it however, it is going to be $txt['lang_character_set'] that is null, but make that change and reload to confirm
Title: Re: Load.php error
Post by: Dave J on January 22, 2021, 10:32:36 AM
These are the errors
Title: Re: Load.php error
Post by: Sir Osis of Liver on January 22, 2021, 12:03:07 PM
Clear forum cache.
Title: Re: Load.php error
Post by: Dave J on January 22, 2021, 12:18:21 PM
Quote from: Sir Osis of Liver on January 22, 2021, 12:03:07 PM
Clear forum cache.

That makes no difference.

Emptied in maintenance and via ftp
Title: Re: Load.php error
Post by: Sir Osis of Liver on January 22, 2021, 12:22:04 PM
Did you change something just before error appeared?
Title: Re: Load.php error
Post by: Dave J on January 22, 2021, 12:31:29 PM
Quote from: Sir Osis of Liver on January 22, 2021, 12:22:04 PM
Did you change something just before error appeared?

No I didn't but I have just checked the PHP version and the host changed me to PHP 74 the .htaccess file said I was still on php70

So I have just changed it back to PHP 71 and the error has now gone

Thanks guys for the replies it's much appreciated.
Title: Re: Load.php error
Post by: Sir Osis of Liver on January 22, 2021, 12:34:17 PM
2.0.17 supports up to php 7.3.  Your forum looked to be running ok in 7.4, but will log a lot of errors.  My forums are running in 7.2.
Title: Re: Load.php error
Post by: tarantula901 on November 24, 2022, 08:34:22 AM
Thanks for your help.

It is necessary to do "Convert HTML-entities to UTF-8 characters" from the admin panel.

Unfortunately, I struggled a bit because I did not do this process because I did everything manually.