Open tonyarnold opened 9 years ago
Thanks, Tony. I'l try have a look into this next week.
Thanks Nils.
I ended up editing extension.driver.php
and updating buildElementOptions()
to look like so:
private function buildElementOptions($association, $settings, $section_id)
{
$elements = array();
$label = FieldManager::fetchHandleFromID($association['child_section_field_id']);
$fields = FieldManager::fetch(null, $association['parent_section_id']);
if (is_array($fields) || $fields instanceof Traversable) {
foreach ($fields as $field) {
$modes = $field->fetchIncludableElements();
if (is_array($modes) || $modes instanceof Traversable) {
foreach ($modes as $mode) {
$value = $association['parent_section_id'] . '|#|' . $association['parent_section_field_id'] . '|#|' . $label . '|#|' . $mode;
$selected = false;
if ($section_id == $settings['section_id'] && isset($settings[$label])) {
if (in_array($mode, $settings[$label]['elements'])) {
$selected = true;
}
}
$elements[] = array($value, $selected, $mode);
}
}
}
}
return array(
'label' => $label,
'data-label' => $section_id,
'options' => $elements
);
}
Note the if (is_array($fields) || $fields instanceof Traversable) { … }
around the lines that were failing. It seems to work without ill effect, but I don't know enough about your code to know if there are other consequences to doing this.
Thanks, Tony!
I have a similar issue on a 2.6.0 install. However on an almost similar installation it works.
why this bug is closed without any commit ?
The related commit is here, it just wasn't referenced: https://github.com/mazedigital/association_output/commit/018dcb651c3b5384aa1c241cd6b60d26a64d1bcc
ok. Is this commit merged to master ? I installed latest version from master - error happened. I manually changed this part of code ...
It's in master
representing version 1.1.0. If you had to change these lines manually, your extension version must have been out of date.
Look at master https://github.com/mazedigital/association_output/blob/master/extension.driver.php#L119
if (is_array($modes) || $modes instanceof Traversable) {
this string is not there
Ah, good catch! Seems like the fix has only been halfway through.
/cc @jonmifsud
@nilshoerrmann Is it possible this is still not in 1.2.0
?
Possible, yes.
For some strange reason I have two almost identical installations where in one I can edit the DSes without problems, while in the other I always get this error. However replacing the buildElementOptions()
like @tonyarnold did here helps.
We haven't been using this extension lately. Asking @jonmifsud to jump in as he might know the current state of the extension better than I do.
Thanks Nils. I love the way we can summon people here like dæmons in a pagan ceremony :·D
This is still a problem for me. @jonmifsud would you be able to investigate?
Still turning up …
Still turning up …
Confirmed! This error just showed up in a Symphony 2.6.11 project for me...
Hi Nils,
I know you're probably not working on this anymore, but I thought I'd pop this issue in for posterity's sake. I'm seeing an error whenever I try to edit a datasource under Symphony 2.5.3 and it's pointing it's finger at this extension.
Symphony Warning: Invalid argument supplied for foreach()
Backtrace
Database Query Log