Hello,
Yes PHP will process the whole instruction, because it needs to gather
all information before making the method call.
You need to split this yourself if you have expensive calculations in
the second argument.
if ( $action->getUser()->getProviderId() !=
$action->reservProvider->getProviderId() ){
$action->forward404(self::genLogMessage($action, ': consumer id does
not match: actual: '.$action->getUser()->getConsumerId().' expected:
'.$action->reservation->getConsumerId()));
}
The same applies for performance critical logger instructions which
are usually wrapped in some kind of if($debug){ }
Note that this only really matters on highly frequented code, because
usually your logmessage construction is cheap.
Fabian
On Wed, Jun 24, 2009 at 6:22 AM, Steve Sanyal<[email protected]> wrote:
>
> Hi,
>
> I have a bunch of calls that use conditional forward404s, such as:
>
> $action->forward404Unless($action->getUser()->getProviderId()
> == $action->reservProvider->getProviderId(), self::genLogMessage
> ($action, ': consumer id does not match: actual: '.$action->getUser()-
>>getConsumerId().' expected: '.$action->reservation->getConsumerId
> ()));
>
> There is a message logged in each case. The thing is, the message
> really only needs to be generated if the 404 action is to be executed.
>
> Does anyone know if PHP will process the complete forward404
> {condition} line if the terms of the condition are not met?
>
> ie: in the case above, if the user's providerId == the
> reservProvider's providerId, will the log message portion of the call
> be evaluated?
>
> If so, I'd think it would be better in all cases to avoid using
> conditional forward404's and instead have a separate if block to
> process the condition.
>
> Thanks,
> Steve
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---