-- Guillaume Oriol <gor...@technema.fr> wrote
(on Monday, 20 April 2009, 09:13 AM -0700):
> Hi, I discovered an issue with the javascriptCaptureStart/javascriptCaptureEnd
> function pair. When the captured text exceeds a certain limit (about 50kB in 
> my
> case), the function returns only a semi-colon. I have the following code in a
> view script:
> 
> <?php $this->dojo()->javascriptCaptureStart(); ?>
> var data = <?php echo $this->data; ?>;
> ...
> <?php $this->dojo()->javascriptCaptureEnd(); ?>
> 
> And, as the number of rows in my database table is growing, $this->data is
> getting bigger and bigger. Finally, over ~50KB, the PHP tag returns a
> semi-colon and nothing else (not even the "var data =" preceeding that tag).
> I was able to trace this issue back to the function addJavascript($js) in
> Zend_Dojo_View_Helper_Dojo_Container and more precisely to the preg_replace
> function:
> 
>         $js = preg_replace('/^\s*(.*?)\s*$/s', '$1', $js);
> 
> I replaced it by:
> 
>         $js = trim($js);
> 
> and everything was fine. Therefore, I have two questions:
> - is there a know limitation on preg_replace()
> - why did you use a preg_replace function to trim the string ?

I'm not aware of any limitations on preg_replace(), but you might want
to either file a bug with php.net or ask on the php-internals mailing
list about it -- that seems like odd behavior.

We chose to use preg_replace over trim() as it allows removing more than
one whitespace character from front and back, and will include newlines
when doing so.

-- 
Matthew Weier O'Phinney
Project Lead            | matt...@zend.com
Zend Framework          | http://framework.zend.com/

Reply via email to