ZF-11068: ErrorController created by zf.sh tries to call getParams() on non-object

Description

When using Zend_Tool to create a project running: bq. zf create project generates an ErrorController with one line trying to call getParams() on non-object.

Line 35 when finding a log instance it tries: bq. $request->getParams() but the request variable is not set.

What I think it means is: bq. $errors->request->getParams() which works as expected.

Found the line in: bq. http://framework.zend.com/svn/framework/… on line 162: bq. \$log->log('Request Parameters', \$priority, \$request->getParams());

Comments

Checked the source for Zend_Log and noticed that I was wrong in thinking that $errors->request->getParams() would solve the problem. I guess everyone else knows this but doing that will just log them into the $event array with the parameter key as index. So instead of getting it into the info index in the event array it will go into controller and action, which will not work that great trying to log the info.

That would result in when trying to format a log message with: bq. %timestamp% %priorityName% (%priority%): %message% -- %info% would need to be: bq. %timestamp% [%priorityName%] (%priority%): %message% -- %controller% / %action% plus any other information that might be logged, and that's not good.

As I said earlier I guess the person working on this already figured this out but just in case. :)

@Magnus, your comment is related to another issue (ZF-10427).

@Benoît isn't it related more to this issue since the adding of the %info% string will not solve the problem I was talking about. Sure the adding of the %info% string is more related to the other issue but that was not the point of my comment. The point was that even if the issue reported here is fixed with the solution I suggested it will not be using the logging correctly. It will be passing an array with string keys into the log and the log will insert the values into those keys instead of the info key. So even if the log string is changed to: bq. %timestamp% %priorityName% (%priority%): %message% - %info% this issue with the ErrorController will still be using it "incorrectly"?

Until this is fixed I am using the line: bq. $log->log('Request Parameters', $priority, print_r($errors->request->getParams(), true)); and then the request parameters are logged using %info%.

Sorry if I am not understanding the connection between my comment and the other issue and if that is the case I will comment that issue instead. :/

It's not the good issue to talk about it, because it's a design problem between the simple formatter and extra info event. %info% is mixed type. So, it's can be an array. We don't have this problem with the others writers like db, Firebug, xml stream, or ZendMonitor. I think that the issue for the extra info can be resolved in ZF2.

Fix in r23708