Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8 undefined array keys in template #93

Closed
erAck opened this issue Jan 21, 2023 · 6 comments
Closed

PHP 8 undefined array keys in template #93

erAck opened this issue Jan 21, 2023 · 6 comments

Comments

@erAck
Copy link
Contributor

erAck commented Jan 21, 2023

With PHP 8.0 I get the following warnings logged:

PHP Warning:  Undefined array key "SHAREALBUM_LINK_IS_ACTIVE" in _data/templates_c/1djt82t^9da4b12e16d1d2bc973c8cd6e2002001bb2536aa_0.file.sharealbum_button_default.tpl.php on line 28
PHP Warning:  Attempt to read property "value" on null in _data/templates_c/1djt82t^9da4b12e16d1d2bc973c8cd6e2002001bb2536aa_0.file.sharealbum_button_default.tpl.php on line 28
PHP Warning:  Undefined array key "SHAREALBUM_LINK_IS_ACTIVE" in _data/templates_c/1djt82t^9da4b12e16d1d2bc973c8cd6e2002001bb2536aa_0.file.sharealbum_button_default.tpl.php on line 31
PHP Warning:  Attempt to read property "value" on null in _data/templates_c/1djt82t^9da4b12e16d1d2bc973c8cd6e2002001bb2536aa_0.file.sharealbum_button_default.tpl.php on line 31
PHP Warning:  Undefined array key "SHAREALBUM_LINK_CREATE" in _data/templates_c/1djt82t^9da4b12e16d1d2bc973c8cd6e2002001bb2536aa_0.file.sharealbum_button_default.tpl.php on line 43
PHP Warning:  Attempt to read property "value" on null in _data/templates_c/1djt82t^9da4b12e16d1d2bc973c8cd6e2002001bb2536aa_0.file.sharealbum_button_default.tpl.php on line 43
@petitssuisses
Copy link
Owner

petitssuisses commented Jan 23, 2023

Hi,
Tried with PHP8.0.20 and did not reproduce.
Can you tell me your exact version, and confirm you're running the latest plugin version ?
Your theme name as well ?

@erAck
Copy link
Contributor Author

erAck commented Jan 24, 2023

Piwigo 13.4.0 - Share Album 13.2 - PHP 8.0.27
Theme: Elegant, with GThumb+ in case it matters.
I get it already when browsing the gallery's home page.
Make sure you haven't E_WARNING excluded in error_reporting ;-)

@RenaeMacLeod
Copy link

I'm getting similar errors. It's only when using the share link in Chrome Incognito...

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /var/www/renae.ca/piwigo/plugins/ShareAlbum/main.inc.php on line 262

Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/renae.ca/piwigo/plugins/ShareAlbum/main.inc.php on line 263

Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/renae.ca/piwigo/plugins/ShareAlbum/main.inc.php on line 266

Since it's not exactly the same, would you like a fresh issue report?

ShareAlbum 13.2 / Piwigo 13.6.0 (core and extensions fully up to date) / Bootstrap Darkroom 2.5.15 / Ubuntu 22.04.2 / PHP 8.1.2-1ubuntu2.10

@gramakri
Copy link

Error/warning is shown despite php.ini config because piwigo default configuration turns on error reporting. Put this in piwigo's include/config.php

// this permit to show the php errors reporting (see INI 'error_reporting'
// for possible values)
// gives an empty value '' to deactivate
$conf['show_php_errors'] = '';

// This sets the display_errors php option to true, so php errors and warning
// messages are shown in the browser. If this is false, the error messages are 
// available in the php log of the server if show_php_errors has any set.
// If the below is turned off in local config and errors are still shown on 
// frontend, check for display_errors setting server's php config
$conf['show_php_errors_on_frontend'] = false;

@erAck
Copy link
Contributor Author

erAck commented Jun 29, 2023

Turning error reporting completely off is a workaround, but not a solution. I'd rather log errors and warnings to file but exclude Notice and Deprecated messages, and turn displaying errors off. So

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

If messages are still displayed then likely because php.ini sets display_errors and if that is wanted otherwise (though always bad on a production site) it can be selectively turned off for Piwigo using the recipe in https://piwigo.org/forum/viewtopic.php?pid=180778#p180778.

@gramakri
Copy link

@erAck Agreed. I was merely commenting on why changing php.ini has no effect on the errors/warnings. Ideally, the code is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants