I've been following this a little. 

If I understand this right...

The json decode works if you dump the var but not if you allow the page to
run through the view.

What happens in the view?

You mention these :

-- sets HTML head
-- spits out contents

Does the view do anything to the data? i.e. expect a exact array key to
exist?

Just some thoughts
Terre

* Resent to list (pesky reply button)

-----Original Message-----
From: Jake McGraw [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 15, 2008 12:13 PM
To: fw-general@lists.zend.com
Subject: Re: [fw-general] Zend_Json::decode in Controller causing Blank
Screen of Death

> Comment out the above line and see what happens -- this is what the 
> previous comment was getting at.
>

Still not working, commented out line, restarted apache, same issue...
I'm not sure that this is related to json/xdebug, as
Zend_Json::decode/json_decode both operate correctly with the same JSON
string outside of the Zend MVC, it is only when I use any of the
following:

Zend_Json::decode($jsonString);

Zend_Json::$useBuiltinEncoderDecoder = TRUE Zend_Json::decode($jsonString);

json_decode($jsonString, TRUE);

and then allow Layout, View to render that I get the blank screen.
Note, I'm not actually doing anything with the resulting PHP array from the
decoding. I'm not passing it to the view, which simply sets the HTML head
and spits out the content. I'm just attempting to dump it.

Again, thanks for the help!

- jake

>
>> Again, nothing in error reporting, logging, etc. Just a blank screen.
>> Also, this works fine (same JSON) outside of Zend_Controller_Action.
>>
>> > -Matt
>> >
>> > On Fri, Aug 15, 2008 at 8:20 AM, Jake McGraw <[EMAIL PROTECTED]>
wrote:
>> >>
>> >> I've spent the last two days struggling with this error:
>> >>
>> >> We've been utilizing REST-ful JSON server for a couple of months now
to host our data api (it's written using Zend Framework). Our client apps
access this API, and decode the JSON. Yesterday, one of our client apps
stopped working, generating no errors, no ouput, just a blank screen. After
commenting out the majority of the code, we found the following code was
causing the grief:
>> >>
>> >> <?php
>> >>
>> >> // BaseController extends Zend_Controller_Action class 
>> >> CustomController extends BaseController {
>> >>
>> >>   public function someAction() {
>> >>
>> >>     $result = $this->api->get('resource', array('field1' => 
>> >> 'value1'));
>> >>
>> >>     $result = 
>> >> Zend_Json::decode($result->getResponse()->getBody());
>> >>
>> >>     var_dump($result);
>> >>
>> >>     // exit;
>> >>   }
>> >>
>> >> }
>> >>
>> >> Now, we only get the blank screen when we allow our dispatcher to
render our Zend_Layout, Zend_View AFTER using Zend_Json::decode, all the
following logic steps work fine:
>> >>
>> >> - Uncomment exit, prevent Layout, View rendering 
>> >> var_dump($result); exit;
>> >>
>> >> - Check body for valid JSON (everything OK in JSON Lint)
>> >> - Layout, View render correctly
>> >> var_dump($result->getResponse()->getBody());
>> >>
>> >> - Try another JSON string
>> >> - Layout, View render correctly
>> >> var_dump(Zend_Json::decode('[{"foo":"bar"}]'));
>> >>
>> >> The JSON looks something like this:
>> >>
>> >> [
>> >>     {
>> >>         "cm_broadcast_type": "National Broadcast Networks",
>> >>         "id": "12659575",
>> >>         "station_id": "12336",
>> >>         "program_id": "EP010501290006",
>> >>         "start_time": "20080814000000",
>> >>         "end_time": "20080814010000",
>> >>         "cc": "Y",
>> >>         "title": "Greatest American Dog"
>> >>     },
>> >>     {
>> >>         "cm_broadcast_type": "National Broadcast Networks",
>> >>         "id": "11469048",
>> >>         "station_id": "12336",
>> >>         "program_id": "EP007537910036",
>> >>         "start_time": "20080814010000",
>> >>         "end_time": "20080814020000",
>> >>         "cc": "Y",
>> >>         "title": "Criminal Minds"
>> >>     },
>> >>     ... Continue ...
>> >> ]
>> >>
>> >> So, as I've said, the problem only occurs when we allow the dispatcher
to continue rendering Layout, View after using Zend_Json::decode, any help
would be MUCH appreciated.
>> >>
>> >> - jake
>>
>
> --
> Matthew Weier O'Phinney
> Software Architect       | [EMAIL PROTECTED]
> Zend Framework           | http://framework.zend.com/
>

Reply via email to