I just installed piwigo to try it and ran into an error: When I visited the photos_add page I had a warnings about some php config values. I tried to hide the warning and the page reloaded into an error :
Warning: Undefined array key "setup_warnings" in /var/www/piwigo/_data/templates_c/p6jhns^a89b9dd2b03da870ac5f8f79b4ece1a8cca1ddc7_0.file.photos_add_direct.tpl.php on line 488
Warning: Attempt to read property "value" on null in /var/www/piwigo/_data/templates_c/p6jhns^a89b9dd2b03da870ac5f8f79b4ece1a8cca1ddc7_0.file.photos_add_direct.tpl.php on line 488
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/piwigo/_data/templates_c/p6jhns^a89b9dd2b03da870ac5f8f79b4ece1a8cca1ddc7_0.file.photos_add_direct.tpl.php:488 Stack trace: #0 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_64dde9cc6a1609_83470618() #1 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode() #2 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render() #3 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render() #4 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_internal_templatebase.php(116): Smarty_Internal_TemplateBase->_execute() #5 /var/www/piwigo/include/template.class.php(469): Smarty_Internal_TemplateBase->fetch() #6 /var/www/piwigo/include/template.class.php(392): Template->parse() #7 /var/www/piwigo/admin/photos_add_direct.php(158): Template->assign_var_from_handle() #8 /var/www/piwigo/admin/photos_add.php(73): include('...') #9 /var/www/piwigo/admin.php(345): include('...') #10 {main} thrown in /var/www/piwigo/_data/templates_c/p6jhns^a89b9dd2b03da870ac5f8f79b4ece1a8cca1ddc7_0.file.photos_add_direct.tpl.php on line 488
Hello !
I just installed piwigo to try it and ran into an error: When I visited the photos_add page I had a warnings about some php config values. I tried to hide the warning and the page reloaded into an error :
```
Warning: Undefined array key "setup_warnings" in /var/www/piwigo/_data/templates_c/p6jhns^a89b9dd2b03da870ac5f8f79b4ece1a8cca1ddc7_0.file.photos_add_direct.tpl.php on line 488
Warning: Attempt to read property "value" on null in /var/www/piwigo/_data/templates_c/p6jhns^a89b9dd2b03da870ac5f8f79b4ece1a8cca1ddc7_0.file.photos_add_direct.tpl.php on line 488
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/piwigo/_data/templates_c/p6jhns^a89b9dd2b03da870ac5f8f79b4ece1a8cca1ddc7_0.file.photos_add_direct.tpl.php:488 Stack trace: #0 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_64dde9cc6a1609_83470618() #1 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode() #2 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render() #3 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render() #4 /var/www/piwigo/include/smarty/libs/sysplugins/smarty_internal_templatebase.php(116): Smarty_Internal_TemplateBase->_execute() #5 /var/www/piwigo/include/template.class.php(469): Smarty_Internal_TemplateBase->fetch() #6 /var/www/piwigo/include/template.class.php(392): Template->parse() #7 /var/www/piwigo/admin/photos_add_direct.php(158): Template->assign_var_from_handle() #8 /var/www/piwigo/admin/photos_add.php(73): include('...') #9 /var/www/piwigo/admin.php(345): include('...') #10 {main} thrown in /var/www/piwigo/_data/templates_c/p6jhns^a89b9dd2b03da870ac5f8f79b4ece1a8cca1ddc7_0.file.photos_add_direct.tpl.php on line 488
```
I dug into the php files and found the cause of the error : When you enable hide_warnings, [setup_warnings doesn't get set in the template variables](https://github.com/Piwigo/Piwigo/blob/29ccabc89f4b00f67731e612cf84c8f16beaaa53/admin/include/photos_add_direct_prepare.inc.php#L184), and thus [count() is called on a null value](https://github.com/Piwigo/Piwigo/blob/29ccabc89f4b00f67731e612cf84c8f16beaaa53/admin/themes/default/template/photos_add_direct.tpl#L404) in the template.
I fixed the error by setting the variable to an empty array if hide_warnings is enabled but there might be better ways to go about it:
```diff
diff --git a/admin/include/photos_add_direct_prepare.inc.php a/admin/include/photos_add_direct_prepare.inc.php
216a217,222
> } else {
> $template->assign(
> array(
> 'setup_warnings' => array()
> )
> );
```
<!-- github-sync-id:1854705329 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Hello !
I just installed piwigo to try it and ran into an error: When I visited the photos_add page I had a warnings about some php config values. I tried to hide the warning and the page reloaded into an error :
I dug into the php files and found the cause of the error : When you enable hide_warnings, setup_warnings doesn't get set in the template variables, and thus count() is called on a null value in the template.
I fixed the error by setting the variable to an empty array if hide_warnings is enabled but there might be better ways to go about it:
any update on this, it’s preventing me uploading files on web.