From 612088bef27418fb6f05fd913aed69c97e381c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 4 Jul 2024 16:11:05 +0200 Subject: [PATCH] feat: Add reserved options in a new OCP class so that applications know about them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../BeforeMessageLoggedEventListener.php | 7 +++--- lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + lib/public/Console/ReservedOptions.php | 24 +++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 lib/public/Console/ReservedOptions.php diff --git a/core/Listener/BeforeMessageLoggedEventListener.php b/core/Listener/BeforeMessageLoggedEventListener.php index a0581f25830..ef771ca0a81 100644 --- a/core/Listener/BeforeMessageLoggedEventListener.php +++ b/core/Listener/BeforeMessageLoggedEventListener.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace OC\Core\Listener; +use OCP\Console\ReservedOptions; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventListener; @@ -54,10 +55,10 @@ class BeforeMessageLoggedEventListener implements IEventListener { $argv = $_SERVER['argv']; $level = 0; foreach ($argv as $key => $arg) { - if ($arg === '--debug-log') { + if ($arg === '--'.ReservedOptions::DEBUG_LOG) { unset($argv[$key]); - } elseif (str_starts_with($arg, '--debug-log-level=')) { - $level = (int)substr($arg, strlen('--debug-log-level=')); + } elseif (str_starts_with($arg, '--'.ReservedOptions::DEBUG_LOG_LEVEL.'=')) { + $level = (int)substr($arg, strlen('--'.ReservedOptions::DEBUG_LOG_LEVEL.'=')); unset($argv[$key]); } } diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 322bae15fae..ffd17837407 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -220,6 +220,7 @@ return array( 'OCP\\Config\\BeforePreferenceDeletedEvent' => $baseDir . '/lib/public/Config/BeforePreferenceDeletedEvent.php', 'OCP\\Config\\BeforePreferenceSetEvent' => $baseDir . '/lib/public/Config/BeforePreferenceSetEvent.php', 'OCP\\Console\\ConsoleEvent' => $baseDir . '/lib/public/Console/ConsoleEvent.php', + 'OCP\\Console\\ReservedOptions' => $baseDir . '/lib/public/Console/ReservedOptions.php', 'OCP\\Constants' => $baseDir . '/lib/public/Constants.php', 'OCP\\Contacts\\ContactsMenu\\IAction' => $baseDir . '/lib/public/Contacts/ContactsMenu/IAction.php', 'OCP\\Contacts\\ContactsMenu\\IActionFactory' => $baseDir . '/lib/public/Contacts/ContactsMenu/IActionFactory.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 2334c0bb7e8..4ca6c0d0a9b 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -253,6 +253,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Config\\BeforePreferenceDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/Config/BeforePreferenceDeletedEvent.php', 'OCP\\Config\\BeforePreferenceSetEvent' => __DIR__ . '/../../..' . '/lib/public/Config/BeforePreferenceSetEvent.php', 'OCP\\Console\\ConsoleEvent' => __DIR__ . '/../../..' . '/lib/public/Console/ConsoleEvent.php', + 'OCP\\Console\\ReservedOptions' => __DIR__ . '/../../..' . '/lib/public/Console/ReservedOptions.php', 'OCP\\Constants' => __DIR__ . '/../../..' . '/lib/public/Constants.php', 'OCP\\Contacts\\ContactsMenu\\IAction' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IAction.php', 'OCP\\Contacts\\ContactsMenu\\IActionFactory' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IActionFactory.php', diff --git a/lib/public/Console/ReservedOptions.php b/lib/public/Console/ReservedOptions.php new file mode 100644 index 00000000000..aff7a7daa3a --- /dev/null +++ b/lib/public/Console/ReservedOptions.php @@ -0,0 +1,24 @@ +