From 41af10ada0deaa9ed2688cb7c8a9429ceb57f6e7 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Fri, 27 Feb 2026 11:47:20 +0100 Subject: [PATCH] strict equality checks across admin bundle, partly fixes #51 --- public/js/lib/ext-plugins/portlet/Portlet.js | 2 +- public/js/opendxp/asset/listfolder.js | 4 +- public/js/opendxp/asset/versions.js | 2 +- public/js/opendxp/functions.js | 34 ++++---- public/js/opendxp/helpers.js | 14 ++-- public/js/opendxp/object/versions.js | 2 +- public/js/opendxp/overrides.js | 2 +- .../Admin/Asset/AssetController.php | 2 +- src/Controller/Admin/ElementController.php | 8 +- src/Controller/Admin/MiscController.php | 2 +- .../Admin/NotificationController.php | 2 +- src/Helper/GridHelperService.php | 84 +++++++++---------- src/Helper/QueryParams.php | 18 ++-- src/Perspective/Config.php | 2 +- 14 files changed, 89 insertions(+), 89 deletions(-) diff --git a/public/js/lib/ext-plugins/portlet/Portlet.js b/public/js/lib/ext-plugins/portlet/Portlet.js index 050a92fa..dbe649b2 100644 --- a/public/js/lib/ext-plugins/portlet/Portlet.js +++ b/public/js/lib/ext-plugins/portlet/Portlet.js @@ -32,7 +32,7 @@ Ext.define('Portal.view.Portlet', { this.closing = false; this.fireEvent('close', this); this[closeAction](); - if (closeAction == 'hide') { + if (closeAction === 'hide') { this.el.setOpacity(1); } }, diff --git a/public/js/opendxp/asset/listfolder.js b/public/js/opendxp/asset/listfolder.js index 89a160b1..e590bea3 100644 --- a/public/js/opendxp/asset/listfolder.js +++ b/public/js/opendxp/asset/listfolder.js @@ -278,8 +278,8 @@ opendxp.asset.listfolder = Class.create(opendxp.asset.helpers.gridTabAbstract, { }.bind(this), celldblclick: function(grid, td, cellIndex, record, tr, rowIndex, e, eOpts) { var columns = grid.grid.getColumnManager().getColumns(); - if(columns[cellIndex].dataIndex == 'id~system' || columns[cellIndex].dataIndex == 'fullpath~system' - || columns[cellIndex].dataIndex == 'preview~system') { + if(columns[cellIndex].dataIndex === 'id~system' || columns[cellIndex].dataIndex === 'fullpath~system' + || columns[cellIndex].dataIndex === 'preview~system') { var data = this.store.getAt(rowIndex); opendxp.helpers.openAsset(data.id, data.get("type~system")); } diff --git a/public/js/opendxp/asset/versions.js b/public/js/opendxp/asset/versions.js index 5ae28fcc..95624583 100644 --- a/public/js/opendxp/asset/versions.js +++ b/public/js/opendxp/asset/versions.js @@ -210,7 +210,7 @@ opendxp.asset.versions = Class.create({ if (elememntId > 0) { Ext.Msg.confirm(t('clear_all'), t('clear_version_message'), function(btn){ - if (btn == 'yes'){ + if (btn === 'yes'){ var modificationDate = this.asset.data.modificationDate; Ext.Ajax.request({ diff --git a/public/js/opendxp/functions.js b/public/js/opendxp/functions.js index 7106f723..9ef346af 100644 --- a/public/js/opendxp/functions.js +++ b/public/js/opendxp/functions.js @@ -313,7 +313,7 @@ function uniqid(prefix, more_entropy) { // * returns 2: 'fooa30285b1cd361' // * example 3: uniqid('bar', true); // * returns 3: 'bara20285b23dfd1.31879087' - if (typeof prefix == 'undefined') { + if (typeof prefix === 'undefined') { prefix = ""; } @@ -379,7 +379,7 @@ function empty (mixed_var) { return true; } - if (typeof mixed_var == 'object') { + if (typeof mixed_var === 'object') { for (key in mixed_var) { return false; } @@ -507,7 +507,7 @@ function base64_encode(data) { // mozilla has this native // - but breaks in 2.0.0.12! - //if (typeof this.window['atob'] == 'function') { + //if (typeof this.window['atob'] === 'function') { // return atob(data); //} @@ -569,7 +569,7 @@ function base64_decode(data) { // * returns 1: 'Kevin van Zonneveld' // mozilla has this native // - but breaks in 2.0.0.12! - //if (typeof this.window['btoa'] == 'function') { + //if (typeof this.window['btoa'] === 'function') { // return btoa(data); //} @@ -1500,7 +1500,7 @@ function implode (glue, pieces) { function insertTextToFormElementAtCursor(txtarea, text) { var scrollPos = txtarea.scrollTop; var strPos = 0; - var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? + var br = ((txtarea.selectionStart || txtarea.selectionStart === '0') ? "ff" : (document.selection ? "ie" : false ) ); if (br == "ie") { txtarea.focus(); @@ -1592,7 +1592,7 @@ sprintf = function () var pPrecision = a[5], pType = a[6], rightPart = a[7]; numMatches++; - if (pType == '%') + if (pType === '%') { subst = '%'; } @@ -1612,17 +1612,17 @@ sprintf = function () var minLength = -1; if (pMinLength) minLength = parseInt(pMinLength); var precision = -1; - if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1)); + if (pPrecision && pType === 'f') precision = parseInt(pPrecision.substring(1)); var subst = param; - if (pType == 'b') subst = parseInt(param).toString(2); - else if (pType == 'c') subst = String.fromCharCode(parseInt(param)); - else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0; - else if (pType == 'u') subst = Math.abs(param); - else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param); - else if (pType == 'o') subst = parseInt(param).toString(8); - else if (pType == 's') subst = param; - else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase(); - else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase(); + if (pType === 'b') subst = parseInt(param).toString(2); + else if (pType === 'c') subst = String.fromCharCode(parseInt(param)); + else if (pType === 'd') subst = parseInt(param) ? parseInt(param) : 0; + else if (pType === 'u') subst = Math.abs(param); + else if (pType === 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param); + else if (pType === 'o') subst = parseInt(param).toString(8); + else if (pType === 's') subst = param; + else if (pType === 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase(); + else if (pType === 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase(); } arguments[numSubstitutions] = subst; str = leftpart + '${'+numSubstitutions+'}' + rightPart; @@ -1706,7 +1706,7 @@ function array_merge_recursive (arr1, arr2){ } else if ((arr1 && (arr1 instanceof Object)) && (arr2 && (arr2 instanceof Object))) { for (idx in arr2) { if (idx in arr1) { - if (typeof arr1[idx] == 'object' && typeof arr2 == 'object') { + if (typeof arr1[idx] === 'object' && typeof arr2 === 'object') { arr1[idx] = this.array_merge(arr1[idx], arr2[idx]); } else { arr1[idx] = arr2[idx]; diff --git a/public/js/opendxp/helpers.js b/public/js/opendxp/helpers.js index e8927503..8bb7b9b2 100644 --- a/public/js/opendxp/helpers.js +++ b/public/js/opendxp/helpers.js @@ -1683,13 +1683,13 @@ opendxp.helpers.sendTestEmail = function (from, to, subject, emailType, document fieldLabel: t('type'), listeners: { select: function(t) { - if(t.value == 'text' || t.value == 'html') { + if(t.value === 'text' || t.value === 'html') { emailContentTextField.show(); } else { emailContentTextField.hide(); } - if(t.value == 'document') { + if(t.value === 'document') { documentComponent.show(); paramGrid.show(); } else { @@ -1843,11 +1843,11 @@ opendxp.helpers.sendTestEmail = function (from, to, subject, emailType, document if(emailType) { emailTypeDropdown.setValue(emailType); - if(emailType == 'document') { + if(emailType === 'document') { documentComponent.show(); paramGrid.show(); } - if(emailType == 'html' || emailType == 'text') { + if(emailType === 'html' || emailType === 'text') { emailContentTextField.show(); } } @@ -3213,7 +3213,7 @@ opendxp.helpers.treeToolTipShow = function (el, record, item) { var offsetTreeNode = Ext.get(item).getXY(); var parentTree = el.ownerCt.ownerCt; - if(parentTree.region == 'west') { + if(parentTree.region === 'west') { opendxp_tooltip.applyStyles({ top: (offsetTreeNode[1] + 8) + "px", left: offsetTabPanel[0] + "px", @@ -3221,7 +3221,7 @@ opendxp.helpers.treeToolTipShow = function (el, record, item) { }); } - if(parentTree.region == 'east') { + if(parentTree.region === 'east') { opendxp_tooltip.addCls('right'); opendxp_tooltip.applyStyles({ top: (offsetTreeNode[1] + 8) + "px", @@ -3324,7 +3324,7 @@ opendxp.helpers.deleteConfirm = function (title, name, deleteCallback) { Ext.Msg.confirm(t('delete'), sprintf(t('delete_message_advanced'), title, name), function (btn) { - if (btn == 'yes') { + if (btn === 'yes') { if (typeof deleteCallback == "function") { deleteCallback(); } diff --git a/public/js/opendxp/object/versions.js b/public/js/opendxp/object/versions.js index 54ec5d0e..33391a9d 100644 --- a/public/js/opendxp/object/versions.js +++ b/public/js/opendxp/object/versions.js @@ -270,7 +270,7 @@ opendxp.object.versions = Class.create({ if (elememntId > 0) { Ext.Msg.confirm(t('clear_all'), t('clear_version_message'), function (btn) { - if (btn == 'yes') { + if (btn === 'yes') { var modificationDate = this.object.data.general.modificationDate; Ext.Ajax.request({ diff --git a/public/js/opendxp/overrides.js b/public/js/opendxp/overrides.js index d765ade0..fe497cf9 100644 --- a/public/js/opendxp/overrides.js +++ b/public/js/opendxp/overrides.js @@ -1190,7 +1190,7 @@ Ext.define('Ext.local.grid.filters.filter.TriFilter', { } if ('in' in value) { v = value.in; - if (typeof v === "object" && v[0][0] == '') { + if (typeof v === "object" && v[0][0] === '') { remove.push(filters.in); } else if (v || v === 0) { add.push(filters.in); diff --git a/src/Controller/Admin/Asset/AssetController.php b/src/Controller/Admin/Asset/AssetController.php index 1f3100a9..5ac57055 100644 --- a/src/Controller/Admin/Asset/AssetController.php +++ b/src/Controller/Admin/Asset/AssetController.php @@ -142,7 +142,7 @@ public function getDataByIdAction(Request $request, EventDispatcherInterface $ev if (\OpenDxp\Video::isAvailable()) { $config = Asset\Video\Thumbnail\Config::getPreviewConfig(); $thumbnail = $asset->getThumbnail($config, ['mp4']); - if ($thumbnail && $thumbnail['status'] == 'finished') { + if ($thumbnail && $thumbnail['status'] === 'finished') { $videoInfo['previewUrl'] = $thumbnail['formats']['mp4']; $videoInfo['width'] = $asset->getWidth(); $videoInfo['height'] = $asset->getHeight(); diff --git a/src/Controller/Admin/ElementController.php b/src/Controller/Admin/ElementController.php index b97b61cf..ab67ef2a 100644 --- a/src/Controller/Admin/ElementController.php +++ b/src/Controller/Admin/ElementController.php @@ -808,7 +808,7 @@ protected function getNicePathFormatterFieldDefinition(DataObject\Concrete $sour $fieldname = $context['fieldname']; $fd = null; - if ($ownerType == 'object') { + if ($ownerType === 'object') { $subContainerType = $context['subContainerType'] ?? null; if ($subContainerType) { $subContainerKey = $context['subContainerKey']; @@ -819,15 +819,15 @@ protected function getNicePathFormatterFieldDefinition(DataObject\Concrete $sour } else { $fd = $source->getClass()->getFieldDefinition($fieldname); } - } elseif ($ownerType == 'localizedfield') { + } elseif ($ownerType === 'localizedfield') { $localizedfields = $source->getClass()->getFieldDefinition('localizedfields'); if ($localizedfields instanceof DataObject\ClassDefinition\Data\Localizedfields) { $fd = $localizedfields->getFieldDefinition($fieldname); } - } elseif ($ownerType == 'objectbrick') { + } elseif ($ownerType === 'objectbrick') { $fdBrick = DataObject\Objectbrick\Definition::getByKey($context['containerKey']); $fd = $fdBrick->getFieldDefinition($fieldname); - } elseif ($ownerType == 'fieldcollection') { + } elseif ($ownerType === 'fieldcollection') { $containerKey = $context['containerKey']; $fdCollection = DataObject\Fieldcollection\Definition::getByKey($containerKey); if (($context['subContainerType'] ?? null) === 'localizedfield') { diff --git a/src/Controller/Admin/MiscController.php b/src/Controller/Admin/MiscController.php index 073afeb9..124125bf 100644 --- a/src/Controller/Admin/MiscController.php +++ b/src/Controller/Admin/MiscController.php @@ -130,7 +130,7 @@ public function scriptProxyAction(Request $request): Response if (!empty($scriptsContent)) { $contentType = 'text/javascript'; - if ($fileExtension == 'css') { + if ($fileExtension === 'css') { $contentType = 'text/css'; } diff --git a/src/Controller/Admin/NotificationController.php b/src/Controller/Admin/NotificationController.php index c6f79dbf..abfaef49 100644 --- a/src/Controller/Admin/NotificationController.php +++ b/src/Controller/Admin/NotificationController.php @@ -44,7 +44,7 @@ public function recipientsAction(UserService $service, TranslatorInterface $tran foreach ($service->findAll($this->getAdminUser()) as $recipient) { $group = $translator->trans('group', [], 'admin'); - $prefix = $recipient->getType() == 'role' ? $group . ' - ' : ''; + $prefix = $recipient->getType() === 'role' ? $group . ' - ' : ''; $data[] = [ 'id' => $recipient->getId(), diff --git a/src/Helper/GridHelperService.php b/src/Helper/GridHelperService.php index d26dffee..b951fc90 100644 --- a/src/Helper/GridHelperService.php +++ b/src/Helper/GridHelperService.php @@ -61,28 +61,28 @@ public function getFeatureAndSlugFilters(string $filterJson, ClassDefinition $cl $filterField = $filter['property']; $filterOperator = $filter['operator']; - if ($filter['type'] == 'string') { + if ($filter['type'] === 'string') { $operator = 'LIKE'; - } elseif ($filter['type'] == 'numeric' || $filter['type'] == 'quantityValue') { - if ($filterOperator == 'lt') { + } elseif ($filter['type'] === 'numeric' || $filter['type'] === 'quantityValue') { + if ($filterOperator === 'lt') { $operator = '<'; - } elseif ($filterOperator == 'gt') { + } elseif ($filterOperator === 'gt') { $operator = '>'; - } elseif ($filterOperator == 'eq') { + } elseif ($filterOperator === 'eq') { $operator = '='; } - } elseif ($filter['type'] == 'date') { - if ($filterOperator == 'lt') { + } elseif ($filter['type'] === 'date') { + if ($filterOperator === 'lt') { $operator = '<'; - } elseif ($filterOperator == 'gt') { + } elseif ($filterOperator === 'gt') { $operator = '>'; - } elseif ($filterOperator == 'eq') { + } elseif ($filterOperator === 'eq') { $operator = '='; } $filter['value'] = strtotime($filter['value']); - } elseif ($filter['type'] == 'list') { + } elseif ($filter['type'] === 'list') { $operator = '='; - } elseif ($filter['type'] == 'boolean') { + } elseif ($filter['type'] === 'boolean') { $operator = '='; $filter['value'] = (int)$filter['value']; } @@ -215,23 +215,23 @@ public function getFilterCondition(string $filterJson, ClassDefinition $class, ? $filterField = $filter['property']; $filterOperator = $filter['operator']; - if ($filter['type'] == 'string') { + if ($filter['type'] === 'string') { $operator = 'LIKE'; - } elseif ($filter['type'] == 'date') { - if ($filterOperator == 'lt') { + } elseif ($filter['type'] === 'date') { + if ($filterOperator === 'lt') { $operator = '<'; - } elseif ($filterOperator == 'gt') { + } elseif ($filterOperator === 'gt') { $operator = '>'; - } elseif ($filterOperator == 'eq') { + } elseif ($filterOperator === 'eq') { $operator = '='; } $filter['value'] = strtotime($filter['value']); - } elseif ($filter['type'] == 'list') { + } elseif ($filter['type'] === 'list') { $operator = '='; - } elseif ($filter['type'] == 'boolean') { + } elseif ($filter['type'] === 'boolean') { $operator = '='; $filter['value'] = (int)$filter['value']; - } elseif ($filterOperator == 'in' && is_array($filter['value'])) { + } elseif ($filterOperator === 'in' && is_array($filter['value'])) { $operator = 'in'; $matches = preg_split('/[^0-9\.]+/', $filter['value'][0][0] ?? [], -1, PREG_SPLIT_NO_EMPTY); if (is_array($matches) && count($matches) > 0) { @@ -239,7 +239,7 @@ public function getFilterCondition(string $filterJson, ClassDefinition $class, ? } else { continue; } - } elseif ($filterOperator == 'in' && !is_array($filter['value'])) { + } elseif ($filterOperator === 'in' && !is_array($filter['value'])) { $operator = 'in'; $matches = preg_split('/[^0-9\.]+/', $filter['value'], -1, PREG_SPLIT_NO_EMPTY); if (is_array($matches) && count($matches) > 0) { @@ -247,11 +247,11 @@ public function getFilterCondition(string $filterJson, ClassDefinition $class, ? } else { continue; } - } elseif ($filterOperator == 'lt') { + } elseif ($filterOperator === 'lt') { $operator = '<'; - } elseif ($filterOperator == 'gt') { + } elseif ($filterOperator === 'gt') { $operator = '>'; - } elseif ($filterOperator == 'eq') { + } elseif ($filterOperator === 'eq') { $operator = '='; } @@ -357,17 +357,17 @@ public function getFilterCondition(string $filterJson, ClassDefinition $class, ? // system field $lowerCasedFilterValue = strtolower($filter['value']); // lowercase for case insensitive search $lowerCasedFilterValue = str_replace('*', '%', $lowerCasedFilterValue); // replace wildcard - if ($filterField == 'fullpath') { + if ($filterField === 'fullpath') { $conditionPartsFilters[] = 'concat(lower(`path`), lower(`key`)) ' . $operator . ' ' . $db->quote('%' . $lowerCasedFilterValue . '%'); - } elseif ($filterField == 'key') { + } elseif ($filterField === 'key') { $conditionPartsFilters[] = 'lower(`key`) ' . $operator . ' ' . $db->quote('%' . $lowerCasedFilterValue . '%'); - } elseif ($filterField == 'id' && $operator !== 'in') { + } elseif ($filterField === 'id' && $operator !== 'in') { $conditionPartsFilters[] = 'oo_id ' . $operator . ' ' . $db->quote($filter['value']); - } elseif ($filterField == 'id' && $operator === 'in') { + } elseif ($filterField === 'id' && $operator === 'in') { $conditionPartsFilters[] = 'oo_id ' . $operator . ' (' . $filter['value'] . ')'; } else { $filterField = $db->quoteIdentifier($filterField); - if ($filter['type'] == 'date' && $operator === '=') { + if ($filter['type'] === 'date' && $operator === '=') { //if the equal operator is chosen with the date type, condition has to be changed $maxTime = $filter['value'] + (86400 - 1); //specifies the top point of the range used in the condition $conditionPartsFilters[] = $filterField . ' BETWEEN ' . $db->quote($filter['value']) . ' AND ' . $db->quote($maxTime); @@ -772,7 +772,7 @@ public function prepareAssetListingForGrid(array $allParams, User $adminUser): M $list = new Model\Asset\Listing(); $conditionFilters = []; - if (isset($allParams['only_direct_children']) && $allParams['only_direct_children'] == 'true') { + if (isset($allParams['only_direct_children']) && $allParams['only_direct_children'] === 'true') { $conditionFilters[] = 'parentId = ' . $folder->getId(); } else { $conditionFilters[] = 'path LIKE ' . ($folder->getRealFullPath() === '/' ? "'/%'" : $list->quote($list->escapeLike($folder->getRealFullPath()) . '/%')); @@ -795,16 +795,16 @@ public function prepareAssetListingForGrid(array $allParams, User $adminUser): M $filterOperator = $filter['operator']; $filterType = $filter['type']; - if ($filterType == 'string') { + if ($filterType === 'string') { $operator = 'LIKE'; - } elseif ($filterType == 'numeric') { - if ($filterOperator == 'lt') { + } elseif ($filterType === 'numeric') { + if ($filterOperator === 'lt') { $operator = '<'; - } elseif ($filterOperator == 'gt') { + } elseif ($filterOperator === 'gt') { $operator = '>'; - } elseif ($filterOperator == 'eq') { + } elseif ($filterOperator === 'eq') { $operator = '='; - } elseif ($filterOperator == 'in') { + } elseif ($filterOperator === 'in') { $operator = 'IN'; $filterValue = $filter['value'] ?? ''; @@ -817,21 +817,21 @@ public function prepareAssetListingForGrid(array $allParams, User $adminUser): M } } } - } elseif ($filterType == 'date') { + } elseif ($filterType === 'date') { $filter['value'] = strtotime($filter['value']); - if ($filterOperator == 'lt') { + if ($filterOperator === 'lt') { $operator = '<'; - } elseif ($filterOperator == 'gt') { + } elseif ($filterOperator === 'gt') { $operator = '>'; - } elseif ($filterOperator == 'eq') { + } elseif ($filterOperator === 'eq') { $operator = 'BETWEEN'; //if the equal operator is chosen with the date type, condition has to be changed $maxTime = $filter['value'] + (86400 - 1); //specifies the top point of the range used in the condition $filter['value'] = $db->quote($filter['value']) . ' AND ' . $db->quote($maxTime); } - } elseif ($filterType == 'list') { + } elseif ($filterType === 'list') { $operator = 'IN'; - } elseif ($filterType == 'boolean') { + } elseif ($filterType === 'boolean') { $operator = '='; if ((int) $filter['value'] === 0) { $notSubselect = 'NOT'; @@ -853,7 +853,7 @@ public function prepareAssetListingForGrid(array $allParams, User $adminUser): M $value = $db->quote($value); } - if (isset($filterDef[1]) && $filterDef[1] == 'system') { + if (isset($filterDef[1]) && $filterDef[1] === 'system') { $filterField = $filterField === 'fullpath' ? 'CONCAT(`path`,filename)' : $db->quoteIdentifier($filterField); $conditionFilters[] = $filterField . ' ' . $operator . ' ' . $value; } else { diff --git a/src/Helper/QueryParams.php b/src/Helper/QueryParams.php index 8a6d3654..e1117040 100644 --- a/src/Helper/QueryParams.php +++ b/src/Helper/QueryParams.php @@ -83,23 +83,23 @@ public static function getFilterCondition(string $filterString, array $matchExac $filters = json_decode($filterString); $db = \OpenDxp\Db::get(); foreach ($filters as $f) { - if ($f->type == 'string') { + if ($f->type === 'string') { if (in_array($f->property, $matchExact)) { $conditions[$f->property][] = ' ' . $db->quoteIdentifier($f->property) . ' = ' . $db->quote($f->value) . ' '; } else { $conditions[$f->property][] = ' ' . $db->quoteIdentifier($f->property) . ' LIKE ' . $db->quote('%' . $f->value . '%') . ' '; } - } elseif ($f->type == 'numeric') { + } elseif ($f->type === 'numeric') { $symbol = null; - if ($f->operator == 'eq') { + if ($f->operator === 'eq') { $symbol = ' = '; - } elseif ($f->operator == 'lt') { + } elseif ($f->operator === 'lt') { $symbol = ' < '; - } elseif ($f->operator == 'gt') { + } elseif ($f->operator === 'gt') { $symbol = ' > '; } $conditions[$f->property][] = ' ' . $db->quoteIdentifier($f->property) . ' ' . $symbol . $db->quote($f->value) . ' '; - } elseif ($f->type == 'date') { + } elseif ($f->type === 'date') { /** * make sure you pass the date as timestamp * @@ -107,12 +107,12 @@ public static function getFilterCondition(string $filterString, array $matchExac */ $date = Carbon::createFromTimestamp($f->value)->setTime(0, 0, 0); - if ($f->operator == 'eq') { + if ($f->operator === 'eq') { $conditions[$f->property][] = ' ' . $f->property . ' >= ' . $db->quote($date->getTimestamp()); $conditions[$f->property][] = ' ' . $f->property . ' <= ' . $db->quote($date->addDay()->subSecond()->getTimestamp()); - } elseif ($f->operator == 'lt') { + } elseif ($f->operator === 'lt') { $conditions[$f->property][] = ' ' . $f->property . ' < ' . $db->quote($date->getTimestamp()); - } elseif ($f->operator == 'gt') { + } elseif ($f->operator === 'gt') { $conditions[$f->property][] = ' ' . $f->property . ' > ' . $db->quote($date->addDay()->subSecond()->getTimestamp()); } } else { diff --git a/src/Perspective/Config.php b/src/Perspective/Config.php index d5515022..e818a154 100644 --- a/src/Perspective/Config.php +++ b/src/Perspective/Config.php @@ -284,7 +284,7 @@ protected static function getRuntimeElementTreeConfig(string $name): array continue; } - if ($resultItem['type'] == 'customview') { + if ($resultItem['type'] === 'customview') { $customViewId = $resultItem['id'] ?? false; if (!$customViewId) { Logger::error('custom view id missing ' . var_export($resultItem, true));