Skip to content

Commit

Permalink
fix updater API Client
Browse files Browse the repository at this point in the history
  • Loading branch information
wordpressfan committed Jun 26, 2024
1 parent a3cb7ba commit b74a302
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion inc/Engine/Common/JobManager/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
use WP_Rocket\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;
use WP_Rocket\Engine\Common\Clock\WPRClock;
use WP_Rocket\Engine\Common\JobManager\APIHandler\APIClient;
use WP_Rocket\Engine\Common\JobManager\APIHandler\PluginUpdateClient;
use WP_Rocket\Engine\Common\JobManager\Cron\Subscriber as CronSubscriber;
use WP_Rocket\Engine\Common\JobManager\Queue\Queue;
use WP_Rocket\Engine\Common\JobManager\Strategy\Context\RetryContext;
use WP_Rocket\Engine\Common\JobManager\Strategy\Factory\StrategyFactory;
use WP_Rocket\Engine\Plugin\PluginInformationClient;
use WP_Rocket\Engine\Plugin\PluginUpdateClient;


class ServiceProvider extends AbstractServiceProvider {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace WP_Rocket\Engine\Common\JobManager\APIHandler;
namespace WP_Rocket\Engine\Plugin;

use WP_Rocket\Engine\Common\JobManager\APIHandler\AbstractSafeAPIClient;

/**
* Class PluginUpdateClient
Expand All @@ -10,7 +12,7 @@
*
* @package WP_Rocket\Engine\Common\JobManager\APIHandler
*/
class PluginUpdateClient extends AbstractSafeAPIClient {
class UpdaterAPIClient extends AbstractSafeAPIClient {

/**
* Get the transient key for plugin updates.
Expand All @@ -31,6 +33,6 @@ protected function get_transient_key() {
* @return string The API URL for plugin updates.
*/
protected function get_api_url() {
return 'https://wp-rocket.me/check_update.php';
return rocket_get_constant( 'WP_ROCKET_WEB_CHECK', 'https://wp-rocket.me/check_update.php' );
}
}
10 changes: 6 additions & 4 deletions inc/Engine/Plugin/UpdaterSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Plugin_Upgrader_Skin;
use WP_Error;
use WP_Rocket\Event_Management\{Event_Manager, Event_Manager_Aware_Subscriber_Interface};
use WP_Rocket\Engine\Common\JobManager\APIHandler\PluginUpdateClient;

/**
* Manages the plugin updates.
Expand Down Expand Up @@ -81,6 +80,8 @@ class UpdaterSubscriber implements Event_Manager_Aware_Subscriber_Interface {
*/
private $renewal_notice;

private $client;

Check notice on line 83 in inc/Engine/Plugin/UpdaterSubscriber.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Plugin/UpdaterSubscriber.php#L83

Missing member variable doc comment

/**
* Constructor
*
Expand All @@ -93,15 +94,17 @@ class UpdaterSubscriber implements Event_Manager_Aware_Subscriber_Interface {
* @type string $vendor_url URL to the plugin provider.
* @type string $api_url URL to contact to get update info.
* }
* @param UpdaterAPIClient $client API Client.
*/
public function __construct( RenewalNotice $renewal_notice, $args ) {
public function __construct( RenewalNotice $renewal_notice, $args, UpdaterAPIClient $client ) {
foreach ( [ 'plugin_file', 'plugin_version', 'vendor_url', 'api_url', 'icons' ] as $setting ) {
if ( isset( $args[ $setting ] ) ) {
$this->$setting = $args[ $setting ];
}
}

$this->renewal_notice = $renewal_notice;
$this->client = $client;

Check notice on line 107 in inc/Engine/Plugin/UpdaterSubscriber.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Plugin/UpdaterSubscriber.php#L107

Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space
}

/**
Expand Down Expand Up @@ -306,8 +309,7 @@ public function disable_auto_updates( $update, $item ) {
* }
*/
public function get_latest_version_data() {
$client = new PluginUpdateClient();
$response = $client->send_get_request( [] );
$response = $this->client->send_get_request();

if ( is_wp_error( $response ) ) {
return $this->get_request_error(
Expand Down

0 comments on commit b74a302

Please sign in to comment.