Commit 4e87836d authored by larowlan's avatar larowlan

Issue #2991346 by alexpott: The message displayed by taxonomy_update_8601() should be overridable

(cherry picked from commit 237b3f41)
parent 058f3387
...@@ -138,9 +138,10 @@ function taxonomy_update_8601() { ...@@ -138,9 +138,10 @@ function taxonomy_update_8601() {
// Bail out early if a field named 'status' is already installed. // Bail out early if a field named 'status' is already installed.
if ($definition_update_manager->getFieldStorageDefinition('status', 'taxonomy_term')) { if ($definition_update_manager->getFieldStorageDefinition('status', 'taxonomy_term')) {
return t('The publishing status field has <strong>not</strong> been added to taxonomy terms. See <a href=":link">this page</a> for more information on how to install it.', [ $message = \Drupal::state()->get('taxonomy_update_8601_skip_message', t('The publishing status field has <strong>not</strong> been added to taxonomy terms. See <a href=":link">this page</a> for more information on how to install it.', [
':link' => 'https://www.drupal.org/node/2985366', ':link' => 'https://www.drupal.org/node/2985366',
]); ]));
return $message;
} }
// Add the 'published' entity key to the taxonomy_term entity type. // Add the 'published' entity key to the taxonomy_term entity type.
......
...@@ -80,6 +80,13 @@ public function testPublishable() { ...@@ -80,6 +80,13 @@ public function testPublishable() {
$term->save(); $term->save();
$term = $storage->loadUnchanged($term->id()); $term = $storage->loadUnchanged($term->id());
$this->assertFalse($term->isPublished()); $this->assertFalse($term->isPublished());
// Test the update does not run when a status field already exists.
module_load_install('taxonomy');
$this->assertEquals('The publishing status field has <strong>not</strong> been added to taxonomy terms. See <a href="https://www.drupal.org/node/2985366">this page</a> for more information on how to install it.', (string) taxonomy_update_8601());
// Test the message can be overridden.
\Drupal::state()->set('taxonomy_update_8601_skip_message', 'Another message');
$this->assertEquals('Another message', (string) taxonomy_update_8601());
} }
/** /**
......
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