Skip to content

Commit

Permalink
Many fixes:
Browse files Browse the repository at this point in the history
 - Mutualize some code
 - Extends CommonTreeDropdown everytime
 - Put back `getAssetClassName()` to reduce diff
 - Add default SO
 - ...
  • Loading branch information
cedric-anne committed Sep 19, 2024
1 parent a27932a commit c3ecd67
Show file tree
Hide file tree
Showing 61 changed files with 559 additions and 899 deletions.
20 changes: 7 additions & 13 deletions .phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -1923,22 +1923,10 @@
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method Glpi\\\\Asset\\\\Asset\\:\\:getById\\(\\) should return static\\(Glpi\\\\Asset\\\\Asset\\)\\|false but returns Glpi\\\\Asset\\\\Asset\\.$#',
'message' => '#^Method Glpi\\\\Asset\\\\Asset\\:\\:getById\\(\\) should return static\\(Glpi\\\\Asset\\\\Asset\\)\\|false but returns object\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Asset/Asset.php',
];
$ignoreErrors[] = [
// identifier: parameter.notFound
'message' => '#^PHPDoc tag @param references unknown parameter\\: \\$definition$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Asset/AssetDefinition.php',
];
$ignoreErrors[] = [
// identifier: parameter.notFound
'message' => '#^PHPDoc tag @param references unknown parameter\\: \\$profiles$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Asset/AssetDefinition.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method Glpi\\\\Asset\\\\AssetModel\\:\\:getById\\(\\) should return static\\(Glpi\\\\Asset\\\\AssetModel\\)\\|false but returns Glpi\\\\Asset\\\\AssetModel\\.$#',
Expand Down Expand Up @@ -2275,6 +2263,12 @@
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Dashboard/Provider.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method Glpi\\\\Dropdown\\\\Dropdown\\:\\:getById\\(\\) should return static\\(Glpi\\\\Dropdown\\\\Dropdown\\)\\|false but returns object\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Dropdown/Dropdown.php',
];
$ignoreErrors[] = [
// identifier: method.nonObject
'message' => '#^Cannot call method getItem\\(\\) on CommonDBTM\\|false\\.$#',
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"psr-4": {
"Glpi\\Tools\\": "tools/src/",
"Glpi\\Tests\\": "tests/src/",
"Glpi\\PHPUNit\\Tests\\": "phpunit/src/"
"Glpi\\PHPUnit\\Tests\\": "phpunit/src/"
},
"files": ["tests/src/autoload/functions.php"]
},
Expand Down
2 changes: 0 additions & 2 deletions dependency_injection/legacyConfigProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Glpi\Config\LegacyConfigProviderInterface;
use Glpi\Config\LegacyConfigurators\AssetsAutoloader;
use Glpi\Config\LegacyConfigurators\AssetsBootstrap;
use Glpi\Config\LegacyConfigurators\CleanPHPSelfParam;
use Glpi\Config\LegacyConfigurators\ConfigRest;
use Glpi\Config\LegacyConfigurators\CustomObjectsAutoloader;
Expand Down
2 changes: 1 addition & 1 deletion front/asset/asset.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
} else {
$definition = new AssetDefinition();
$classname = array_key_exists('class', $_GET) && $definition->getFromDBBySystemName((string)$_GET['class'])
? $definition->getCustomObjectClassName()
? $definition->getAssetClassName()
: null;
$asset = $classname !== null && class_exists($classname)
? new $classname()
Expand Down
2 changes: 1 addition & 1 deletion front/asset/asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

$definition = new AssetDefinition();
$classname = array_key_exists('class', $_GET) && $definition->getFromDBBySystemName((string)$_GET['class'])
? $definition->getCustomObjectClassName()
? $definition->getAssetClassName()
: null;

if ($classname === null || !class_exists($classname)) {
Expand Down
135 changes: 0 additions & 135 deletions front/dropdown/dropdown.form.php

This file was deleted.

55 changes: 0 additions & 55 deletions front/dropdown/dropdown.php

This file was deleted.

5 changes: 2 additions & 3 deletions install/migrations/update_10.0.x_to_11.0.0/dropdowns.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

/**
* @var array $ADDTODISPLAYPREF
* @var DB $DB
* @var DBmysql $DB
* @var Migration $migration
*/

Expand All @@ -52,7 +52,6 @@
`is_active` tinyint NOT NULL DEFAULT '0',
`profiles` JSON NOT NULL,
`translations` JSON NOT NULL,
`is_tree` tinyint NOT NULL DEFAULT '0',
`date_creation` timestamp NULL DEFAULT NULL,
`date_mod` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
Expand All @@ -69,7 +68,7 @@
$query = <<<SQL
CREATE TABLE `glpi_dropdowns_dropdowns` (
`id` int {$default_key_sign} NOT NULL AUTO_INCREMENT,
`dropdowns_dropdowndefinitions_id` int unsigned NOT NULL,
`dropdowns_dropdowndefinitions_id` int {$default_key_sign} NOT NULL,
`name` varchar(255) DEFAULT NULL,
`comment` text,
`entities_id` int {$default_key_sign} NOT NULL DEFAULT '0',
Expand Down
1 change: 0 additions & 1 deletion install/mysql/glpi-empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9953,7 +9953,6 @@ CREATE TABLE `glpi_dropdowns_dropdowndefinitions` (
`is_active` tinyint NOT NULL DEFAULT '0',
`profiles` JSON NOT NULL,
`translations` JSON NOT NULL,
`is_tree` tinyint NOT NULL DEFAULT '0',
`date_creation` timestamp NULL DEFAULT NULL,
`date_mod` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
Expand Down
4 changes: 2 additions & 2 deletions phpunit/DbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ protected function initAssetDefinition(
);

// Clear definition cache
$rc = new ReflectionClass(\Glpi\Asset\AssetDefinitionManager::class);
$rc->getProperty('definitions_data')->setValue(\Glpi\Asset\AssetDefinitionManager::getInstance(), null);
$rc = new ReflectionClass(\Glpi\CustomObject\AbstractDefinitionManager::class);
$rc->getProperty('definitions_data')->setValue(\Glpi\Asset\AssetDefinitionManager::getInstance(), []);

$manager = \Glpi\Asset\AssetDefinitionManager::getInstance();
$this->callPrivateMethod($manager, 'loadConcreteClass', $definition);
Expand Down
4 changes: 2 additions & 2 deletions phpunit/functional/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4141,10 +4141,10 @@ protected function customAssetsProvider(): iterable
$document_3 = $this->createTxtDocument();

$definition_1 = $this->initAssetDefinition(capacities: [HasDocumentsCapacity::class]);
$asset_class_1 = $definition_1->getCustomObjectClassName();
$asset_class_1 = $definition_1->getAssetClassName();

$definition_2 = $this->initAssetDefinition(capacities: [HasDocumentsCapacity::class]);
$asset_class_2 = $definition_2->getCustomObjectClassName();
$asset_class_2 = $definition_2->getAssetClassName();

// Assets for first class
$asset_1_1 = $this->createItem(
Expand Down
Loading

0 comments on commit c3ecd67

Please sign in to comment.