[TYPO3-commerce] RFC: #7862: bug: Class constructor of tx_commerce_attribute_value causes PHP Warning

Sascha Egerer seg at softvision.de
Fri May 21 13:52:56 CEST 2010


Hi Ingo,

i think this is an PHP/TYPO3 related problem.
In earlier versions of commerce sometimes objects are created with a 
"new className" call. In this case you have to give the constructor the 
id of the attribute value like "new className($id)".

But in TYPO3 objects should always be created by the "makeInstance" 
function, because of xClassing and so on.

makeInstance creates the object for you and than call's the "init" 
function of the object to initialize the object. So this is the same 
like PHP does with the constructor. You create an object and the 
constrcutor is called by php.

The problem is that the constructor is called everytime a object is 
created. So it will also be called if "makeInstance" creates the object 
for you. But there is no way to tell makeInstance that it sould add some 
parameter to the object initialisation.

And there isn't, luckily, no "new className" call in commerce anymore.

So objects of this class are everytime created by makeInstance wich ends 
in an PHP Warning.
PHP Warning: Missing argument 1 for 
tx_commerce_attribute_value::tx_commerce_attribute_value(), called in 
/typo3_src/typo3_src-4.2.12/t3lib/class.t3lib_div.php on line 4678 and 
/typo3conf/ext/commerce/lib/class.tx_commerce_attribute_value.php on line 88


Maybe our core guy christian kuhn can have a look at this.



Am 21.05.10 13:06, schrieb Ingo Schmitt:
> Hi Sascha,
>
> if the constructor is not needed, no warnings should be given. Thus I assume, the constructor is needed.
>
> Please do not remove Methods, instead please add a @deprecated to the documentation.
>
> So -1 from me.
>
> ingo
>
>> This is an SVN patch request.
>>
>> Type: Bug
>>
>> Bugtracker references:
>> http://forge.typo3.org/issues/show/7862
>>
>> Branches:
>> trunk
>>
>> Problem:
>> The Constructor in the class.tx_commerce_attribute_value class causes a php warning because of missing arguments. It expects the attribute value uid as first parameter but the TYPO3 api call "makeInstance" does not give any parameter to a new class.
>>
>> Solution:
>> Remove the constructor because we don't need it.
>>
>> Notes:
>> I think we can remove the Constructor because everything is dome by "makeInstance" and the "init" function of the class. The constructor also only calls the init function of the class.
>>
>>
>> Regards
>> Sascha Egerer
>> <7862.patch>_______________________________________________
>> TYPO3-team-commerce mailing list
>> TYPO3-team-commerce at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-team-commerce
>
>
> Mit freundlichen Gruessen
> Ingo Schmitt
>



More information about the TYPO3-team-commerce mailing list