From bbf33b836026cbe9fb9e7c76291dcb133b7144e2 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 10 Aug 2026 00:57:19 +0900 Subject: feat(xdebug): switch Xdebug off in the PHP worker Composer restarts itself with Xdebug unloaded because Xdebug makes PHP several times slower. Xdebug is never loaded into this process, so what needs dealing with is the PHP worker: it is spawned with `-d xdebug.mode=off` and `XDEBUG_MODE=off` (Xdebug reads the environment variable first and lets it override every ini setting), which makes its module init return before it installs any executor, compile, error or opcode hook. Rewriting the ini files and re-executing, the way xdebug-handler does, would additionally cover Xdebug 2, which hooks unconditionally and has no equivalent setting. That is not worth its machinery here: Xdebug 2 caps out at PHP 7.4, while every PHP version Composer supports can run Xdebug 3. What remains of XdebugHandler is small enough to live beside the worker it governs, so its crate is gone and its callers inline it. isXdebugActive answers false without asking PHP whenever the worker is switched off, so a command that needs no PHP does not spawn one just for the Xdebug warning; diagnose reports what the worker measures instead, which still surfaces an Xdebug that ignores the setting. PlatformRepository has no unloaded extension to restore, since switching the mode off leaves it loaded. COMPOSER_ORIGINAL_INIS is neither written nor read: it exists so a restarted process can name the ini files it replaced, and IniHelper can report the worker's own. IniHelperTest injects through that variable, so none of its cases are ported. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-xdebug-handler/Cargo.toml | 11 -------- crates/shirabe-xdebug-handler/LICENSE | 21 -------------- crates/shirabe-xdebug-handler/src/lib.rs | 3 -- .../shirabe-xdebug-handler/src/xdebug_handler.rs | 32 ---------------------- 4 files changed, 67 deletions(-) delete mode 100644 crates/shirabe-xdebug-handler/Cargo.toml delete mode 100644 crates/shirabe-xdebug-handler/LICENSE delete mode 100644 crates/shirabe-xdebug-handler/src/lib.rs delete mode 100644 crates/shirabe-xdebug-handler/src/xdebug_handler.rs (limited to 'crates/shirabe-xdebug-handler') diff --git a/crates/shirabe-xdebug-handler/Cargo.toml b/crates/shirabe-xdebug-handler/Cargo.toml deleted file mode 100644 index 3deda4ac..00000000 --- a/crates/shirabe-xdebug-handler/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "shirabe-xdebug-handler" -version.workspace = true -edition.workspace = true -rust-version.workspace = true -description = "A Rust port of composer/xdebug-handler" -repository.workspace = true -license.workspace = true - -[lints] -workspace = true diff --git a/crates/shirabe-xdebug-handler/LICENSE b/crates/shirabe-xdebug-handler/LICENSE deleted file mode 100644 index 963618a1..00000000 --- a/crates/shirabe-xdebug-handler/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Composer - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/crates/shirabe-xdebug-handler/src/lib.rs b/crates/shirabe-xdebug-handler/src/lib.rs deleted file mode 100644 index c95f237d..00000000 --- a/crates/shirabe-xdebug-handler/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod xdebug_handler; - -pub use xdebug_handler::*; diff --git a/crates/shirabe-xdebug-handler/src/xdebug_handler.rs b/crates/shirabe-xdebug-handler/src/xdebug_handler.rs deleted file mode 100644 index 6ccedc6a..00000000 --- a/crates/shirabe-xdebug-handler/src/xdebug_handler.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! ref: composer/vendor/composer/xdebug-handler/src/XdebugHandler.php - -#[derive(Debug)] -pub struct XdebugHandler; - -impl XdebugHandler { - pub fn is_xdebug_active() -> bool { - // TODO(php-runtime) - false - } - - pub fn get_skipped_version() -> Option { - // TODO(php-runtime) - // The restart-to-disable-xdebug mechanism is not ported (`is_xdebug_active` is - // hardcoded `false`), so a restart never happens and `self::$skipped` stays at - // its PHP default of `""`. - Some(String::new()) - } - - pub fn get_all_ini_files() -> Vec { - // TODO(php-runtime) - // No XdebugHandler is ever constructed (`self::$name` stays null), because the - // `new XdebugHandler('Composer'); $xdebug->check();` bootstrap in `bin/composer` is not - // ported (see the TODO(phase-c) at the top of shirabe's main.rs), so the - // COMPOSER_ORIGINAL_INIS env-var branch is unreachable here. - // - // Callers that need the real PHP runtime's ini files (php_ini_loaded_file() / - // php_ini_scanned_files()) query shirabe_php_rpc directly instead of going through this - // stub; see IniHelper::get_all in the shirabe crate. - vec![String::new()] - } -} -- cgit v1.3.1-4-g156e