Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Symphony 2.5.3 #10

Open
tonyarnold opened this issue Mar 7, 2015 · 19 comments
Open

Error with Symphony 2.5.3 #10

tonyarnold opened this issue Mar 7, 2015 · 19 comments
Labels

Comments

@tonyarnold
Copy link

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()

An error occurred in /Users/tonyarnold/Sites/drcwine.com.au/extensions/association_output/extension.driver.php around line 118
113 $fields = FieldManager::fetch(null, $association['parent_section_id']);
114
115 foreach ($fields as $field) {
116 $modes = $field->fetchIncludableElements();
117
118 foreach ($modes as $mode) {
119 $value = $association['parent_section_id'] . '|#|' . $association['parent_section_field_id'] . '|#|' . $label . '|#|' . $mode;
120 $selected = false;
121
122 if ($section_id == $settings['section_id'] && isset($settings[$label])) {

Backtrace

[/Users/tonyarnold/Sites/drcwine.com.au/extensions/association_output/extension.driver.php:118]
    GenericErrorHandler::handler();
[/Users/tonyarnold/Sites/drcwine.com.au/extensions/association_output/extension.driver.php:82]
    extension_association_output->buildElementOptions();
[/Users/tonyarnold/Sites/drcwine.com.au/symphony/lib/toolkit/class.extensionmanager.php:706]
    extension_association_output->buildEditor();
[/Users/tonyarnold/Sites/drcwine.com.au/symphony/lib/core/class.administration.php:490]
    ExtensionManager::notifyMembers();
[/Users/tonyarnold/Sites/drcwine.com.au/symphony/lib/boot/func.utilities.php:232]
    Administration->display();
[/Users/tonyarnold/Sites/drcwine.com.au/symphony/lib/boot/func.utilities.php:208]
    symphony_launcher();
[/Users/tonyarnold/Sites/drcwine.com.au/index.php:14]
    symphony();

Database Query Log

[0.0002] SET character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8';
[0.0001] SET CHARACTER SET 'utf8';
[0.0001] SET time_zone = '+11:00';
[0.0006] SELECT SQL_CACHE t1.name, t2.page, t2.delegate, t2.callback FROM `sym_extensions` as t1 INNER JOIN `sym_extensions_delegates` as t2 ON t1.id = t2.extension_id WHERE t1.status = 'enabled' ORDER BY t2.delegate, t1.name;
[0.0002] SELECT SQL_CACHE `session_data` FROM `sym_sessions` WHERE `session` = '3hg8b3873060qb14sbopg9tgt7' LIMIT 1;
[0.0003] SELECT SQL_CACHE a.* FROM `sym_authors` AS `a` WHERE `username` = 'tonyarnold' ORDER BY a.id ASC LIMIT 1;
[0.0002] UPDATE sym_authors SET `last_seen` = '2015-03-07 22:01:43' WHERE `id` = 1;
[0.0003] SELECT SQL_CACHE `name` FROM `sym_extensions` WHERE `status` = 'enabled';
[0.0002] SELECT SQL_CACHE * FROM `sym_extensions`;
[0.0003] SELECT SQL_CACHE `s`.* FROM `sym_sections` AS `s` ORDER BY `s`.`sortorder` asc;
[0.0004] SELECT SQL_CACHE `s`.* FROM `sym_sections` AS `s` ORDER BY `s`.`name` ASC;
[0.0003] SELECT SQL_CACHE * FROM `sym_sections_association` AS `sa`, `sym_sections` AS `s` WHERE `sa`.`child_section_id` = 28 AND `s`.`id` = `sa`.`parent_section_id` ORDER BY `s`.`sortorder` ASC;
[0.0002] SELECT SQL_CACHE `element_name` FROM `sym_fields` WHERE `id` = 218 LIMIT 1;
[0.0002] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`parent_section` = '13' ORDER BY t1.`sortorder` ASC;
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_textbox` WHERE `field_id` IN (90);
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_uniqueupload` WHERE `field_id` IN (91);
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_reflection` WHERE `field_id` IN (435);
[0.0002] SELECT SQL_CACHE `element_name` FROM `sym_fields` WHERE `id` = 295 LIMIT 1;
[0.0003] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`parent_section` = '17' ORDER BY t1.`sortorder` ASC;
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_uniqueupload` WHERE `field_id` IN (129);
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_textbox` WHERE `field_id` IN (296);
[0.0003] SELECT SQL_CACHE * FROM `sym_fields_reflection` WHERE `field_id` IN (436);
[0.0004] SELECT SQL_CACHE * FROM `sym_sections_association` AS `sa`, `sym_sections` AS `s` WHERE `sa`.`child_section_id` = 13 AND `s`.`id` = `sa`.`parent_section_id` ORDER BY `s`.`sortorder` ASC;
[0.0002] SELECT SQL_CACHE `element_name` FROM `sym_fields` WHERE `id` = 308 LIMIT 1;
[0.0003] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`parent_section` = '36' ORDER BY t1.`sortorder` ASC;
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_publish_tabs` WHERE `field_id` IN (304,309);
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_textbox` WHERE `field_id` IN (305,306,419,420,310);
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_association` WHERE `field_id` IN (307,308);
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_enhancedtaglist` WHERE `field_id` IN (311);
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_author` WHERE `field_id` IN (312);
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_select` WHERE `field_id` IN (313);
[0.0002] SELECT SQL_CACHE * FROM `sym_fields_html_panel` WHERE `field_id` IN (314);
@nilshoerrmann
Copy link
Contributor

Thanks, Tony. I'l try have a look into this next week.

@tonyarnold
Copy link
Author

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.

@nilshoerrmann
Copy link
Contributor

Thanks, Tony!

@animaux
Copy link

animaux commented May 18, 2015

I have a similar issue on a 2.6.0 install. However on an almost similar installation it works.

@savosik
Copy link

savosik commented Jun 2, 2016

why this bug is closed without any commit ?

@nilshoerrmann
Copy link
Contributor

The related commit is here, it just wasn't referenced: 018dcb6

@savosik
Copy link

savosik commented Jun 2, 2016

ok. Is this commit merged to master ? I installed latest version from master - error happened. I manually changed this part of code ...

@nilshoerrmann
Copy link
Contributor

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.

@savosik
Copy link

savosik commented Jun 2, 2016

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

@nilshoerrmann
Copy link
Contributor

Ah, good catch! Seems like the fix has only been halfway through.

/cc @jonmifsud

@animaux
Copy link

animaux commented Nov 29, 2016

@nilshoerrmann Is it possible this is still not in 1.2.0?

@nilshoerrmann
Copy link
Contributor

Possible, yes.

@animaux
Copy link

animaux commented Nov 29, 2016

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.

@nilshoerrmann
Copy link
Contributor

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.

@animaux
Copy link

animaux commented Nov 29, 2016

Thanks Nils. I love the way we can summon people here like dæmons in a pagan ceremony :·D

@animaux
Copy link

animaux commented Feb 9, 2017

This is still a problem for me. @jonmifsud would you be able to investigate?

@animaux
Copy link

animaux commented Sep 26, 2017

Still turning up …

@twiro
Copy link

twiro commented Sep 26, 2017

Still turning up …

Confirmed! This error just showed up in a Symphony 2.6.11 project for me...

@animaux
Copy link

animaux commented Sep 27, 2017

@tonyarnold’s fix still works in Symphony 2.7.0, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants