Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By MegaChriz on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
7.x-2.x
Introduced in version:
7.x-2.0-beta1
Issue links:
Description:
Modules that implement hook_feeds_processor_targets_alter()
can specify additional mapping targets. Each target should specify a callback for how to handle the target.
In Feeds 7.x-2.0-alpha8 and earlier it was not clear what kind of value (with which the target should be populated) the target callback would get. It could be a string, integer, array, etcetera. The given value will now always be an array.
Before
<?php
/**
* Mapping target callback.
*/
function mymodule_feeds_set_target($source, $entity, $target, $value, $mapping) {
if (!is_array($value)) {
$value = array($value);
}
$delta = 0;
foreach ($value as $v) {
$entity->{$target}[$entity->language][$delta]['value'] = $v;
$delta++;
}
}
?>
After
<?php
/**
* Mapping target callback.
*/
function mymodule_feeds_set_target($source, $entity, $target, array $values, $mapping) {
$delta = 0;
foreach ($values as $value) {
$entity->{$target}[$entity->language][$delta]['value'] = $value;
$delta++;
}
}
?>
Impacts:
Module developers