Categories > TinyButStrong general >

Indirect Modification of Overloaded Property

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Sarah
Date: 2016-05-25
Time: 22:01

Indirect Modification of Overloaded Property

I'm trying to use OpenTBS within Laravel, which relies on magic __get methods to return object attributes.I prefer not to change my __get to &__get because then you lose any illusion of the object protecting its properties.

__get works fine for me until line 2808 of tbs_class.php:

$data = &$Src->CurrRec->$col;

which throws an "indirect modification of overloaded property has no effect" error. Removing the ampersand from this line, or prefacing it with the error suppressor @ both solve my problem, but I wonder if the & is really needed?

Thanks for reading.
By: Skrol29
Date: 2016-05-26
Time: 00:56

Re: Indirect Modification of Overloaded Property

Hi,

> but I wonder if the & is really needed?

This is for optimization: some parameters like "ondata" and some plug-in may change the data during the merging.
I explain : let's say « $Src->CurrRec->$col » is an array,
then if you have « $data = $Src->CurrRec->$col; », then PHP will duplicate the array in memory if you attempt to modify $data. This is because $data and $Src->CurrRec->$col becomes two different arrays.
Now if you have « $data = &$Src->CurrRec->$col; », then PHP will not duplicate he array if you attempt to modify $data.
This can save memory if the data is a big array.

Since it is only for optimization, you can change the code and omit the « & ».

I will have a look for the next TBS version to see if we can fix this problem.