Announcement

Symphony's issue tracker has been moved to Github.

Issues are displayed here for reference only and cannot be created or edited.

Browse

Closed#200: (2.0.7) Saving preferences results in an error

Invalid argument supplied for foreach()
An error occurred in /www/htdocs/webseiten/hananils/symphony/content/content.systempreferences.php around line 65

60:                 $this->_Parent->ExtensionManager->notifyMembers('Save', '/system/preferences/', array('settings' => &$settings, 'errors' => &$this->_errors));
61:                 
62:                 if (!is_array($this->_errors) || empty($this->_errors)) {
63:
64:                     foreach($settings as $set => $values) {
65:                         foreach($values as $key => $val) {
66:                             Symphony::Configuration()->set($key, $val, $set);
67:                         }
68:                     }
69: 

Backtrace

[/www/htdocs/webseiten/hananils/symphony/content/content.systempreferences.php:65] GenericErrorHandler::handler(); [/www/htdocs/webseiten/hananils/symphony/lib/toolkit/class.administrationpage.php:70] contentSystemPreferences->action(); [/www/htdocs/webseiten/hananils/symphony/lib/core/class.administration.php:88] AdministrationPage->build(); [/www/htdocs/webseiten/hananils/symphony/lib/core/class.administration.php:204] Administration->__buildPage(); [/www/htdocs/webseiten/hananils/index.php:20] Administration->display();

Nils, I might be totally off topic here, so excuse me in advance.

I had a similar problem when I was trying to make your extension - the Localisation Manager - compatible with the 2.0.7 release. The answer lies in supplying HTML form inputs with a legal value for the name attribute. For example, in extension.driver.php at line 219 there was:

$select = Widget::Select('settings[language]', $options);

By the way, when trying to save the new settings I received the same exact error that you reported above. I’ve found a working solution by replacing the old line with:

$select = Widget::Select('settings[symphony][lang]', $options);

This way, the expected requirements for the settings array (i.e. to be bidimensional) are met and foreachs don’t throw any runtime error. Plus, language settings are correctly saved inside the config.php file under the symphony section.

Again, sorry if that was not your case…

Thanks, that’s exactly the case. I’ve a working version of the Localisation Manager locally but I still have to adjust it to accept subfolders in the lang directory. And I still think that anything besides the translation file generation should be integrated into the core.

Hopefully this commit has fixed the problem. It will prevent that Foreach loop from running if the $settings variable is empty or not an array.

This issue is closed.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details