paid-memberships-pro
paid-memberships-pro copied to clipboard
Depricated warngins - PHP 8.2
Describe the bug Creation of dynamic properties deprecation notice when members cancel memberships (when email class fires)
To Reproduce Steps to reproduce the behavior:
- turn on error logging in PHP
- Click on 'CANCEL MEMBERSHIP' (follow through with cancellation)
- Read the deprecation notices in the log (or the output)
Deprecated: Creation of dynamic property PMProEmail::$headers is deprecated in /wp-content/plugins/paid-memberships-pro/classes/class.pmproemail.php on line 112
Deprecated: Creation of dynamic property PMProEmail::$attachments is deprecated in /wp-content/plugins/paid-memberships-pro/classes/class.pmproemail.php on line 114
Screenshots
Expected behavior
Deprecation patch (note: this issue is persistent across all classes within /paid-memberships-pro/classes/
not just the email class. currently I add #[AllowDynamicProperties]
and hide the problem like an ostrich... ;) but that means molesting the core files each release :(
Isolating the problem (mark completed items with an [x]):
- [x] I have deactivated other plugins and confirmed this bug occurs when only Paid Memberships Pro plugin is active.
- [x] This bug happens with a default WordPress theme active, or Memberlite.
- [x] I can reproduce this bug consistently using the steps above.
WordPress Environment
```
PHP8.2
WordPress6.4.3
Host: WPengine
```
SOLUTION: quick copy paste job.
- simply declare the property within the class: https://php.watch/versions/8.2/dynamic-properties-deprecated
- in this case, we just need some vars stuffed in and declared in the class for example:
// instead of this:
class PMProEmail
{
public $email = '';
public $from = '';
public $fromname = '';
//// which causes this error
$this->headers;
Deprecated: Creation of dynamic property PMProEmail::$headers
// do this
class PMProEmail
{
public $email = '';
public $from = '';
public $fromname = '';
private static $headers;
private static $attachments;
// error gos away