Another Symphony on PHP 5.0.1 bug

March 2, 2008 – 1:17 pm

Found another interesting bug today when I deployed a symphony app on the “older” php version 5.0.1.

The bug itself has solely to do with php, and it’s already documented here and fixed in the current version, but basically what happened, is that I assigned a couple of methods to objects via the sfMixer class, and in one environment it worked, and in the other it didn’t (”call to undefined method xyz…” error ). Weird!

Turns out, the ReflectionClass::getMethod() method that Symfony uses as part of the sfMixer class, turns every string you pass into into lowercase.. BY REFERENCE!! So assigning a mixer method “getChildren” would actually be saved under “getchildren”, and wouldn’t be found in subsequent calls. What’s more, assigning the string to a “backup” variable to conserve it’s capitalization doesn’t help either, because then somehow both variables are affected. ( I didn’t know that string variable are passed by reference as well???)

Thanks to my smart boss we found a workaround, which is appending something to the copy of the string, and removing it later when you reassign it to the original variable.. I suggest the appendix “save_this_f%$#@#$_variable”. Worked for me! ;)

Filed under: Symfony — by Richtermeister

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress