Search

I’m trying to save a nested array in the config.php file as part of my extension. I am having no luck and I have tried serialising the data with both serialize() and json_encode() but I think the core is adding slashes to the data so they will not de-serialize correctly.

Line 68 of class.configuration.php: -

$string .= "rnttt'$key' => ".(strlen($value) > 0 ? "'".addslashes($value)."'" : 'NULL').",";

I have tried all kinds of fixes by strip-slashing the data on the way back out etc, but with regex patterns that have slashes in them it is a bit of a nightmare!!

I may be missing a function that can save a nested array in the config for me, but when I tried the setArray() method with the config object, the nested array just saved as the word “Array”.

Any help appreciated.

I tried saving serialized arrays in the configuration file in my first tries for an extension as well. It felt like abusing config.php and I ended up using the database. So maybe that’s the way to go…

I have tried all kinds of fixes by strip-slashing the data on the way back out etc, but with regex patterns that have slashes in them it is a bit of a nightmare!!

This is a pain, I agree, however the problem is the config.php file must be valid PHP otherwise Symphony will crash. The alternative is to use some other plain text format.

I tried saving serialized arrays in the configuration file in my first tries for an extension as well.

What about base64_encode(serialize($myArray))? No slashes would get added. It’s just not human readable in any way.

Alistair - thanks for the suggestions but I have gone the route of using the DB to store the data, it’s simply easier.

Also, pulling the route data is a single “SELECT * FROM…” which is not going to add much overhead to each page render which was one of my original concerns.

Create an account or sign in to comment.

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