If formatter does not contain underscore than the $parts array will be empty since it is popped at the second line, so the implode function will try to implode an empty array
$parts = explode('_', $formatter);
$style = array_pop($parts);
$presetname = implode('_', $parts);
Solution
// Check if there is an underscore in the formatter name
if (strpos($formatter, '_')) {
preg_match('/^(.*)_(linked|imagelink|path|url)?$/', $formatter, $matches);
// Shift the first element of regex match since it contains the whole string (formatter)
array_shift($matches);
list($presetname, $style) = $matches;
}
else {
$presetname = $formatter;
}
Comments
Comment #1
energie commentedSorry, i've found a bug in my patch
Here comes the correct one...
condition changed
Comment #2
soxofaan commentedIsn't just easier to make sure all formatters names have the same structure?
Comment #3
soxofaan commentedthis issue is duplicate of http://drupal.org/node/249363
marking this one as the duplicate because the other is older (and longer)