juergenweb / FrontendForms

A module for ProcessWire CMS to create and validate forms on the frontend easily using the Valitron library.
MIT License
15 stars 1 forks source link

The creation of dynamic properties is deprecated in PHP 8.2 #1

Closed the-ge closed 1 year ago

the-ge commented 1 year ago

In PHP 8.2 the creation of dynamic properties was deprecated, hence the module installation spawns lots of

PHP Deprecated:  Creation of dynamic property FrontendForms\DefaultImageCaptcha::$[...] is deprecated in /var/www/html/site/modules/FrontendForms/Formelements/Tag.php on line 103

notices.

Although it doesn't really matter, here are the versions:

juergenweb commented 1 year ago

Hello Gabriel,

thank you for your feedback. I know, that it does not work properly in 8.2, but there are so many people out there who run a lower version than 8.2, that I had decided to do not take care about PHP 8.2. In PHP 8.1 it should work without warnings. I will add a hint on the readme file, that using 8.2 will lead to warnings at the moment. Thank you for reporting and using the module. I will update the module to be 8.2 ready, when the time is fine :-)

Best regards Jürgen

juergenweb commented 1 year ago

AllowDynamicProperties class added to class Tag to prevent warning on PHP 8.2 for dynamically decleared properties

juergenweb commented 1 year ago

All dynamic properties were replaced by a declared property. Should now work without problems in PHP 8.2 (if I have not forgotten a property to replace ;-). Corrected version is now available in the download section. Version number will be increased after more testing.

the-ge commented 1 year ago

You work faster than I think :grin:

I apologize for not being specific about the issue description. In my case it was - and it still is - caused by:

Although I'm not sure that these are the same as the first time.

The module spawned no more notices after I defined those properties, but I didn't grok your code enough to understand what would be the better solution.

The complete properties list is:

juergenweb commented 1 year ago

You are right: There was an relict from the old version, which I haver overlooked. Please update to 2.1.20 and let me know if the warnings are gone.

Best regards

the-ge commented 1 year ago
 Uncaught Error: Call to a member function setText() on null in site/modules/FrontendForms/Formelements/Captcha/AbstractImageCaptcha.php:33

The error is gone after making InputRadioMultiple::$topLabel public.

juergenweb commented 1 year ago

Thanks for reporting and offering the solution :-) I have made it public! I do not know why I have made it protected, but I guess I have made it out of habit...

the-ge commented 1 year ago

:+1: It's good now.

Time to put your module to work :grinning: