Piwigo / piwigo-bootstrap-darkroom

A mobile-ready and feature-rich theme for Piwigo photo gallery, based on Bootstrap 4
Apache License 2.0
83 stars 40 forks source link

Fix error 'Undefined array key "COMMENT_COUNT"' with php 8.x #344

Closed wittypluck closed 1 year ago

wittypluck commented 1 year ago

Fix error 'Undefined array key "COMMENT_COUNT"' with php 8.x when option picture_info=tabs is selected. The fix is similar to how $COMMENT_COUNT is handled elsewhere in this theme's code and should be fully retro compatible with previous versions of php.

wittypluck commented 1 year ago

Possibly fixes issue #335. I haven't encountered any other issue with php 8.1 but haven't tested extensively.

sbochnak commented 1 year ago

HI, I've got 'Undefined array key "COMMENT_COUNT" error on a picture page, when using the theme with "card grid below the image" setting in the configuration. I do not have any comments nor do I allow for them.

A quick fix I made to solve it:

File: picture_info_cards.tpl line: 195

Replace: {if isset($metadata) || isset($comment_add) || $COMMENT_COUNT > 0 } with: {if isset($metadata) || isset($comment_add) || !empty($COMMENT_COUNT)}

then purging compiled templates and problem solved.

If you use : "Tabs below the image" setting on the theme config page, then the following fix is needed (basically - the same expression) in file picture_info_tabs.tpl, lines: 10 and 227

replace {if isset($comment_add) || $COMMENT_COUNT > 0 }

with

{if isset($comment_add) || !empty($COMMENT_COUNT)}