memberful / memberful-wp

Better membership software for WordPress.
https://memberful.com
42 stars 15 forks source link

Fixed statically calling instance method `delete_mapping` in syncing.php #322

Closed julianfssen closed 2 years ago

julianfssen commented 2 years ago

This PR fixes the following error caught by one of our customers, reported here:

HP Fatal error: Uncaught Error: Non-static method Memberful_User_Mapping_Repository::delete_mapping() cannot be called statically

The following instance method, delete_mapping:

// syncing.php

class Memberful_User_Mapping_Repository {
// ...

public function delete_mapping( $user_id ) {
  global $wpdb;

  return $wpdb->delete(self::table(), array( "wp_user_id" => $user_id ) );
}

is called statically in syncing.php#63:

// ...
if ( memberful_is_safe_to_delete( $user ) ) {
  wp_delete_user( $user->ID );
  Memberful_User_Mapping_Repository::delete_mapping( $user->ID );

which is deprecated in PHP 8.0 and throws an error on calling: PHP 8.0: Calling non-static class methods statically result in a fatal error