Cloudflare-WordPress
Cloudflare-WordPress copied to clipboard
Fix PHP Deprecated messages
Confirmation
- [X] My issue isn't already found on the issue tracker.
- [X] I have replicated my issue using the latest version of the plugin and it is still present.
WordPress version
6.3.2
Cloudflare-WordPress version
4.12.2
PHP version
8.2.11
Expected result
No messages
Actual result
PHP Deprecated: Creation of dynamic property CF\WordPress\Proxy::$pluginAPI is deprecated in ***/wp-content/plugins/cloudflare/src/WordPress/Proxy.php on line 31
PHP Deprecated: Creation of dynamic property CF\WordPress\DataStore::$logger is deprecated in ***/wp-content/plugins/cloudflare/src/WordPress/DataStore.php on line 23
Steps to reproduce
Activate Debug logging
Additional factoids
How to fix:
class DataStore {
public $logger;
// ... rest of the class
}
namespace CF\WordPress;
use CF\Integration\DefaultLogger;
use CF\Integration\DataStoreInterface;
use CF\API\Plugin;
use Symfony\Polyfill\Tests\Intl\Idn;
class DataStore implements DataStoreInterface
{
const API_KEY = 'cloudflare_api_key';
const EMAIL = 'cloudflare_api_email';
const CACHED_DOMAIN_NAME = 'cloudflare_cached_domain_name';
protected $wordPressWrapper;
protected $logger; // <-- Add this line here
/**
* @param DefaultLogger $logger
*/
public function __construct(DefaultLogger $logger)
{
$this->logger = $logger;
$this->wordPressWrapper = new WordPressWrapper();
}
// ... rest of the class
}
namespace CF\WordPress;
use CF\API;
use CF\API\Plugin;
use CF\Integration\IntegrationInterface;
use CF\Router\RequestRouter;
class Proxy
{
protected $config;
protected $dataStore;
protected $logger;
protected $wordpressAPI;
protected $wordpressClientAPI;
protected $wordpressIntegration;
protected $requestRouter;
protected $pluginAPI; // <-- Add this line here
/**
* @param IntegrationInterface $integration
*/
public function __construct(IntegrationInterface $integration)
{
// ... rest of the constructor
}
// ... rest of the class
}
References
No response
@PHP8Coder protected $logger; or public though? Or either would be a safe one? (asking because I don't know)
Please
Same
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
bump