backdrop-contrib / flag

Flag module for Backdrop CMS
0 stars 11 forks source link

PHP 8 incompatibility #42

Closed onyxnz closed 10 months ago

onyxnz commented 1 year ago

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 1286 of /var/www/clients/client1/web1/web/modules/flag/includes/flag/flag_flag.inc).

When adding an action. PHP 8-fpm, on Ubuntu.

argiepiano commented 10 months ago

This problem exists because Backdrop removed the key triggers from action definitions. This was removed because Backdrop doesn't support the D7 core module trigger. So, doing an array_keys on the null $action['triggers'] results in a fatal error.

The solution here is unclear. We could remove the if statement and show all the defined system actions. The check for 'all' in triggers was meant to show only those actions that were possibly triggered by any hook, via the defunct module trigger. Since the module trigger doesn't exist, I'm not even sure that adding actions will have ANY effect. In other words, the maintainers here should probably remove all functionality related to trigger. Only Rules can now be used to create custom actions for specific events.

argiepiano commented 10 months ago

A bit more about this. I'm not so familiar with flags. It looks like flag does include the ability to trigger pre-defined actions when someone flags an entity (so in a way it's like a trigger "lite").

In the D7 version, the 3 actions defined by flag itself, in flag_action_info(), were not available to create custom reactions in admin/structure/flags/actions, since those flag actions did not have 'any' in the 'triggers' key.

So a possible solution may be to "filter out" those 3 actions by hard-coding them, and then assuming that the rest of the Backdrop core-provided actions should all be accessible.

argiepiano commented 10 months ago

PR #45 submitted and ready for review.

herbdool commented 10 months ago

Merged the PR. Thanks @argiepiano