diff --git a/plugins/FeedsNodeProcessor.inc b/plugins/FeedsNodeProcessor.inc index 46aa36e78d3d2db77326a5b288a4e962fe300435..407a0d3fad8cfb17367051921719447f570b027a 100644 --- a/plugins/FeedsNodeProcessor.inc +++ b/plugins/FeedsNodeProcessor.inc @@ -226,34 +226,33 @@ class FeedsNodeProcessor extends FeedsProcessor { * Static cached, may be called multiple times in a page load. */ public function getMappingTargets() { - static $targets; - if (empty($targets)) { - $targets = array( - 'title' => array( - 'name' => t('Title'), - ), - 'status' => array( - 'name' => t('Published status'), - ), - 'created' => array( - 'name' => t('Published date'), - ), - // Using 'teaser' instead of 'body' forces entire content above the break. - 'body' => array( - 'name' => t('Body'), - ), - 'url' => array( - 'name' => t('URL'), - 'optional_unique' => TRUE, - ), - 'guid' => array( - 'name' => t('GUID'), - 'optional_unique' => TRUE, - ), - ); - self::loadMappers(); - drupal_alter('feeds_node_processor_targets', $targets, $this->config['content_type']); - } + $targets = array( + 'title' => array( + 'name' => t('Title'), + ), + 'status' => array( + 'name' => t('Published status'), + ), + 'created' => array( + 'name' => t('Published date'), + ), + // Using 'teaser' instead of 'body' forces entire content above the break. + 'body' => array( + 'name' => t('Body'), + ), + 'url' => array( + 'name' => t('URL'), + 'optional_unique' => TRUE, + ), + 'guid' => array( + 'name' => t('GUID'), + 'optional_unique' => TRUE, + ), + ); + + self::loadMappers(); + drupal_alter('feeds_node_processor_targets', $targets, $this->config['content_type']); + return $targets; } diff --git a/plugins/FeedsProcessor.inc b/plugins/FeedsProcessor.inc index 1880a970e696da9c0d5fdf9cdc21420bea244512..4eeb2b7e7048c2d82d99cb372655ba2b3d73c6c2 100644 --- a/plugins/FeedsProcessor.inc +++ b/plugins/FeedsProcessor.inc @@ -51,6 +51,12 @@ abstract class FeedsProcessor extends FeedsPlugin { * Execute mapping on an item. */ protected function map($source_item, $target_item = NULL) { + + // Static cache $targets as getMappingTargets() may be an expensive method. + static $targets; + if (empty($targets)) { + $targets = $this->getMappingTargets(); + } $parser = feeds_importer($this->id)->parser; if (empty($target_item)) { $target_item = array(); @@ -65,7 +71,6 @@ abstract class FeedsProcessor extends FeedsPlugin { If the mapping specifies a callback method, use the callback instead of setTargetElement(). */ - $targets = $this->getMappingTargets(); foreach ($this->config['mappings'] as $mapping) { $value = $parser->getSourceElement($source_item, $mapping['source']);