Commit 9b81940e authored by gbyte.co's avatar gbyte.co

Remove state upon module uninstall

parent a588bf79
...@@ -65,6 +65,17 @@ function simple_sitemap_requirements($phase) { ...@@ -65,6 +65,17 @@ function simple_sitemap_requirements($phase) {
return $requirements; return $requirements;
} }
/**
* Implements hook_uninstall().
*/
function simple_sitemap_uninstall() {
\Drupal::service('state')->deleteMultiple([
'simple_sitemap.last_cron_generate',
'simple_sitemap.queue_items_initial_amount',
'simple_sitemap.queue_stashed_results',
]);
}
/** /**
* Implements hook_schema(). * Implements hook_schema().
*/ */
......
...@@ -55,7 +55,7 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase { ...@@ -55,7 +55,7 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase {
$queue_worker = $this->generator->getQueueWorker(); $queue_worker = $this->generator->getQueueWorker();
$indexed_count = $queue_worker->getProcessedElementCount(); $indexed_count = $queue_worker->getProcessedElementCount();
$total_count = $queue_worker->getOriginalElementCount(); $total_count = $queue_worker->getInitialElementCount();
$index_progress = [ $index_progress = [
'#theme' => 'progress_bar', '#theme' => 'progress_bar',
'#percent' => $total_count ? (100 * $indexed_count / $total_count) : 100, '#percent' => $total_count ? (100 * $indexed_count / $total_count) : 100,
......
...@@ -67,7 +67,7 @@ trait BatchTrait { ...@@ -67,7 +67,7 @@ trait BatchTrait {
$queue_worker->generateSitemap(); $queue_worker->generateSitemap();
$processed_element_count = $queue_worker->getProcessedElementCount(); $processed_element_count = $queue_worker->getProcessedElementCount();
$original_element_count = $queue_worker->getOriginalElementCount(); $original_element_count = $queue_worker->getInitialElementCount();
$context['message'] = t('@indexed out of @total total items have been indexed.', [ $context['message'] = t('@indexed out of @total total items have been indexed.', [
'@indexed' => $processed_element_count, '@total' => $original_element_count]); '@indexed' => $processed_element_count, '@total' => $original_element_count]);
......
...@@ -321,7 +321,7 @@ class QueueWorker { ...@@ -321,7 +321,7 @@ class QueueWorker {
} }
} }
public function getOriginalElementCount() { public function getInitialElementCount() {
if (NULL === $this->elementsTotal) { if (NULL === $this->elementsTotal) {
$this->elementsTotal = !empty($original = $this->state->get('simple_sitemap.queue_items_initial_amount')) $this->elementsTotal = !empty($original = $this->state->get('simple_sitemap.queue_items_initial_amount'))
? (int) $original ? (int) $original
...@@ -340,7 +340,7 @@ class QueueWorker { ...@@ -340,7 +340,7 @@ class QueueWorker {
} }
public function getProcessedElementCount() { public function getProcessedElementCount() {
$original = $this->getOriginalElementCount(); $original = $this->getInitialElementCount();
$remaining = $this->getRemainingElementCount(); $remaining = $this->getRemainingElementCount();
return $remaining <= $original ? ($original - $remaining) : 0; return $remaining <= $original ? ($original - $remaining) : 0;
......
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