backdrop-contrib / flag

Flag module for Backdrop CMS
0 stars 11 forks source link

PHP 8.2 deprecation notices #51

Open jenlampton opened 6 months ago

jenlampton commented 6 months ago

I'm running PHP 8.2 and I'm seeing dozens of notices like the following:

Deprecated function: Creation of dynamic property flag_node::$flag_short is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$flag_long is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$flag_message is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$unflag_short is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$unflag_long is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$unflag_message is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$unflag_denied_text is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$link_type is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$weight is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$show_in_links is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$show_as_field is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$show_on_form is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$access_author is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$show_contextual_link is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$i18n is deprecated in flag_flag->construct() (line 227 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$options is deprecated in flag_flag::factory_by_row() (line 125 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).
Deprecated function: Creation of dynamic property flag_node::$type is deprecated in flag_flag::factory_by_row() (line 125 of backdrop/modules/contrib/flag/includes/flag/flag_flag.inc).

Here's the change notice from PHP https://php.watch/versions/8.2/dynamic-properties-deprecated

aduhour commented 1 month ago

Hello, here is posted a solution to the drupal module: https://www.drupal.org/project/flag/issues/3359763.

As suggested, adding the attribute :

#[AllowDynamicProperties] class flag_flag {...}

signals PHP to not emit any deprecation notices.

Regards, Andrés

argiepiano commented 1 month ago

Hola Andrés! Would you like to submit a PR for this? It's easy, and it would help the maintainer. Take a look at the [guidelines](Contributing to an existing project) for contributing to an existing project.

aduhour commented 1 month ago

Hello! Following your suggestion, I've sent my contribution to fix this issue. Andrés

jenlampton commented 4 days ago

PR works for me. Thank you @aduhour !