geodesicsolutions-community / geocore-community

GeoCore Community, open source classifieds and auctions software
MIT License
9 stars 6 forks source link

Error with PHP8.1 on Sitemap page in admin panel #209

Closed vinprom1 closed 9 months ago

vinprom1 commented 1 year ago

Error when open /admin/index.php?page=site_map with PHP8.1 (in PHP7.4 work fine)

TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /templates_c/e9672fb4d91ca01e8a2228f9e4b44bffcf040c4a_0.geo_tset.site_map_category.php:50 Stack trace:

0 /vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_63ca4e9c5593c7_98046444()

1 /vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode()

2 /vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(383): Smarty_Template_Compiled->render()

3 /templates_c/b1821f320aad8afd58b028add6adfa08895b1117_0.geo_tset.admin_site_map_index.php(44): Smarty_Internal_Template->_subTemplateRender()

4 /vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_63ca4e9c554197_91139282()

5 /vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode()

6 /vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render()

7 /vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render()

8 /vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(116): Smarty_Internal_TemplateBase->_execute()

9 /classes/php5_classes/Template.class.php(485): Smarty_Internal_TemplateBase->fetch()

10 /classes/geo_smarty_plugins/function.body_html.php(50): geoTemplate::loadInternalTemplate()

11 /templates_c/48330c44fba757c8d0301f61fc1cc670b997acd9_0.geo_tset.index.php(252): smarty_function_body_html()

12 /vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_63ca4e95c9d7e9_35299192()

13 /vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode()

14 /vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render()

15 /vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render()

16 /vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(116): Smarty_Internal_TemplateBase->_execute()

17 /classes/php5_classes/View.class.php(1840): Smarty_Internal_TemplateBase->fetch()

18 /admin/php5_classes/Admin.class.php(217): geoView->toString()

19 /admin/php5_classes/Admin.class.php(576): geoAdmin->toString()

20 /admin/index.php(16): geoAdmin->load_page()

21 {main}

iBeleave commented 1 year ago

count no longer works in smarty templates if called on non-countable or null value suggested fix, just check if the item exists, which seems to work fine in smarty. Replace the lines shown below in \admin\templates\site_map\category.tpl

- {if count($category.children_pages) > 0}
+ {if $category.children_pages}
- {if count($category.children_categories) > 0}
+ {if $category.children_categories}