View Issue Details

IDProjectCategoryView StatusLast Update
0006324OXID eShop (all versions)4.07. Source code, Testpublic2024-03-06 11:16
ReporterAlexN Assigned To 
PrioritylowSeveritytrivialReproducibilityalways
Status confirmedResolutionopen 
Product Version4.9.3 / 5.2.3 
Summary0006324: Inconsistence comment / method body
DescriptionIn 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);
        }
    }

--------------------------------------------------------------
TagsNo tags attached.
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined

Activities

AlexN

2016-02-05 16:14

reporter   ~0011451

EDIT: According to the method comment it returns null or true on success*

QA

2016-02-05 16:42

administrator   ~0011453

Last edited: 2016-02-05 16:45

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.

AlexN

2016-02-05 18:05

reporter   ~0011454

@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 :)

SvenBrunk

2024-03-06 11:16

administrator   ~0016357

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.