Development

#194 (sfDefineEnvironmentConfigHandler doesn't properly preserve arrays)

You must first sign up to be able to contribute.

Ticket #194 (closed defect: fixed)

Opened 7 years ago

Last modified 7 years ago

sfDefineEnvironmentConfigHandler doesn't properly preserve arrays

Reported by: anonymous Assigned to:
Priority: minor Milestone: 0.6.2
Component: Version: 0.7.X
Keywords: Cc:
Qualification:

Description

As the summary says, sfDefineEnvironmentConfigHandler doesn't properly preserve arrays. Specifically, fixCategoryValue blindly calls replaceConstants, and if an array is passed to replaceConstants, the preg_replace it performs transforms the array into the literal text string 'Array', dropping the contents of the array on the floor in the process. The attached patch against the tagged RELEASE_0_6_0 should address this issue (at least it seems to work for me):

Index: lib/config/sfDefineEnvironmentConfigHandler.class.php
===================================================================
--- lib/config/sfDefineEnvironmentConfigHandler.class.php       (revision 794)
+++ lib/config/sfDefineEnvironmentConfigHandler.class.php       (working copy)
@@ -92,7 +92,25 @@
     $key = strtolower($category.$key);

     // replace constant values
-    $value = $this->replaceConstants($value);
+    if (is_array($value))
+    {
+      foreach ($value as $temp_key => $temp_item)
+      {
+        if (is_array($temp_item))
+        {
+          list($return_key, $return_value) = $this->fixCategoryValue($category, $key, $temp_item);
+          $value[$temp_key] = $return_value;
+        }
+        else
+        {
+          $value[$temp_key] = $this->replaceConstants($temp_item);
+        }
+      }
+    }
+    else
+    {
+      $value = $this->replaceConstants($value);
+    }

     return array($key, $value);
   }

Change History

02/10/06 08:21:51 changed by subzero2000

Sorry, I hadn't meant to submit that anonymously.

02/10/06 14:50:28 changed by RoVeRT <symfony@rovert.net>

  • status changed from new to closed.
  • resolution set to fixed.

inline recursion supported added in r804

04/20/06 22:08:37 changed by subzero2000

  • priority changed from major to minor.
  • status changed from closed to reopened.
  • resolution deleted.
  • milestone changed from 0.6.1 to 0.6.3.

Re-opening ticket. The fix for this seems to have been lost somewhere along the way. The issue seems to have been address in branches/rovert/lib/config/sfDefineEnvironmentConfigHandler.class.php in r804, but I can find no evidence that this was ever merged with the trunk, as the current release 0.6.2 still has the same code. Note, I have not tested had an opportunity to test 0.6.2, just simply noticed that 0.6.2 does not appear to contain the change made by RoVeRT in r804. I am trying to minimize the amount of local modifications I have to make to given release of Symfony, and this is one I find that I continually have to make. Note, also, that this isn't a complaint, as I assume it is a simple oversight or some other really good reason for this, and as usual, the symfony project continues to be my favorite framework to work in, bar none. Keep up the good work.

04/20/06 22:19:46 changed by subzero2000

  • status changed from reopened to closed.
  • resolution set to fixed.
  • milestone changed from 0.6.3 to 0.6.2.

Never mind. Boy, do I feel stupid. I see where the method replaceConstants in sfConfigHandler.class.php checks to see if it is dealing with an array or not and makes choices appropriately. That is a much cleaner way to implement what I was describing than my patch did, and generally feels like the right way to do things. Since this was done in r1160, 0.6.2 would be the first release to actually fix this bug. Yay! Gives me reason to want to deploy it already! Also, it should be noted that r1160 also properly closes this bug (#194), as my issue was the same, but my proposed fix wasn't as good as the one ultimately used. Again, keep up the good work guys, and thanks for such a top notch framework.