From 4f3bcc40ce2b8ff92f67145a8163a5c9ac75eb68 Mon Sep 17 00:00:00 2001 From: MyuTsu Date: Mon, 30 Jun 2025 15:15:28 +0200 Subject: [PATCH 1/4] fix(fields): massive actions with Fields plugin --- hook.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hook.php b/hook.php index d92f6370..f4198dca 100644 --- a/hook.php +++ b/hook.php @@ -212,3 +212,18 @@ function plugin_genericobject_MassiveActions($type) return []; } } + +function plugin_genericobject_MassiveActionsFieldsDisplay($options = []) +{ + if (!Plugin::isPluginActive('fields')) { + return false; + } + + $itemtypes = PluginFieldsContainer::getEntries('all'); + + if (in_array($options['itemtype'], $itemtypes)) { + return PluginFieldsField::showSingle($options['itemtype'], $options['options'], true); + } + + return false; +} From b26a95a6c56e96c89a69d0dd71e0a565a65f7ad1 Mon Sep 17 00:00:00 2001 From: MyuTsu Date: Mon, 30 Jun 2025 15:30:32 +0200 Subject: [PATCH 2/4] CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bec1205b..e30aa4c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +- Fix massive actions compatibility with Fields plugin + ## [2.14.14] - 2025-04-23 ### Fixed From 6b4cdfbf17f7aae39e0b74a9b83c46f2262f5012 Mon Sep 17 00:00:00 2001 From: MyuTsu Date: Mon, 30 Jun 2025 16:06:19 +0200 Subject: [PATCH 3/4] lint --- phpstan.neon | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index 8feb5069..034b9706 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,5 +15,7 @@ parameters: - ../../src stubFiles: - ../../stubs/glpi_constants.php + ignoreErrors: + - '#Call to .* on an unknown class PluginFields*#' rules: - GlpiProject\Tools\PHPStan\Rules\GlobalVarTypeRule From 13d3a6ac0c170282133a823cee44fea85d65c92f Mon Sep 17 00:00:00 2001 From: Stanislas Date: Tue, 1 Jul 2025 10:28:35 +0200 Subject: [PATCH 4/4] fix phpsran --- composer.json | 1 + composer.lock | 52 +++++++++++++++++++++++++++++++++++++++++++++++++-- hook.php | 8 ++++++++ phpstan.neon | 4 ---- 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 5f94c53d..67767908 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,7 @@ "php": ">=7.4" }, "require-dev": { + "glpi-project/phpstan-glpi": "^1.0", "glpi-project/tools": "^0.7.5", "php-parallel-lint/php-parallel-lint": "^1.4", "phpstan/phpstan": "^2.1", diff --git a/composer.lock b/composer.lock index 8a792052..fbf91ab4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,57 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7d6cf27f3edf20c177140ee4bfed39fc", + "content-hash": "31a02686fa4587fa1891c4b7b55d0f67", "packages": [], "packages-dev": [ + { + "name": "glpi-project/phpstan-glpi", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/glpi-project/phpstan-glpi.git", + "reference": "432f7a10d221f60abdbd4ab4676dbd846a485df1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/glpi-project/phpstan-glpi/zipball/432f7a10d221f60abdbd4ab4676dbd846a485df1", + "reference": "432f7a10d221f60abdbd4ab4676dbd846a485df1", + "shasum": "" + }, + "require": { + "php": ">=7.4", + "phpstan/phpstan": "^2.1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.75", + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStanGlpi\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for GLPI.", + "support": { + "issues": "https://github.com/glpi-project/phpstan-glpi/issues", + "source": "https://github.com/glpi-project/phpstan-glpi/tree/1.0.0" + }, + "time": "2025-06-24T11:45:31+00:00" + }, { "name": "glpi-project/tools", "version": "0.7.5", @@ -1293,5 +1341,5 @@ "platform-overrides": { "php": "7.4.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/hook.php b/hook.php index f4198dca..4ead38bf 100644 --- a/hook.php +++ b/hook.php @@ -219,6 +219,14 @@ function plugin_genericobject_MassiveActionsFieldsDisplay($options = []) return false; } + if (!class_exists('PluginFieldsContainer') || !method_exists('PluginFieldsContainer', 'getEntries')) { + return false; + } + + if (!class_exists('PluginFieldsField') || !method_exists('PluginFieldsField', 'showSingle')) { + return false; + } + $itemtypes = PluginFieldsContainer::getEntries('all'); if (in_array($options['itemtype'], $itemtypes)) { diff --git a/phpstan.neon b/phpstan.neon index 034b9706..60bb85d3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,7 +15,3 @@ parameters: - ../../src stubFiles: - ../../stubs/glpi_constants.php - ignoreErrors: - - '#Call to .* on an unknown class PluginFields*#' -rules: - - GlpiProject\Tools\PHPStan\Rules\GlobalVarTypeRule