Announcement

#1 2021-05-16 13:57:32

kenk
Member
2017-03-19
10

Error Message

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

 

#2 2021-05-16 14:11:14

Zentalquabula
Member
2014-05-10
208

Re: Error Message

Edit local/config/config.inc.php

Code:

$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

 

#3 2021-05-16 14:47:59

erAck
Only trying to help
2015-09-06
1500

Re: Error Message

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

Code:

$conf['show_php_errors'] = E_ALL & ~E_DEPRECATED;

but on PHP 7.4 notices want to be suppressed as well.

Code:

$conf['show_php_errors'] = E_ALL & ~E_NOTICE & ~E_DEPRECATED;

Running Piwigo at https://erack.net/gallery/

Offline

 

#4 2021-05-16 15:01:04

Zentalquabula
Member
2014-05-10
208

Re: Error Message

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

 

#5 2021-05-16 17:39:57

erAck
Only trying to help
2015-09-06
1500

Re: Error Message

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).

Code:

$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);
  // 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.


Running Piwigo at https://erack.net/gallery/

Offline

 

#6 2021-05-16 20:45:47

Zentalquabula
Member
2014-05-10
208

Re: Error Message

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

Code:

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

 

#7 2021-05-17 00:50:56

erAck
Only trying to help
2015-09-06
1500

Re: Error Message

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).


Running Piwigo at https://erack.net/gallery/

Offline

 

#8 2021-12-10 22:27:47

cmprior
Member
2021-12-10
5

Re: Error Message

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

 

#9 2021-12-10 22:30:28

cmprior
Member
2021-12-10
5

Re: Error Message

Sorry - I missed adding the php directives at the start and end of the file

Offline

 

#10 2022-02-15 16:01:36

rhermans
Member
Belgium
2012-09-05
7

Re: Error Message

thank you, just upgraded to php 8.1.2 and had the same problem, didn't fix the deprecated but there hidden now.  ;)

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact