Browse Source

refactor(phpinfo): 移除 PHPInfo 模块中的 Hook 和中间件实现

- 删除了 PhpinfoHook 类及其 HttpRun 事件监听功能
- 移除了 AppendSqlDebugMiddleware 中间件类
- 清理了数据库查询日志调试功能的相关代码
- 移除了将 SQL 日志附加到响应数据的逻辑
runphp 1 month ago
parent
commit
496af7f8e0
2 changed files with 0 additions and 58 deletions
  1. 0 23
      src/Hook/PhpinfoHook.php
  2. 0 35
      src/Middleware/AppendSqlDebugMiddleware.php

+ 0 - 23
src/Hook/PhpinfoHook.php

@@ -1,23 +0,0 @@
-<?php
-declare(strict_types=1);
-
-namespace SixShop\PHPInfo\Hook;
-
-use SixShop\Core\Attribute\Hook;
-use SixShop\PHPInfo\Middleware\AppendSqlDebugMiddleware;
-use think\App;
-use think\event\HttpRun;
-
-class PhpinfoHook
-{
-
-    public function __construct(private App $app)
-    {
-
-    }
-    #[Hook(HttpRun::class)]
-    public function appendSqlDebug(): void
-    {
-        $this->app->middleware->add(AppendSqlDebugMiddleware::class);
-    }
-}

+ 0 - 35
src/Middleware/AppendSqlDebugMiddleware.php

@@ -1,35 +0,0 @@
-<?php
-declare(strict_types=1);
-
-namespace SixShop\PHPInfo\Middleware;
-
-use Closure;
-use think\DbManager;
-use think\Request;
-use think\Response;
-
-
-class AppendSqlDebugMiddleware
-{
-    private array $logList = [];
-
-    public function __construct(private readonly DbManager $dbManager)
-    {
-        $this->dbManager->setLog(function (string $type, string $log) {
-            $this->logList[] = $log;
-        });
-    }
-
-    public function handle(Request $request, Closure $next): Response
-    {
-        $response = $next($request);
-        if ($response instanceof Response && is_array($data = $response->getData())) {
-            $data['sql'] = $this->logList;
-            if (!empty($data['sql'])) {
-                $response->data($data);
-            }
-        }
-
-        return $response;
-    }
-}