View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006324 | OXID eShop (all versions) | 4.07. Source code, Test | public | 2016-02-05 16:13 | 2024-03-06 11:16 |
Reporter | AlexN | Assigned To | |||
Priority | low | Severity | trivial | Reproducibility | always |
Status | confirmed | Resolution | open | ||
Product Version | 4.9.3 / 5.2.3 | ||||
Summary | 0006324: Inconsistence comment / method body | ||||
Description | In oxbase.php a method "assign" exists. According to the method comment it returns null but when looking into the method body in no case null (afaik return; just exits the method) or true is returned. According to the API http://docu.oxid-esales.com/CE/sourcecodedocumentation/4.9.7/classox_base.html#a1231cc033a41f8a9466955e93912cd37 it has not been fixed in EE v5.2.7. -------------------------------------------------------------- /** * Assigns DB field values to object fields. Returns true on success. * * @param array $dbRecord Associative data values array * * @return null */ public function assign($dbRecord) { if (!is_array($dbRecord)) { return; } if (!$this->canRead()) { return false; } reset($dbRecord); while (list($sName, $sValue) = each($dbRecord)) { // patch for IIS //TODO: test it on IIS do we still need it //if( is_array($value) && count( $value) == 1) // $value = current( $value); $this->_setFieldData($sName, $sValue); } $sOxidField = $this->_getFieldLongName('oxid'); $this->_sOXID = $this->$sOxidField->value; $sShopVarName = $this->_getFieldLongName('oxshopid'); if (isset($this->$sShopVarName) && isset($this->$sShopVarName->value)) { $this->setShopId($this->$sShopVarName->value); } } -------------------------------------------------------------- | ||||
Tags | No tags attached. | ||||
Theme | Not defined | ||||
Browser | Not defined | ||||
PHP Version | Not defined | ||||
Database Version | Not defined | ||||
|
EDIT: According to the method comment it returns null or true on success* |
|
The code snippet in the description is not from a shop version 4.9.3. In a 4.9.3 the code looks like: https://github.com/OXID-eSales/oxideshop_ce/blob/v4.9.3/source/core/oxbase.php#L463 (It is the same on 4.9.7). There is only a single return with no parameters. This will return null. (See http://php.net/manual/en/function.return.php) In other cases there is no return. This also will return null. (See http://php.net/manual/en/functions.returning-values.php) So nothing wrong until here. But: As you correctly noted, the comment says "Returns true on success.". So this could be incorrect. |
|
@Code snippet: > Weird it's not the same as I copy pasted it from a EE 5.2.3 instance. @Return & null: > I see, thanks for the link :) |
|
This is now https://github.com/OXID-eSales/oxideshop_ce/blob/2f8dda9995b328b0d265de05ca40797bb37f7073/source/Core/Model/BaseModel.php#L472 but it still states that it returns true. |