Commit bb433bee authored by gbyte.co's avatar gbyte.co

Remove unpublished variants when rebuilding queue

parent a58154a3
......@@ -184,8 +184,17 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
* @return $this
*/
public function remove($mode = 'all') {
$query = $this->db->delete('simple_sitemap')
->condition('type', $this->sitemapVariant);
self::removeSitemapVariant($this->sitemapVariant, $mode);
return $this;
}
public static function removeSitemapVariant($variant = NULL, $mode = 'all') {
$query = \Drupal::database()->delete('simple_sitemap');
if (NULL !== $variant) {
$query->condition('type', $variant);
}
switch($mode) {
case 'published':
......@@ -200,8 +209,6 @@ abstract class SitemapGeneratorBase extends SimplesitemapPluginBase implements S
//todo: throw error
}
$query->execute();
return $this;
}
/**
......
......@@ -3,6 +3,7 @@
namespace Drupal\simple_sitemap\Queue;
use Drupal\Component\Utility\Timer;
use Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator\SitemapGeneratorBase;
use Drupal\simple_sitemap\SimplesitemapSettings;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\simple_sitemap\SimplesitemapManager;
......@@ -106,11 +107,10 @@ class QueueWorker {
/**
* @return $this
*
* @todo Should remove all unpublished variants from db.
*/
public function deleteQueue() {
$this->queue->deleteQueue();
SitemapGeneratorBase::removeSitemapVariant(NULL, 'unpublished');
$this->variantProcessedNow = NULL;
$this->generatorProcessedNow = NULL;
$this->results = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment