Skip to content

Commit

Permalink
Merge branch 'pr646' into b-6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieg committed May 10, 2018
2 parents 376d733 + bac4d9c commit 43201c3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
via `widget.php` it must extend `\OxidEsales\Eshop\Application\Component\Widget\WidgetController`.
- `SeoEncoderArticle::_prepareArticleTitle` now uses `_getUrlExtension()` method in place of hardcoded `.html` extension [PR-634](https://github.com/OXID-eSales/oxideshop_ce/pull/634).
- Add ^ to version constraint on doctrine/dbal [PR-635](https://github.com/OXID-eSales/oxideshop_ce/pull/635)
- Model performance micro optimizations [PR-646](https://github.com/OXID-eSales/oxideshop_ce/pull/646)

### Deprecated
- Recommendations feature will be moved to separate module:
Expand Down
18 changes: 10 additions & 8 deletions source/Application/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -976,22 +976,24 @@ protected function _update()
/**
* Sets data field value
*
* @param string $sFieldName index OR name (eg. 'oxarticles__oxtitle') of a data field to set
* @param string $sValue value of data field
* @param int $iDataType field type
* @param string $fieldName index OR name (eg. 'oxarticles__oxtitle') of a data field to set
* @param string $value value of data field
* @param int $dataType field type
*
* @return null
*/
protected function _setFieldData($sFieldName, $sValue, $iDataType = \OxidEsales\Eshop\Core\Field::T_TEXT)
protected function _setFieldData($fieldName, $value, $dataType = \OxidEsales\Eshop\Core\Field::T_TEXT)
{
//preliminary quick check saves 3% of execution time in category lists by avoiding redundant strtolower() call
if ($sFieldName[2] == 'l' || $sFieldName[2] == 'L' || (isset($sFieldName[16]) && ($sFieldName[16] == 'l' || $sFieldName[16] == 'L'))) {
if ('oxlongdesc' === strtolower($sFieldName) || 'oxcategories__oxlongdesc' === strtolower($sFieldName)) {
$iDataType = \OxidEsales\Eshop\Core\Field::T_RAW;
$fieldNameIndex2 = $fieldName[2];
if ($fieldNameIndex2 === 'l' || $fieldNameIndex2 === 'L' || (isset($fieldName[16]) && ($fieldName[16] == 'l' || $fieldName[16] == 'L'))) {
$loweredFieldName = strtolower($fieldName);
if ('oxlongdesc' === $loweredFieldName || 'oxcategories__oxlongdesc' === $loweredFieldName) {
$dataType = \OxidEsales\Eshop\Core\Field::T_RAW;
}
}

return parent::_setFieldData($sFieldName, $sValue, $iDataType);
return parent::_setFieldData($fieldName, $value, $dataType);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion source/Application/Model/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ public function getStdLink($iLang = null, $aParams = [])
*/
protected function _setFieldData($sFieldName, $sValue, $iDataType = \OxidEsales\Eshop\Core\Field::T_TEXT)
{
if ('oxcontent' === strtolower($sFieldName) || 'oxcontents__oxcontent' === strtolower($sFieldName)) {
$sLoweredFieldName = strtolower($sFieldName);
if ('oxcontent' === $sLoweredFieldName || 'oxcontents__oxcontent' === $sLoweredFieldName) {
$iDataType = \OxidEsales\Eshop\Core\Field::T_RAW;
}

Expand Down
14 changes: 9 additions & 5 deletions source/Core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1068,13 +1068,17 @@ public function getShopCurrency()
*/
public function getActShopCurrencyObject()
{
$cur = $this->getShopCurrency();
$currencies = $this->getCurrencyArray();
if (!isset($currencies[$cur])) {
return $this->_oActCurrencyObject = reset($currencies); // reset() returns the first element
if ($this->_oActCurrencyObject === null) {
$cur = $this->getShopCurrency();
$currencies = $this->getCurrencyArray();
if (!isset($currencies[$cur])) {
$this->_oActCurrencyObject = reset($currencies); // reset() returns the first element
} else {
$this->_oActCurrencyObject = $currencies[$cur];
}
}

return $this->_oActCurrencyObject = $currencies[$cur];
return $this->_oActCurrencyObject;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions source/Core/Model/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ public function assign($dbRecord)
return;
}

reset($dbRecord);
while (list($name, $value) = each($dbRecord)) {
foreach ($dbRecord as $name => $value) {
$this->_setFieldData($name, $value);
}

Expand Down Expand Up @@ -1235,15 +1234,16 @@ protected function _setFieldData($fieldName, $fieldValue, $dataType = Field::T_T
}
}
// if we have a double field we replace "," with "." in case somebody enters it in european format
if ($this->isPropertyLoaded($longFieldName)
$isPropertyLoaded = $this->isPropertyLoaded($longFieldName);
if ($isPropertyLoaded
&& isset($this->$longFieldName->fldtype)
&& $this->$longFieldName->fldtype == 'double'
) {
$fieldValue = str_replace(',', '.', $fieldValue);
}

// isset is REQUIRED here not to use getter
if ($this->isPropertyLoaded($longFieldName)
if ($isPropertyLoaded
&& is_object($this->$longFieldName)
) {
$this->$longFieldName->setValue($fieldValue, $dataType);
Expand Down

0 comments on commit 43201c3

Please sign in to comment.