From 1dcfc57f15c381f4a87f1a193a0a0831752f3f69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Dec 2022 03:12:00 +0000 Subject: [PATCH 1/6] Bump certifi from 2019.11.28 to 2022.12.7 in /docs Bumps [certifi](https://github.com/certifi/python-certifi) from 2019.11.28 to 2022.12.7. - [Release notes](https://github.com/certifi/python-certifi/releases) - [Commits](https://github.com/certifi/python-certifi/compare/2019.11.28...2022.12.07) --- updated-dependencies: - dependency-name: certifi dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 2734cd2..e9f5e9f 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,7 +1,7 @@ alabaster==0.7.12 Babel==2.9.1 cakephp-theme==1.1.3 -certifi==2019.11.28 +certifi==2022.12.7 chardet==3.0.4 docutils==0.15.2 idna==2.8 From ea3e954aa18a4b7830913331ff5d75596c443b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Turek?= Date: Fri, 16 Dec 2022 09:20:32 +0100 Subject: [PATCH 2/6] Fixed variable name in line 50 Fixes #303 --- webroot/js/local.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webroot/js/local.js b/webroot/js/local.js index ebe5b89..319c379 100644 --- a/webroot/js/local.js +++ b/webroot/js/local.js @@ -47,7 +47,7 @@ var CrudView = { query[$ele.data('filter-field') || $ele.attr('name')] = params.term; if ($ele.data('dependent-on') && $('#' + $ele.data('dependent-on')).val()) { - data[$ele.data('dependent-on-field')] = $('#' + $ele.data('dependent-on')).val(); + query[$ele.data('dependent-on-field')] = $('#' + $ele.data('dependent-on')).val(); } return query; From 9f07c06233c1d75508faa6ef0855128752d5e5a9 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 16 Dec 2022 14:30:35 +0530 Subject: [PATCH 3/6] Update composer config --- composer.json | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index aa162fc..36542f6 100644 --- a/composer.json +++ b/composer.json @@ -30,8 +30,8 @@ ], "require": { "cakephp/cakephp": "^4.0", - "friendsofcake/crud": "^6.0", - "friendsofcake/bootstrap-ui": "^3.0" + "friendsofcake/bootstrap-ui": "^3.0", + "friendsofcake/crud": "^6.0" }, "require-dev": { "friendsofcake/cakephp-test-utilities": "^2.0", @@ -54,5 +54,11 @@ "wiki": "http://cakephp.nu/cakephp-crud/", "irc": "irc://irc.freenode.org/friendsofcake" }, - "prefer-stable": true + "prefer-stable": true, + "config": { + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + } } From ec53e0a64ca1df2eb90b9e31cce3f06f0d695e6d Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 16 Dec 2022 14:40:28 +0530 Subject: [PATCH 4/6] Fix errors reported by phpstan --- .github/workflows/ci.yml | 2 +- phpstan-baseline.neon | 34 ++-------------------------------- phpstan.neon | 1 + src/Action/DashboardAction.php | 2 +- 4 files changed, 5 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db57c4b..36d3dbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: php-version: '7.4' extensions: mbstring, intl coverage: none - tools: vimeo/psalm:4.22, phpstan:1.4 + tools: vimeo/psalm:4, phpstan:1.9 - name: Composer Install run: composer require --dev cakephp/cakephp-codesniffer:^4.1 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c433336..a039fbb 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,22 +1,7 @@ parameters: ignoreErrors: - - message: "#^Access to an undefined property object\\:\\:\\$element\\.$#" - count: 1 - path: src/Listener/ViewListener.php - - - - message: "#^Access to an undefined property object\\:\\:\\$query\\.$#" - count: 4 - path: src/Listener/ViewListener.php - - - - message: "#^Access to an undefined property object\\:\\:\\$type\\.$#" - count: 1 - path: src/Listener/ViewListener.php - - - - message: "#^Cannot unset offset mixed on array\\.$#" + message: "#^Cannot unset offset mixed on array\\{\\}\\.$#" count: 2 path: src/Listener/ViewListener.php @@ -41,22 +26,7 @@ parameters: path: src/Listener/ViewSearchListener.php - - message: "#^Binary operation \"\\+\" between string and array\\{data\\-enable\\-seconds\\?\\: 'true', data\\-date\\-format\\: string, data\\-alt\\-format\\?\\: mixed, data\\-alt\\-input\\?\\: 'true', data\\-no\\-calendar\\?\\: 'true', data\\-enable\\-time\\?\\: 'true', data\\-alt\\-input\\-class\\?\\: string, class\\: array\\{'input\\-group', 'flatpickr'\\}\\} results in an error\\.$#" - count: 1 - path: src/View/Widget/DateTimeWidget.php - - - - message: "#^Binary operation \"\\+\\=\" between array\\\\|string and array\\{data\\-enable\\-seconds\\?\\: 'true', data\\-date\\-format\\: string, data\\-alt\\-format\\?\\: mixed, data\\-alt\\-input\\?\\: 'true', data\\-no\\-calendar\\?\\: 'true', data\\-enable\\-time\\?\\: 'true'\\} results in an error\\.$#" - count: 1 - path: src/View/Widget/DateTimeWidget.php - - - - message: "#^Offset 'data\\-wrap' does not exist on array\\{data\\-enable\\-seconds\\?\\: 'true', data\\-date\\-format\\: string, data\\-alt\\-format\\?\\: mixed, data\\-alt\\-input\\?\\: 'true', data\\-no\\-calendar\\?\\: 'true', data\\-enable\\-time\\?\\: 'true'\\}\\.$#" - count: 1 - path: src/View/Widget/DateTimeWidget.php - - - - message: "#^Offset 'iconClass' on array\\{data\\-enable\\-seconds\\?\\: 'true', data\\-date\\-format\\: string, data\\-alt\\-format\\?\\: mixed, data\\-alt\\-input\\?\\: 'true', data\\-no\\-calendar\\?\\: 'true', data\\-enable\\-time\\?\\: 'true'\\} in isset\\(\\) does not exist\\.$#" + message: "#^Binary operation \"\\+\" between string and non\\-empty\\-array results in an error\\.$#" count: 1 path: src/View/Widget/DateTimeWidget.php diff --git a/phpstan.neon b/phpstan.neon index aba1800..3b09bdc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,6 +4,7 @@ includes: parameters: level: 7 checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false paths: - src universalObjectCratesClasses: diff --git a/src/Action/DashboardAction.php b/src/Action/DashboardAction.php index fd8b12b..cc9bfde 100644 --- a/src/Action/DashboardAction.php +++ b/src/Action/DashboardAction.php @@ -19,7 +19,7 @@ class DashboardAction extends BaseAction /** * HTTP GET handler * - * @return void|\Cake\Http\Response + * @return void */ protected function _get() { From c9a2d46f03acfa8e84c3cdfcfe2c9921d80399fa Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 19 Dec 2022 18:00:53 +0530 Subject: [PATCH 5/6] Auto blacklist disabled actions. --- src/Listener/Traits/FormTypeTrait.php | 5 ++++- src/Listener/ViewListener.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Listener/Traits/FormTypeTrait.php b/src/Listener/Traits/FormTypeTrait.php index 5c56b08..35e6d0b 100644 --- a/src/Listener/Traits/FormTypeTrait.php +++ b/src/Listener/Traits/FormTypeTrait.php @@ -133,7 +133,10 @@ protected function _getDefaultExtraLeftButtons(): array $action = $this->_action(); if ($action instanceof EditAction) { $blacklist = $action->getConfig('scaffold.actions_blacklist', []); - if (!in_array('delete', $blacklist, true)) { + if ( + !in_array('delete', $blacklist, true) && + $this->_crud()->action('delete')->enabled() + ) { $buttons[] = [ 'title' => __d('crud', 'Delete'), 'url' => ['action' => 'delete'], diff --git a/src/Listener/ViewListener.php b/src/Listener/ViewListener.php index 7f3c039..b457cc1 100644 --- a/src/Listener/ViewListener.php +++ b/src/Listener/ViewListener.php @@ -504,7 +504,10 @@ protected function _getAllowedActions(): array $blacklist = (array)$this->_action()->getConfig('scaffold.actions_blacklist'); $blacklist = array_combine($blacklist, $blacklist); foreach ($this->_crud()->getConfig('actions') as $action => $config) { - if ($config['className'] === 'Crud.Lookup') { + if ( + $config['className'] === 'Crud.Lookup' || + !$this->_crud()->action($action)->enabled() + ) { $blacklist[$action] = $action; } } From da917d205369c610efc3a28dc63d1b3f97ae7f60 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 23 Dec 2022 12:29:02 +0530 Subject: [PATCH 6/6] Check if action is mapped before trying to access it's config. --- src/Listener/Traits/FormTypeTrait.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Listener/Traits/FormTypeTrait.php b/src/Listener/Traits/FormTypeTrait.php index 35e6d0b..11e70f7 100644 --- a/src/Listener/Traits/FormTypeTrait.php +++ b/src/Listener/Traits/FormTypeTrait.php @@ -135,6 +135,7 @@ protected function _getDefaultExtraLeftButtons(): array $blacklist = $action->getConfig('scaffold.actions_blacklist', []); if ( !in_array('delete', $blacklist, true) && + $this->_crud()->isActionMapped('delete') && $this->_crud()->action('delete')->enabled() ) { $buttons[] = [