File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Update.tar
CleanupProductTargetCountriesJob.php 0000644 00000003314 15155024140 0013701 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Update;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\AbstractProductSyncerBatchedJob;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductSyncerException;
defined( 'ABSPATH' ) || exit;
/**
* Class CleanupProductTargetCountriesJob
*
* Deletes the previous list of target countries which was in use before the
* Global Offers option became available.
*
* @since 1.1.0
* @package Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Update
*/
class CleanupProductTargetCountriesJob extends AbstractProductSyncerBatchedJob {
/**
* Get the name of the job.
*
* @return string
*/
public function get_name(): string {
return 'cleanup_product_target_countries';
}
/**
* Get a single batch of items.
*
* If no items are returned the job will stop.
*
* @param int $batch_number The batch number increments for each new batch in the job cycle.
*
* @return array
*/
public function get_batch( int $batch_number ): array {
return $this->product_repository->find_synced_product_ids( [], $this->get_batch_size(), $this->get_query_offset( $batch_number ) );
}
/**
* Process batch items.
*
* @param int[] $items A single batch of WooCommerce product IDs from the get_batch() method.
*
* @throws ProductSyncerException If an error occurs. The exception will be logged by ActionScheduler.
*/
protected function process_items( array $items ) {
$products = $this->product_repository->find_by_ids( $items );
$stale_entries = $this->batch_product_helper->generate_stale_countries_request_entries( $products );
$this->product_syncer->delete_by_batch_requests( $stale_entries );
}
}
PluginUpdate.php 0000644 00000003666 15155024140 0007666 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Update;
use Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\Service;
use Automattic\WooCommerce\GoogleListingsAndAds\Internal\Interfaces\InstallableInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\JobException;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\JobRepository;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\UpdateAllProducts;
defined( 'ABSPATH' ) || exit;
/**
* Runs update jobs when the plugin is updated.
*
* @since 1.1.0
* @package Automattic\WooCommerce\GoogleListingsAndAds\Jobs\Update
*/
class PluginUpdate implements Service, InstallableInterface {
/**
* @var JobRepository
*/
protected $job_repository;
/**
* PluginUpdate constructor.
*
* @param JobRepository $job_repository
*/
public function __construct( JobRepository $job_repository ) {
$this->job_repository = $job_repository;
}
/**
* Update Jobs that need to be run per version.
*
* @var array
*/
private $updates = [
'1.0.1' => [
CleanupProductTargetCountriesJob::class,
UpdateAllProducts::class,
],
'1.12.6' => [
UpdateAllProducts::class,
],
];
/**
* Run installation logic for this class.
*
* @param string $old_version Previous version before updating.
* @param string $new_version Current version after updating.
*/
public function install( string $old_version, string $new_version ): void {
foreach ( $this->updates as $version => $jobs ) {
if ( version_compare( $old_version, $version, '<' ) ) {
$this->schedule_jobs( $jobs );
}
}
}
/**
* Schedules a list of jobs.
*
* @param array $jobs List of jobs
*/
protected function schedule_jobs( array $jobs ): void {
foreach ( $jobs as $job ) {
try {
$this->job_repository->get( $job )->schedule();
} catch ( JobException $e ) {
do_action( 'woocommerce_gla_exception', $e, __METHOD__ );
}
}
}
}