[dev] [Tickets #10880] Rdo drops objects from result when eager relation target is NULL or invalid key

Ralf Lang lang at b1-systems.de
Wed Feb 22 07:38:31 UTC 2012


Am 21.02.2012 13:59, schrieb Chuck Hagenbuch:
> On Feb 21, 2012, at 3:12 AM, Ralf Lang<lang at b1-systems.de>  wrote:
>
>>>
>>> I'm hesitant to make this an exception, though. I see your use case, but
>>> for non-nested use, it means that I have to put a try/catch around
>>> property testing when I could otherwise just use if checks (duck typing,
>>> etc)...
>>>
>>> -chuck
>>
>> You can check the relation key for a non-null value. But I see the issue too.
>>
>> Another approach would be a "null" response object that only throws an exception if the user tries to access attributes or methods of the response. Both the Rdo_Base object and the "null" object would need to implement a simple true-false-interface which could be checked similarly to your former if ($object) {}. At least in my use cases, porting would be easy.
>
> That seems hackish and error prone, IMO...
>

Can't disagree, it's uglier than it should be.

It's working around PHP's inconsistent use of fatals vs exceptions. I've 
raised this on the PHP-dev list, with mixed results. Most responses were 
programming patterns, the NoValue object in several incarnations. One "I 
don't like it but write an RFC" and a few "any fatal which becomes an 
exception is a step forward". I'll probably write that RFC and see how 
the php devs feel about it.

I withdraw the exception idea now. But I'll try to fix the original 
$subject asap.

-- 
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang at b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


More information about the dev mailing list