commit 571cc343fc8827def82727382b66ceb023fb0dfc Author: Joel Pittet Date: Mon Apr 20 08:59:06 2015 -0700 fast static diff --git a/pathauto.module b/pathauto.module index 2bc2fd0..5b35039 100644 --- a/pathauto.module +++ b/pathauto.module @@ -362,7 +362,14 @@ function pathauto_field_attach_form($entity_type, $entity, &$form, &$form_state, * Implements hook_entity_load(). */ function pathauto_entity_load($entities, $type) { - static $path_auto_entity_types; + static $drupal_static_fast; + + if (!isset($drupal_static_fast)) { + $drupal_static_fast = &drupal_static(__FUNCTION__); + } + + $path_auto_entity_types = &$drupal_static_fast; + // Save the entity types used statically to avoid unnessasary queries later. if (!isset($path_auto_entity_types)) { $path_auto_entity_types = db_query("SELECT entity_type FROM {pathauto_state} GROUP BY entity_type")->fetchAllKeyed(0, 0); @@ -412,6 +419,7 @@ function pathauto_entity_presave($entity, $type) { if (isset($entity->path['pathauto']) && !isset($entity->path['alias'])) { $entity->path['alias'] = ''; } + drupal_static_reset('pathauto_entity_load'); } /** @@ -461,6 +469,9 @@ function pathauto_entity_state_load($entity_type, $entity_id) { * An entity type. * @param $entity_ids * An array of entity IDs. + * + * @return + * An array of the state of pathauto keyed by the entity_id. */ function pathauto_entity_state_load_multiple($entity_type, $entity_ids) { static $table_exists; @@ -485,7 +496,7 @@ function pathauto_entity_state_load_multiple($entity_type, $entity_ids) { // Filter out entity_ids that are not integers. $entity_ids = array_filter($entity_ids, 'is_numeric'); - // if everything was filtered out, return an empty array + // If everything was filtered out, return an empty array. if (empty($entity_ids)) { return array(); }