Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlavtox committed Jan 5, 2024
1 parent f0d9b84 commit 2557350
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
46 changes: 23 additions & 23 deletions controllers/front/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@
*/
class GsitemapCronModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
// Check correct token when not in CLI context
if (!Tools::isPHPCLI() && Tools::substr(Tools::hash('gsitemap/cron'), 0, 10) != Tools::getValue('token')) {
exit('Bad token');
}
public function postProcess()
{
// Check correct token when not in CLI context
if (!Tools::isPHPCLI() && Tools::substr(Tools::hash('gsitemap/cron'), 0, 10) != Tools::getValue('token')) {
exit('Bad token');
}

// Check if the requested shop exists
$shops = Db::getInstance()->ExecuteS('SELECT id_shop FROM `' . _DB_PREFIX_ . 'shop`');
$list_id_shop = [];
foreach ($shops as $shop) {
$list_id_shop[] = (int) $shop['id_shop'];
}
// Check if the requested shop exists
$shops = Db::getInstance()->ExecuteS('SELECT id_shop FROM `' . _DB_PREFIX_ . 'shop`');
$list_id_shop = [];
foreach ($shops as $shop) {
$list_id_shop[] = (int) $shop['id_shop'];
}

$id_shop = (Tools::getIsset('id_shop') && in_array(Tools::getValue('id_shop'), $list_id_shop)) ? (int) Tools::getValue('id_shop') : (int) Configuration::get('PS_SHOP_DEFAULT');

// Mark a flag that we are in cron context
$this->module->cron = true;
$id_shop = (Tools::getIsset('id_shop') && in_array(Tools::getValue('id_shop'), $list_id_shop)) ? (int) Tools::getValue('id_shop') : (int) Configuration::get('PS_SHOP_DEFAULT');
// Mark a flag that we are in cron context
$this->module->cron = true;

// If this is the first request to generate, we delete all previous sitemaps
if (!Tools::getIsset('continue')) {
$this->module->emptySitemap((int) $id_shop);
}
// If this is the first request to generate, we delete all previous sitemaps
if (!Tools::getIsset('continue')) {
$this->module->emptySitemap((int) $id_shop);
}

// Run generation
$this->module->createSitemap((int) $id_shop);
}
// Run generation
$this->module->createSitemap((int) $id_shop);
}
}
7 changes: 3 additions & 4 deletions gsitemap-cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/

/**
/*
* This file can be called using a cron to generate Google sitemap files automatically.
*
* @deprecated This file should no longer be used and will be removed in 5.0.0 version of this module.
* Please update your cron tasks to use the new URL available in module settings.
* This file should no longer be used and will be removed in 5.0.0 version of this module.
* Please update your cron tasks to use the new URL available in module settings.
*/
trigger_error('This file should no longer be used and will be removed in 5.0.0 version of this module. Please update your cron tasks to use the new URL available in module settings.', E_USER_NOTICE);

Expand Down

0 comments on commit 2557350

Please sign in to comment.