View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003189 | OXID eShop (all versions) | 4.07. Source code, Test | public | 2011-08-26 09:25 | 2012-12-10 13:44 |
Reporter | csimon | Assigned To | |||
Priority | high | Severity | major | Reproducibility | always |
Status | resolved | Resolution | won't fix | ||
Product Version | 4.5.1 revision 38045 | ||||
Summary | 0003189: __get and __set are not called for every database field | ||||
Description | __get and __set are not called always for every database field. This is because, if __set is called once, the shop writes the resulting field directly onto the object, which causes that __get is never called if __set was used to set the value. This makes it hard to only write output filters für database values, without manipulating the object itself. The solution could be to change oxbase.php line 1185: $this->$sLongName = $oField; to something like this: $this->_aFields[$sLongName] = $oField; aFields contains every database field of the object as array element, __set should make use of this array and __get should use it too, so that __get is always called and overwritable. This is a little performance draining, a much cleaner, faster and long time solution would be to implement every database value as an function call. | ||||
Tags | No tags attached. | ||||
Theme | Both | ||||
Browser | All | ||||
PHP Version | any | ||||
Database Version | any | ||||
|
@Developers: please check from source code side if that's the case and offered solution would solves the problem correctly. |
|
Reminder sent to: csimon it is not clear the problem. Can you deeply explain the use case: what you are trying to do and what's go wrong. |
|
Hi, For example: You want to filter the short description (without manipulating every template). Normally, you could hook with a module into oxArticle::__get(), check if $sName is oxshortdesc, filter the data and return the oxField object with the filtered value in this function. But, because __set and the called method oxBase::_addField are adding the property directly onto $this, php never calls __get again when you are trying to read the property, because __get is only called on properties which are nonexistent. To make it possible to filter or manipulate the output, it must be avoided to write data directly on the object. |
|
with "data" i mean properties, of course. |
|
"if __set is called once, the shop writes the resulting field directly onto the object, which causes that __get is never called if __set was used to set the value". This is how PHP magic setters and getters are supposed to work. It's not a bug. What you probably need is separate field value getters and setters, which is actually a good idea to be implemented. I'll take care that this request is included to feature request list with higher priority than normal. |
|
will be added as feature: field value getters and setters |