diff -u b/pathauto.install b/pathauto.install --- b/pathauto.install +++ b/pathauto.install @@ -11,8 +11,8 @@ * Implements hook_schema(). */ function pathauto_schema() { - $schema['pathauto_state'] = array( - 'description' => '', + $schema['pathauto_regenerate'] = array( + 'description' => 'The status of each entity alias (whether it was automatically generated or not).', 'fields' => array( 'entity_type' => array( 'type' => 'varchar', @@ -223,9 +223,9 @@ * Create pathauto table, copying data from pathauto_persist if it exists */ function pathauto_update_7006() { - if (!db_table_exists('pathauto_state')) { + if (!db_table_exists('pathauto_regenerate')) { - $schema['pathauto_state'] = array( + $schema['pathauto_regenerate'] = array( 'description' => 'The status of each entity alias (whether it was automatically generated or not).', 'fields' => array( 'entity_type' => array( @@ -254,15 +254,22 @@ if (db_table_exists('pathauto_persist')) { // Rename pathauto_persist's table, then create a new empty one just so // that we can cleanly disable that module. - db_rename_table('pathauto_persist', 'pathauto_state'); - db_create_table('pathauto_persist', $schema['pathauto_state']); + db_rename_table('pathauto_persist', 'pathauto_regenerate'); + db_create_table('pathauto_persist', $schema['pathauto_regenerate']); + // Change the entity_id column to varchar because the entity system does + // not assume serial or integer IDs (see [#1823494]). + db_drop_primary_key('pathauto_regenerate'); + db_change_field('pathauto_regenerate', 'entity_id', 'entity_id', + array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'An entity ID.')); + db_add_primary_key('pathauto_regenerate', array('entity_type', 'entity_id')); + // Disable the module and inform the user. if (module_exists('pathauto_persist')) { module_disable(array('pathauto_persist')); } return t('This version of Pathauto includes the functionality of Pathauto Persist, which has been disabled and can be safely removed. All settings have been copied.'); } else { - db_create_table('pathauto_state', $schema['pathauto_state']); + db_create_table('pathauto_regenerate', $schema['pathauto_regenerate']); } } } diff -u b/pathauto.module b/pathauto.module --- b/pathauto.module +++ b/pathauto.module @@ -427,8 +427,8 @@ * An entity ID. */ function pathauto_entity_state_load($entity_type, $entity_id) { - $pathauto_state = pathauto_entity_state_load_multiple($entity_type, array($entity_id)); - return !empty($pathauto_state) ? reset($pathauto_state) : FALSE; + $pathauto_regenerate = pathauto_entity_state_load_multiple($entity_type, array($entity_id)); + return !empty($pathauto_regenerate) ? reset($pathauto_regenerate) : FALSE; } /** @@ -440,8 +440,8 @@ * An array of entity IDs. */ function pathauto_entity_state_load_multiple($entity_type, $entity_ids) { - $pathauto_state = db_query("SELECT entity_id, pathauto FROM {pathauto_state} WHERE entity_type = :entity_type AND entity_id IN (:entity_ids)", array(':entity_type' => $entity_type, ':entity_ids' => $entity_ids))->fetchAllKeyed(); - return $pathauto_state; + $pathauto_regenerate = db_query("SELECT entity_id, pathauto FROM {pathauto_regenerate} WHERE entity_type = :entity_type AND entity_id IN (:entity_ids)", array(':entity_type' => $entity_type, ':entity_ids' => $entity_ids))->fetchAllKeyed(); + return $pathauto_regenerate; } /** @@ -451,19 +451,19 @@ * An entity type. * @param $entity * The entity object. - * @param $pathauto_state + * @param $pathauto_regenerate * A boolean flag if TRUE means that Pathauto should keep controlling this * entity's path in the future. A FALSE value means Pathauto should stay out. */ -function pathauto_entity_state_save($entity_type, $entity, $pathauto_state) { +function pathauto_entity_state_save($entity_type, $entity, $pathauto_regenerate) { list($entity_id) = entity_extract_ids($entity_type, $entity); - db_merge('pathauto_state') + db_merge('pathauto_regenerate') ->key(array( 'entity_type' => $entity_type, 'entity_id' => $entity_id, )) ->fields(array( - 'pathauto' => $pathauto_state ? 1 : 0, + 'pathauto' => $pathauto_regenerate ? 1 : 0, )) ->execute(); } @@ -478,7 +478,7 @@ */ function pathauto_entity_state_delete($entity_type, $entity) { list($entity_id) = entity_extract_ids($entity_type, $entity); - db_delete('pathauto_state') + db_delete('pathauto_regenerate') ->condition('entity_type', $entity_type) ->condition('entity_id', $entity_id) ->execute();