Question

I am using CakePhp to build an application that interfaces with the Linkedin API. I have a simple page that is given a linkedin members ID in a GET variable and Application Authentication token in a session variable. The page controller should do a cURL call to the API & set a $connection variable, finish the controller code, then display the *.CTP.

However, what is happening. Is the controller executes one time without problems, then executes the *.CTP file without problems. Then executes the controller AGAIN this time not successfully pulling data from the linkedin API and then executes the *.CTP file AGAIN creating all kinds of error "notices" in the Debug Log. The strange thing is, even though the debug log shows CAKE isn't able to set the $connection variable the data based on that variable is shown correctly when the page is rendered.

I have used a Debugger::Log('xxx') flag to indicate when the start and end of the controller and *.CTP are executed. Here is the debug log for ONE refresh on the page

2011-11-20 04:16:23 Debug: "START controller function"
2011-11-20 04:16:24 Debug: "End controller function"
2011-11-20 04:16:24 Debug: "START the .ctp"
2011-11-20 04:16:24 Debug: "END the .ctp"
2011-11-20 04:16:25 Debug: "START controller function"
2011-11-20 04:16:26 Debug: Notice (8): Undefined variable: connection in [C:\wamp\www\ta\app\controllers\reviews_controller.php, line 100]
2011-11-20 04:16:26 Debug: "End controller function"
2011-11-20 04:16:26 Debug: "START the .ctp"
2011-11-20 04:16:26 Debug: Notice (8): Trying to get property of non-object in [C:\wamp\www\ta\app\views\reviews\write_review.ctp, line 7]
2011-11-20 04:16:26 Debug: Notice (8): Trying to get property of non-object in [C:\wamp\www\ta\app\views\reviews\write_review.ctp, line 36]
2011-11-20 04:16:26 Debug: Notice (8): Trying to get property of non-object in [C:\wamp\www\ta\app\views\reviews\write_review.ctp, line 41]
2011-11-20 04:16:26 Debug: Notice (8): Trying to get property of non-object in [C:\wamp\www\ta\app\views\reviews\write_review.ctp, line 43]
2011-11-20 04:16:26 Debug: "END the .ctp"

The page actually renders fine. I'm just trying to understand why CAKE would run the *.CTP file twice (it has no redirects) and create all the error notices in the debug file. I thought Cake runs the controller function and only if the controller reaches the end run the *.CTP file once? Anyone know what could be happening?

Thanks!

No correct solution

OTHER TIPS

This problem can be caused by something that causes a standard error handling in CakePHP, in this case, it first calls your function, and then display an error message.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top