Hello/Hi/Greetings,
I get this error message when I click on a picture. It is only in albums with extended description being used.
Notice: Trying to access array offset on value of type null in /home/xxx/xxx.com/plugins/meta/main.inc.php on line 200
Notice: Trying to access array offset on value of type null in /home/xxx/xxx.com/plugins/meta/main.inc.php on line 204
Warning: Cannot modify header information - headers already sent by (output started at /home/xxx/xxx.com/plugins/meta/main.inc.php:200) in /home/xxx/xxx.com/include/page_header.php on line 94
It was happening before the lastest upgrade. I think it started after my host went to PHP7.4
Piwigo 11.5.0 Check for upgrade
Operating system: Linux
PHP: 7.4.15 (Show info) [2021-05-16 04:55:31]
MySQL: 5.7.28-log [2021-05-16 04:55:31]
Graphics Library: ImageMagick 6.9.7-4
ce])
Piwigo URL: http://www.kkutzler.com
Offline
Edit local/config/config.inc.php
$conf['show_php_errors'] = 0;
Either directly or via Localfiles editor (plugin).
You must suppress error messages, becuse Piwigo's code is far from clean.
For fun, I checked with PHPstan and got around 12000 errors…
Offline
Setting that to 0 is a bad idea and ill-advised. You won't get any error message if something goes really wrong. Usually (unless you have bad plugins) for Piwigo on PHP 7.3 and earlier it's sufficient to suppress only deprecates
$conf['show_php_errors'] = E_ALL & ~E_DEPRECATED;
but on PHP 7.4 notices want to be suppressed as well.
$conf['show_php_errors'] = E_ALL & ~E_NOTICE & ~E_DEPRECATED;
Offline
Bull. You should never SHOW errors. You log them.
https://www.php.net/manual/en/errorfunc … lay-errors
Note:
This is a feature to support your development and should never be used on production systems (e.g. systems connected to the internet).
Last edited by Zentalquabula (2021-05-16 15:06:58)
Offline
So how do you configure Piwigo to log all PHP errors to file?
Right, you can't, AFAIK. Most people wouldn't even know how to do that with php.ini or a local .user.ini and crappy hosters might even forbid the latter. So, for all those rather display errors instead of not making them available at all.
However, this (best at the top) in local config logs errors (or however configured) to
piwigo/_data/logs/php-error.log
(unless $conf['data_location'] or $conf['log_dir'] are redefined).
$conf['show_php_errors'] = E_ALL & ~E_DEPRECATED; if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors'])) { // Define subdirectories in case include/config_default.inc.php was not read. // Identical (!) to include/config_default.inc.php, including slashes. if(!isset($conf['data_location']) || empty($conf['data_location'])) { $conf['data_location'] = '_data/'; } if(!isset($conf['log_dir']) || empty($conf['log_dir'])) { $conf['log_dir'] = '/logs'; } @ini_set('error_log', PHPWG_ROOT_PATH . $conf['data_location'] . $conf['log_dir'] . '/php-error.log'); @ini_set('log_errors', true); @ini_set('error_reporting', $conf['show_php_errors']); @ini_set('display_errors', false); $conf['show_php_errors_on_frontend'] = false; // Set to 0 so the same condition in include/common.inc.php does not override // it again to display errors. $conf['show_php_errors'] = 0; }
Note that the error log file has to be cycled manually to not grow forever.
Offline
If on, you may accidentally reveal your credentials in SQL statements. It is a REALLY BAD idea.
https://www.php.net/manual/en/errorfunc … log-errors
Note: You're strongly advised to use error logging in place of error displaying on production web sites.
If you can set up a server, you can also set up error logging. It is on per default in 7.4.
If the host doesn't allow it, switch host.
Offline
Zentalquabula wrote:
If on, you may accidentally reveal your credentials in SQL statements. It is a REALLY BAD idea.
That might happen if everything is completely rotten, yes.
If you can set up a server, you can also set up error logging. It is on per default in 7.4.
My impression is that most users wouldn't know either one nor the other.
If the host doesn't allow it, switch host.
Agreed, still, many wouldn't.
Anyway, I agree that error display is to be avoided and logged instead. I posted working Piwigo config code for how to switch from display_errors to log_errors if PHP is setup differently (or in any case for local to Piwigo logging).
Offline
Hi again
I have set the $conf to suppress the deprecated messages but instead of the code being executed, my browser is just displaying the full text of local/config.inc.php
The file is set to the correct owner and is also executable
Have I missed something?
Offline
Sorry - I missed adding the php directives at the start and end of the file
Offline
thank you, just upgraded to php 8.1.2 and had the same problem, didn't fix the deprecated but there hidden now. ;)
Offline
This worked for me:
root dir
/home/mysite/myhtml/.htaccess
following two lines:
php_flag error_reporting On php_flag display_errors Off
linux ubuntu 18.04 & 20.04
php8.1 (as @kenk mentioned the code is a bit messy. It shows lots of errors on switch to php 8.x)
apache2
#### edit #####
I have to qualify the above. The only errors I was seeing were in the osm plugin. OpenStreetMap.
Last edited by grantiago (2023-01-16 20:48:17)
Offline