Terre:

Thanks for the effort, but I have also been able to set up a basic
Controller / Layout / View and get my code to work. There still
appears to be some kind of intractable issue going on here that has to
do with json_decode and Zend MVC will my existing code base. I'm going
to try to refactor my code, and get this working. I'll report back my
findings.

- jake

On Fri, Aug 15, 2008 at 2:37 PM, Terre Porter
<[EMAIL PROTECTED]> wrote:
>
> I put together a basic test project.
>
> Used the layout and the view tpl you provided.
>
> I've got this as my controller function.
>
> public function indexAction()
> {
>        $jsonData = '--string from text file--';
>        $result = json_decode($jsonData);
>        var_dump($result);
> }
>
> I get a "hello world" and a var dump of the json data.
>
> What needs to happen to the $results data for it to be used on the
> layout/view?
>
> Terre
>
> -----Original Message-----
> From: Jake McGraw [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 15, 2008 1:07 PM
> To: Terre Porter; fw-general
> Subject: Re: [fw-general] Zend_Json::decode in Controller causing Blank
> Screen of Death
>
> On Fri, Aug 15, 2008 at 12:31 PM, Terre Porter
> <[EMAIL PROTECTED]> wrote:
>>
>> 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
>
> My Layout:
>
> <?php
>
>        // <meta>
>        $this->headMeta()
>                ->appendHttpEquiv('Content-Type', 'text/html;
> charset=UTF-8')
>                ->appendHttpEquiv('Content-Language', 'en-US');
>
>        $this->headTitle()
>                ->headTitle('My Page', 'APPEND');
>
>        echo $this->doctype('XHTML1_STRICT');
> ?>
>
> <html xmlns="http://www.w3.org/1999/xhtml";>
>        <head>
>                <?= $this->headMeta() ?>
>
>                <?= $this->headTitle() ?>
>
>        </head>
>        <body>
>                <?= $this->layout()->content ?>
>
>        </body>
> </html>
>
> My View:
> <h1>HELLO WORLD</h1>
>
> In the course of debugging this, I've tried to take out all of the possible
> bugs, I've narrowed it down to one thing: attempting to json_decode a
> perfectly valid JSON string, which I've attached, prior to preDispatch(),
> View, Layout rendering causes blank screen.
>
> - jake
>
>>
>> Does the view do anything to the data? i.e. expect a exact array key
>> to exist?
>>
>> Just some thoughts
>> Terre
>>
>>
>> -----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