Commit c4952e15 authored by Dave Reid's avatar Dave Reid Committed by Dave Reid
Browse files

Issue #2705937 by Dave Reid: Ensure the url_alias table is created when the module is installed.

parent 3628aaca
......@@ -8,7 +8,6 @@
*/
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Utility\UpdateException;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\pathauto\Entity\PathautoPattern;
......@@ -20,6 +19,26 @@ function pathauto_install() {
// Set the weight to 1
module_set_weight('pathauto', 1);
// Ensure the url_alias table exists.
_pathauto_ensure_url_alias_table_exists();
}
/**
* Helper function to ensure the url_alias table exists.
*
* Only necessary on Drupal 8.1.x.
*
* @see https://www.drupal.org/node/2704821
*/
function _pathauto_ensure_url_alias_table_exists() {
$alias_storage = \Drupal::service('path.alias_storage');
if (method_exists($alias_storage, 'schemaDefinition')) {
$database_schema = \Drupal::database()->schema();
if (!$database_schema->tableExists($alias_storage::TABLE)) {
$schema_definition = $alias_storage->schemaDefinition();
$database_schema->createTable($alias_storage::TABLE, $schema_definition);
}
}
}
/**
......@@ -253,7 +272,7 @@ function pathauto_update_8103() {
}
}
/*
/**
* Resave patterns so that lookup keys are updated.
*/
function pathauto_update_8104() {
......@@ -265,3 +284,10 @@ function pathauto_update_8104() {
$pattern_config->save();
}
}
/**
* Ensure the url_alias table exists.
*/
function pathauto_update_8105() {
_pathauto_ensure_url_alias_table_exists();
}
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