From 62f601f6fd3c723bc0085a7890ff517d46484e75 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Tue, 25 May 2021 09:40:04 +0200 Subject: [PATCH] feat(install): drop internal CLI instal script replaced by GLPI's console script Signed-off-by: Thierry Bugier --- composer.json | 1 - composer.lock | 225 +++++++++++++++----------------------- hook.php | 11 +- install/install.php | 13 ++- scripts/cliinstall.php | 158 -------------------------- tests/script-functions.sh | 2 +- 6 files changed, 104 insertions(+), 306 deletions(-) delete mode 100644 scripts/cliinstall.php diff --git a/composer.json b/composer.json index 8afda869d..ae68f8187 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,6 @@ "require": { "php": ">= 7.2", "ext-xml": "*", - "docopt/docopt": "^1.0", "gregwar/captcha": "^1.1", "xylemical/php-expressions": "^1.0.3" }, diff --git a/composer.lock b/composer.lock index 7cfc0f1cc..7029c83c5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,58 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b5bf42d960a67bc1e5006743e51cadf3", + "content-hash": "3131ee87a5435fa34485ccb07a71e4e7", "packages": [ - { - "name": "docopt/docopt", - "version": "1.0.4", - "source": { - "type": "git", - "url": "https://github.com/docopt/docopt.php.git", - "reference": "bf3683a16e09fa1665e493eb4d5a29469e132a4f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/docopt/docopt.php/zipball/bf3683a16e09fa1665e493eb4d5a29469e132a4f", - "reference": "bf3683a16e09fa1665e493eb4d5a29469e132a4f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "4.1.*" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/docopt.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Blake Williams", - "email": "code@shabbyrobe.org", - "homepage": "http://docopt.org/", - "role": "Developer" - } - ], - "description": "Port of Python's docopt for PHP >=5.3", - "homepage": "http://github.com/docopt/docopt.php", - "keywords": [ - "cli", - "docs" - ], - "support": { - "issues": "https://github.com/docopt/docopt.php/issues", - "source": "https://github.com/docopt/docopt.php/tree/1.0.4" - }, - "time": "2019-12-03T02:48:46+00:00" - }, { "name": "gregwar/captcha", "version": "v1.1.9", @@ -115,16 +65,16 @@ }, { "name": "symfony/finder", - "version": "v4.4.19", + "version": "v4.4.24", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "25d79cfccfc12e84e7a63a248c3f0720fdd92db6" + "reference": "a96bc19ed87c88eec78e1a4c803bdc1446952983" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/25d79cfccfc12e84e7a63a248c3f0720fdd92db6", - "reference": "25d79cfccfc12e84e7a63a248c3f0720fdd92db6", + "url": "https://api.github.com/repos/symfony/finder/zipball/a96bc19ed87c88eec78e1a4c803bdc1446952983", + "reference": "a96bc19ed87c88eec78e1a4c803bdc1446952983", "shasum": "" }, "require": { @@ -156,7 +106,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v4.4.19" + "source": "https://github.com/symfony/finder/tree/v4.4.24" }, "funding": [ { @@ -172,7 +122,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T09:09:26+00:00" + "time": "2021-05-16T12:27:45+00:00" }, { "name": "xylemical/php-expressions", @@ -1056,21 +1006,21 @@ }, { "name": "league/container", - "version": "2.4.1", + "version": "2.5.0", "source": { "type": "git", "url": "https://github.com/thephpleague/container.git", - "reference": "43f35abd03a12977a60ffd7095efd6a7808488c0" + "reference": "8438dc47a0674e3378bcce893a0a04d79a2c22b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/container/zipball/43f35abd03a12977a60ffd7095efd6a7808488c0", - "reference": "43f35abd03a12977a60ffd7095efd6a7808488c0", + "url": "https://api.github.com/repos/thephpleague/container/zipball/8438dc47a0674e3378bcce893a0a04d79a2c22b3", + "reference": "8438dc47a0674e3378bcce893a0a04d79a2c22b3", "shasum": "" }, "require": { "container-interop/container-interop": "^1.2", - "php": "^5.4.0 || ^7.0" + "php": "^5.4 || ^7.0 || ^8.0" }, "provide": { "container-interop/container-interop-implementation": "^1.2", @@ -1080,7 +1030,9 @@ "orno/di": "~2.0" }, "require-dev": { - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "^4.8.36", + "scrutinizer/ocular": "^1.3", + "squizlabs/php_codesniffer": "^3.5" }, "type": "library", "extra": { @@ -1119,9 +1071,15 @@ ], "support": { "issues": "https://github.com/thephpleague/container/issues", - "source": "https://github.com/thephpleague/container/tree/2.x" + "source": "https://github.com/thephpleague/container/tree/2.5.0" }, - "time": "2017-05-10T09:20:27+00:00" + "funding": [ + { + "url": "https://github.com/philipobenito", + "type": "github" + } + ], + "time": "2021-02-22T09:20:06+00:00" }, { "name": "natxet/cssmin", @@ -1461,21 +1419,21 @@ }, { "name": "php-parallel-lint/php-parallel-lint", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", - "reference": "474f18bc6cc6aca61ca40bfab55139de614e51ca" + "reference": "772a954e5f119f6f5871d015b23eabed8cbdadfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/474f18bc6cc6aca61ca40bfab55139de614e51ca", - "reference": "474f18bc6cc6aca61ca40bfab55139de614e51ca", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/772a954e5f119f6f5871d015b23eabed8cbdadfb", + "reference": "772a954e5f119f6f5871d015b23eabed8cbdadfb", "shasum": "" }, "require": { "ext-json": "*", - "php": ">=5.4.0" + "php": ">=5.3.0" }, "replace": { "grogy/php-parallel-lint": "*", @@ -1484,7 +1442,7 @@ "require-dev": { "nette/tester": "^1.3 || ^2.0", "php-parallel-lint/php-console-highlighter": "~0.3", - "squizlabs/php_codesniffer": "~3.0" + "squizlabs/php_codesniffer": "^3.5" }, "suggest": { "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" @@ -1512,9 +1470,9 @@ "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", "support": { "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", - "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/master" + "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.3.0" }, - "time": "2020-04-04T12:18:32+00:00" + "time": "2021-04-07T14:42:48+00:00" }, { "name": "phpcsstandards/phpcsutils", @@ -1586,27 +1544,22 @@ }, { "name": "psr/container", - "version": "1.0.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.2.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -1619,7 +1572,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common Container Interface (PHP FIG PSR-11)", @@ -1633,22 +1586,22 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" + "source": "https://github.com/php-fig/container/tree/1.1.1" }, - "time": "2017-02-14T16:28:37+00:00" + "time": "2021-03-05T17:36:06+00:00" }, { "name": "psr/log", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", "shasum": "" }, "require": { @@ -1672,7 +1625,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for logging libraries", @@ -1683,22 +1636,22 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.3" + "source": "https://github.com/php-fig/log/tree/1.1.4" }, - "time": "2020-03-23T09:12:05+00:00" + "time": "2021-05-03T11:20:27+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.8", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", "shasum": "" }, "require": { @@ -1741,20 +1694,20 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2020-10-23T02:01:07+00:00" + "time": "2021-04-09T00:54:41+00:00" }, { "name": "symfony/console", - "version": "v4.4.19", + "version": "v4.4.24", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "24026c44fc37099fa145707fecd43672831b837a" + "reference": "1b15ca1b1bedda86f98064da9ff5d800560d4c6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/24026c44fc37099fa145707fecd43672831b837a", - "reference": "24026c44fc37099fa145707fecd43672831b837a", + "url": "https://api.github.com/repos/symfony/console/zipball/1b15ca1b1bedda86f98064da9ff5d800560d4c6d", + "reference": "1b15ca1b1bedda86f98064da9ff5d800560d4c6d", "shasum": "" }, "require": { @@ -1814,7 +1767,7 @@ "description": "Eases the creation of beautiful and testable command line interfaces", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/console/tree/v4.4.19" + "source": "https://github.com/symfony/console/tree/v4.4.24" }, "funding": [ { @@ -1830,11 +1783,11 @@ "type": "tidelift" } ], - "time": "2021-01-27T09:09:26+00:00" + "time": "2021-05-13T06:28:07+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.4.19", + "version": "v4.4.20", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -1897,7 +1850,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v4.4.19" + "source": "https://github.com/symfony/event-dispatcher/tree/v4.4.20" }, "funding": [ { @@ -1996,16 +1949,16 @@ }, { "name": "symfony/filesystem", - "version": "v4.4.19", + "version": "v4.4.22", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "83a6feed14846d2d9f3916adbaf838819e4e3380" + "reference": "f0f06656a18304cdeacb2c4c0113a2b78a2b4c2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/83a6feed14846d2d9f3916adbaf838819e4e3380", - "reference": "83a6feed14846d2d9f3916adbaf838819e4e3380", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/f0f06656a18304cdeacb2c4c0113a2b78a2b4c2a", + "reference": "f0f06656a18304cdeacb2c4c0113a2b78a2b4c2a", "shasum": "" }, "require": { @@ -2038,7 +1991,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v4.4.19" + "source": "https://github.com/symfony/filesystem/tree/v4.4.22" }, "funding": [ { @@ -2054,11 +2007,11 @@ "type": "tidelift" } ], - "time": "2021-01-27T09:09:26+00:00" + "time": "2021-04-01T10:24:12+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -2117,7 +2070,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1" }, "funding": [ { @@ -2137,16 +2090,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13" + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", - "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/5232de97ee3b75b0360528dae24e73db49566ab1", + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1", "shasum": "" }, "require": { @@ -2197,7 +2150,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.1" }, "funding": [ { @@ -2213,11 +2166,11 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -2276,7 +2229,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.22.1" }, "funding": [ { @@ -2296,7 +2249,7 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -2359,7 +2312,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.1" }, "funding": [ { @@ -2379,16 +2332,16 @@ }, { "name": "symfony/process", - "version": "v4.4.19", + "version": "v4.4.22", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "7e950b6366d4da90292c2e7fa820b3c1842b965a" + "reference": "f5481b22729d465acb1cea3455fc04ce84b0148b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/7e950b6366d4da90292c2e7fa820b3c1842b965a", - "reference": "7e950b6366d4da90292c2e7fa820b3c1842b965a", + "url": "https://api.github.com/repos/symfony/process/zipball/f5481b22729d465acb1cea3455fc04ce84b0148b", + "reference": "f5481b22729d465acb1cea3455fc04ce84b0148b", "shasum": "" }, "require": { @@ -2420,7 +2373,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v4.4.19" + "source": "https://github.com/symfony/process/tree/v4.4.22" }, "funding": [ { @@ -2436,7 +2389,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T09:09:26+00:00" + "time": "2021-04-07T16:22:29+00:00" }, { "name": "symfony/service-contracts", @@ -2519,16 +2472,16 @@ }, { "name": "symfony/yaml", - "version": "v4.4.19", + "version": "v4.4.24", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "17ed9f14c1aa05b1a5cf2e2c5ef2d0be28058ef9" + "reference": "8b6d1b97521e2f125039b3fcb4747584c6dfa0ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/17ed9f14c1aa05b1a5cf2e2c5ef2d0be28058ef9", - "reference": "17ed9f14c1aa05b1a5cf2e2c5ef2d0be28058ef9", + "url": "https://api.github.com/repos/symfony/yaml/zipball/8b6d1b97521e2f125039b3fcb4747584c6dfa0ef", + "reference": "8b6d1b97521e2f125039b3fcb4747584c6dfa0ef", "shasum": "" }, "require": { @@ -2570,7 +2523,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v4.4.19" + "source": "https://github.com/symfony/yaml/tree/v4.4.24" }, "funding": [ { @@ -2586,7 +2539,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T09:09:26+00:00" + "time": "2021-05-16T09:52:47+00:00" } ], "aliases": [], diff --git a/hook.php b/hook.php index f7b4bd4b9..a28f219d3 100644 --- a/hook.php +++ b/hook.php @@ -31,9 +31,10 @@ /** * Install all necessary elements for the plugin + * @param array $args ARguments passed from CLI * @return boolean True if success */ -function plugin_formcreator_install() { +function plugin_formcreator_install(array $args = []): bool { spl_autoload_register('plugin_formcreator_autoload'); $version = plugin_version_formcreator(); @@ -41,11 +42,11 @@ function plugin_formcreator_install() { require_once(__DIR__ . '/install/install.php'); $install = new PluginFormcreatorInstall(); if (!$install->isPluginInstalled() - || isset($_SESSION['plugin_formcreator']['cli']) - && $_SESSION['plugin_formcreator']['cli'] == 'force-install') { - return $install->install($migration); + || isset($args['force-install']) + && $args['force-install'] === true) { + return $install->install($migration, $args); } - return $install->upgrade($migration); + return $install->upgrade($migration, $args); } /** diff --git a/install/install.php b/install/install.php index 405c75f4b..84c462bdb 100644 --- a/install/install.php +++ b/install/install.php @@ -73,10 +73,10 @@ class PluginFormcreatorInstall { /** * Install the plugin * @param Migration $migration - * - * @return void + * @param array $args arguments passed to CLI + * @return bool */ - public function install(Migration $migration) { + public function install(Migration $migration, $args = []): bool { $this->migration = $migration; $this->installSchema(); @@ -95,10 +95,13 @@ public function install(Migration $migration) { /** * Upgrade the plugin + * @param Migration $migration + * @param array $args arguments passed to CLI + * @return bool */ - public function upgrade(Migration $migration) { + public function upgrade(Migration $migration, $args = []): bool { $this->migration = $migration; - if (isset($_SESSION['plugin_formcreator']['cli']) && $_SESSION['plugin_formcreator']['cli'] == 'force-upgrade') { + if (isset($args['force-upgrade']) && $args['force-upgrade'] === true) { // Might return false $fromSchemaVersion = array_search(PLUGIN_FORMCREATOR_SCHEMA_VERSION, $this->upgradeSteps); } else { diff --git a/scripts/cliinstall.php b/scripts/cliinstall.php deleted file mode 100644 index c3db2e1ca..000000000 --- a/scripts/cliinstall.php +++ /dev/null @@ -1,158 +0,0 @@ -. - * --------------------------------------------------------------------- - * @copyright Copyright © 2011 - 2021 Teclib' - * @license http://www.gnu.org/licenses/gpl.txt GPLv3+ - * @link https://github.com/pluginsGLPI/formcreator/ - * @link https://pluginsglpi.github.io/formcreator/ - * @link http://plugins.glpi-project.org/#/plugin/formcreator - * --------------------------------------------------------------------- - */ - -(PHP_SAPI == 'cli') or die('Only available from command line'); - -chdir(dirname($_SERVER["SCRIPT_FILENAME"])); - -if (!is_readable(__DIR__ . '/../vendor/autoload.php')) { - echo 'Please run composer install --no-dev in the plugin directory' . PHP_EOL; - exit(1); -} -include (__DIR__ . '/../vendor/docopt/docopt/src/docopt.php'); - -$doc = <<handle($doc); -$args = $args->args; -$pluginName = basename(dirname(__DIR__)); - -$asUser = 'glpi'; -if (isset($args)) { - if (!is_null($args['--as-user'])) { - $asUser = $args['--as-user']; - } - if (isset($args['--tests']) && $args['--tests'] !== false) { - // Use test GLPi's database - // Requires use of cliinstall of GLPI with --tests argument - $glpiConfigDir = $args['--tests']; - define('GLPI_ROOT', dirname(dirname(dirname(__DIR__)))); - define("GLPI_CONFIG_DIR", GLPI_ROOT . "/$glpiConfigDir"); - } -} - -// Prevent problem of execution time -ini_set("max_execution_time", "0"); -ini_set("memory_limit", "-1"); -ini_set("session.use_cookies", "0"); - -include (__DIR__ . "/../../../inc/includes.php"); - -// Init debug variable -$_SESSION['glpi_use_mode'] = Session::DEBUG_MODE; -$_SESSION['glpilanguage'] = "en_GB"; - -Session::loadLanguage(); - -// Only show errors -$CFG_GLPI["debug_sql"] = $CFG_GLPI["debug_vars"] = 0; -$CFG_GLPI["use_log_in_files"] = 1; -ini_set('display_errors', 'On'); -error_reporting(E_ALL | E_STRICT); -//set_error_handler('userErrorHandlerDebug'); - -$DB = new DB(); -if (!$DB->connected) { - die("No DB connection\n"); -} - -$user = new User(); -$user->getFromDBbyName($asUser); -$auth = new Auth(); -$auth->auth_succeded = true; -$auth->user = $user; -Session::init($auth); - -if (!$DB->tableExists("glpi_configs")) { - die("GLPI not installed" . PHP_EOL); -} - -$plugin = new Plugin(); - -// Install the plugin -$plugin->checkStates(true); -if (!$plugin->getFromDBbyDir($pluginName)) { - print("Failed : GLPi does not find the plugin" . PHP_EOL); - exit(1); -} -print("Installing Plugin Id: " . $plugin->fields['id'] . " version " . $plugin->fields['version'] . "...\n"); -if ($args['--force-install']) { - $_SESSION["plugin_$pluginName"]['cli'] = 'force-install'; -} -if ($args['--force-upgrade']) { - $_SESSION["plugin_$pluginName"]['cli'] = 'force-upgrade'; -} -ob_start(function($in) { return $in; }); -$plugin->install($plugin->fields['id']); -$log = ob_get_clean(); -if ($log != '') { - print("Messages while installing\n$log"); -} -print("Done" . PHP_EOL); - -// Enable the plugin -print("Activating Plugin..." . PHP_EOL); -if (!$plugin->activate($plugin->fields['id'])) { - print("Activation failed" . PHP_EOL); - foreach ($_SESSION['MESSAGE_AFTER_REDIRECT'] as $level => $messages) { - switch ($level) { - case INFO: - print("INFO: " . implode('\n', $messages)); - break; - case WARNING: - print("WARNING: " . implode('\n', $messages)); - break; - case ERROR: - print("ERROR: " . implode('\n', $messages)); - break; - } - } - exit(1); -} -print("Activation Done" . PHP_EOL); - -//Load the plugin -print("Loading Plugin..." . PHP_EOL); -$plugin->load($pluginName); -print("Load Done..." . PHP_EOL); diff --git a/tests/script-functions.sh b/tests/script-functions.sh index 597040e14..d4e61d499 100644 --- a/tests/script-functions.sh +++ b/tests/script-functions.sh @@ -55,7 +55,7 @@ init_glpi() { plugin_test_upgrade() { mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWD $OLD_DB_NAME < tests/plugin_formcreator_config_2.5.0.sql mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWD $OLD_DB_NAME < tests/plugin_formcreator_empty_2.5.0.sql - php scripts/cliinstall.php --tests $TEST_GLPI_CONFIG_DIR + php ../../bin/console glpi:plugin:install formcreator --username=glpi --config-dir=../../$TEST_GLPI_CONFIG_DIR } # Plugin test