aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--crates/shirabe-php-rpc/php/worker.php5
-rw-r--r--crates/shirabe-php-rpc/src/lib.rs8
-rw-r--r--crates/shirabe/src/command/diagnose_command.rs22
-rw-r--r--crates/shirabe/src/lib.rs8
-rw-r--r--crates/shirabe/tests/command/diagnose_command_test.rs20
5 files changed, 35 insertions, 28 deletions
diff --git a/crates/shirabe-php-rpc/php/worker.php b/crates/shirabe-php-rpc/php/worker.php
index cb2bf48d..d7d8f251 100644
--- a/crates/shirabe-php-rpc/php/worker.php
+++ b/crates/shirabe-php-rpc/php/worker.php
@@ -22,6 +22,11 @@ $dispatch = [
$re->info();
return (string) ob_get_clean();
},
+ 'phpinfo' => static function ($what) {
+ ob_start();
+ phpinfo((int) $what);
+ return (string) ob_get_clean();
+ },
];
$read_exact = static function ($conn, int $len): ?string {
$buf = '';
diff --git a/crates/shirabe-php-rpc/src/lib.rs b/crates/shirabe-php-rpc/src/lib.rs
index d5d1dafa..9ba02629 100644
--- a/crates/shirabe-php-rpc/src/lib.rs
+++ b/crates/shirabe-php-rpc/src/lib.rs
@@ -58,6 +58,14 @@ pub fn get_extension_info(name: &str) -> String {
}
}
+/// PHP `phpinfo($what)` output, captured via `ob_start()`/`ob_get_clean()`.
+pub fn get_phpinfo(what: i64) -> String {
+ match call("phpinfo", &what.to_string()) {
+ PhpMixed::String(s) => s,
+ other => panic!("PHP RPC: `phpinfo` did not return a string: {other:?}"),
+ }
+}
+
/// PHP `phpversion($extension)`.
pub fn phpversion(extension: &str) -> Option<String> {
match call("phpversion", extension) {
diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs
index d726efd4..13fe8294 100644
--- a/crates/shirabe/src/command/diagnose_command.rs
+++ b/crates/shirabe/src/command/diagnose_command.rs
@@ -44,8 +44,8 @@ use shirabe_php_shim::{
PHP_BINARY, PHP_EOL, PHP_VERSION, PHP_VERSION_ID, PHP_WINDOWS_VERSION_BUILD, PhpMixed, defined,
disk_free_space, extension_loaded, file_exists, filter_var_boolean, function_exists,
get_class_err, hash, implode, ini_get, ioncube_loader_iversion, ioncube_loader_version,
- is_array, is_string, ob_get_clean, ob_start, php_regex, phpinfo, rtrim, str_contains,
- str_replace, str_starts_with, strpos, strstr, strtolower, trim, version_compare,
+ is_array, is_string, php_regex, rtrim, str_contains, str_replace, str_starts_with, strpos,
+ strstr, strtolower, trim, version_compare,
};
#[derive(Debug)]
@@ -1170,19 +1170,13 @@ impl DiagnoseCommand {
warnings.insert("zlib".to_string(), PhpMixed::Bool(true));
}
- ob_start();
- phpinfo(INFO_GENERAL);
- let phpinfo_str = ob_get_clean();
+ let phpinfo_str = shirabe_php_rpc::get_phpinfo(INFO_GENERAL);
let mut phpinfo_match: IndexMap<CaptureKey, String> = IndexMap::new();
- if phpinfo_str.is_some()
- && Preg::is_match3(
- php_regex!(
- "{Configure Command(?: *</td><td class=\"v\">| *=> *)(.*?)(?:</td>|$)}m"
- ),
- phpinfo_str.as_ref().unwrap(),
- Some(&mut phpinfo_match),
- )
- {
+ if Preg::is_match3(
+ php_regex!("{Configure Command(?: *</td><td class=\"v\">| *=> *)(.*?)(?:</td>|$)}m"),
+ &phpinfo_str,
+ Some(&mut phpinfo_match),
+ ) {
let configure = phpinfo_match
.get(&CaptureKey::ByIndex(1))
.cloned()
diff --git a/crates/shirabe/src/lib.rs b/crates/shirabe/src/lib.rs
index b5e58d08..4d17f6c6 100644
--- a/crates/shirabe/src/lib.rs
+++ b/crates/shirabe/src/lib.rs
@@ -182,10 +182,10 @@ mod cli_tests {
run_config => "config",
run_create_project => "create-project",
run_depends => "depends",
- #[ignore = "DiagnoseCommand::check_platform captures phpinfo() via ob_start()/ob_get_clean(), \
- which are todo!() in shirabe-php-shim (PHP output buffering and runtime \
- introspection are unmodeled), so the command panics; same root cause as \
- tests/command/diagnose_command_test.rs"]
+ #[ignore = "DiagnoseCommand::check_http passes &config.borrow() into a call chain that \
+ reaches CurlDownloader::download, which then does self.config.borrow_mut() on \
+ the same Config RefCell, panicking with 'RefCell already borrowed'; same root \
+ cause as tests/command/diagnose_command_test.rs"]
run_diagnose => "diagnose",
run_dump_autoload => "dump-autoload",
run_exec => "exec",
diff --git a/crates/shirabe/tests/command/diagnose_command_test.rs b/crates/shirabe/tests/command/diagnose_command_test.rs
index 95c713ff..521cea84 100644
--- a/crates/shirabe/tests/command/diagnose_command_test.rs
+++ b/crates/shirabe/tests/command/diagnose_command_test.rs
@@ -7,11 +7,11 @@ use shirabe_php_shim::PhpMixed;
#[test]
#[serial]
-#[ignore = "DiagnoseCommand::check_platform captures phpinfo() via ob_start()/ob_get_clean(), \
- which are todo!() in shirabe-php-shim (PHP output buffering and runtime introspection \
- are unmodeled), so the command panics before producing output; beyond that, diagnose \
- checks live http/https connectivity to packagist and the github.com rate limit, so the \
- test also requires real network access (as the PHP original does)"]
+#[ignore = "DiagnoseCommand::check_http passes &config.borrow() into a call chain that reaches \
+ CurlDownloader::download, which then does self.config.borrow_mut() on the same \
+ Config RefCell, panicking with 'RefCell already borrowed'; beyond that, diagnose checks \
+ live http/https connectivity to packagist and the github.com rate limit, so the test \
+ also requires real network access (as the PHP original does)"]
fn test_cmd_fail() {
let tear_down = init_temp_composer(
Some(&serde_json::json!({ "name": "foo/bar", "description": "test pkg" })),
@@ -51,11 +51,11 @@ Checking github.com rate limit: "
#[test]
#[serial]
-#[ignore = "DiagnoseCommand::check_platform captures phpinfo() via ob_start()/ob_get_clean(), \
- which are todo!() in shirabe-php-shim (PHP output buffering and runtime introspection \
- are unmodeled), so the command panics before producing output; beyond that, diagnose \
- checks live http/https connectivity to packagist and the github.com rate limit, so the \
- test also requires real network access (as the PHP original does)"]
+#[ignore = "DiagnoseCommand::check_http passes &config.borrow() into a call chain that reaches \
+ CurlDownloader::download, which then does self.config.borrow_mut() on the same \
+ Config RefCell, panicking with 'RefCell already borrowed'; beyond that, diagnose checks \
+ live http/https connectivity to packagist and the github.com rate limit, so the test \
+ also requires real network access (as the PHP original does)"]
fn test_cmd_success() {
let tear_down = init_temp_composer(
Some(&serde_json::json!({