From 54fec63da58efded96050cf67c4db37bb341469b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E9=87=91=E5=8B=87?= Date: Thu, 28 Dec 2023 18:53:42 +0800 Subject: [PATCH] * Fix webroot in cli. --- framework/base/helper.class.php | 6 +++++- module/tree/test/model/createrequirementlink.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/framework/base/helper.class.php b/framework/base/helper.class.php index 22b350c751..896008cbca 100644 --- a/framework/base/helper.class.php +++ b/framework/base/helper.class.php @@ -1168,8 +1168,12 @@ function getWebRoot($full = false) return $http . $_SERVER['HTTP_HOST'] . substr((string) $path, 0, (strrpos((string) $path, '/') + 1)); } - $path = substr((string) $path, 0, (strrpos((string) $path, '/') + 1)); + $pos = strrpos((string) $path, '/'); + if($pos === false) return ''; + + $path = substr((string) $path, 0, ($pos + 1)); $path = str_replace('\\', '/', $path); + return $path; } diff --git a/module/tree/test/model/createrequirementlink.php b/module/tree/test/model/createrequirementlink.php index a2f3ae60e5..c82d1c4cfb 100755 --- a/module/tree/test/model/createrequirementlink.php +++ b/module/tree/test/model/createrequirementlink.php @@ -31,4 +31,4 @@ r($tree->createRequirementLinkTest(2)) && p('url') && e("product-browse-1-all-by r($tree->createRequirementLinkTest(1, 0, $extra1)) && p('url') && e("product-browse-1-1-byModule-1-requirement.html"); // 测试获取module 1 branchID 1 的 requriement link r($tree->createRequirementLinkTest(1, 0, $extra2)) && p('url') && e("projectstory-story-1-0--byModule-1-requirement.html"); // 测试获取module 1 projectID 1 的 requriement link -r($tree->createRequirementLinkTest(1, 0, $extra3)) && p('url') && e("execution-story-1-requirement-order_desc-byModule-1.html"); // 测试获取module 1 executionID 1 的 requriement link +r($tree->createRequirementLinkTest(1, 0, $extra3)) && p('url') && e("execution-story-1-requirement-order_desc-byModule-1.html"); // 测试获取module 1 executionID 1 的 requriement link \ No newline at end of file