[TYPO3-core] RFC #10454: t3lib_div::makeInstanceClassName() allows to bypass checks for t3lib_Singleton

Jeff Segars jsegars at alumni.rice.edu
Tue Feb 17 23:47:28 CET 2009


Ingo Renner wrote:
> Jeff Segars wrote:
> 
> Hi Jeff,
> 
>> Here's my +1 on reading and testing, with one item that may be open to 
>> some discussion.
>>
>> The call to newInstanceArgs() throws a fatal error if a developer 
>> passes arguments to a class without a constructor. On the one hand, 
>> this the developer's fault but at the the same time "new myclass(arg1, 
>> arg2)" doesn't throw a fatal error when there's no constructor.
> 
> hmm, not sure what to do about that one... any ideas welcome.

This is my first time into the Reflection classes, so there may be 
better ways to do it but it looks like getConstructor() fits the bill 
nicely.

Attaching an updated patch that works fine in my testing.

>>> Fatal error: Uncaught exception 'ReflectionException' with message 
>>> 'Class language does not have a constructor, so you cannot pass any 
>>> constructor arguments'
> 
> well to me this particular exception is pretty clear: language actually 
> doesn't have a constructor - at least not an explicit one...
> 
> If the message solely resulted from that, than I think it's ok. Could 
> you test it with a different class again, a class that has a 
> constructor, but doesn't expect arguments...

I agree the message is clear; my only (very small) problem is that it 
differs from happens with the when I create an object directly with 
"new" and do not get a fatal error.

After some more testing, the fatal error only occurs when there's not a 
constructor at all.  If there is a constructor with no arguments but 
arguments are unexpectedly passed to the constructor, it works fine.

Thanks!
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makeInstanceWithArgs_v2.diff
Type: application/pgp-keys
Size: 2505 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20090217/6f750f8e/attachment-0001.key 


More information about the TYPO3-team-core mailing list