mirror of
https://github.com/kuaifan/dootask.git
synced 2026-06-24 08:12:36 +00:00
巡检全量 323 接口 + laravel.log PHP 致命异常普查发现: - Base::getSchemeAndHost(): 非请求上下文(Task/导出闭包)request() 非 Request 实例,调 getHttpHost() 致命错误(导出超期任务等)。加 instanceof 守卫。 - FileController::office__token(): php-jwt v7 强制 array payload, config 缺失为 null 触发 TypeError。校验为数组,否则 retError。 - DialogController::msg__translation(): 空 language 传入 Doo::getLanguages(bool|string) 触发 TypeError。前置拦截空值。 - InvokeController: 动态路由改为仅暴露 public 方法,protected/private 视为内部方法返回 404,堵住内部辅助方法被裸访问触发 ArgumentCountError。 - ApproveController: 6 个内部辅助方法(getProcessById 等)收敛为 protected。 验证: 复扫 323 接口 0 个 5xx,phpstan 无错误,真 public 端点回归正常。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
||
|
||
namespace App\Http\Controllers;
|
||
|
||
use App\Module\Base;
|
||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||
use Illuminate\Routing\Controller as BaseController;
|
||
use Request;
|
||
|
||
class InvokeController extends BaseController
|
||
{
|
||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||
|
||
/**
|
||
* @param $method
|
||
* @param string $action
|
||
* @return array|void
|
||
*/
|
||
public function __invoke($method, $action = '')
|
||
{
|
||
$app = $method ?: 'main';
|
||
if ($action) {
|
||
$app .= "__" . $action;
|
||
}
|
||
// 接口不存在(仅 public 方法可作为端点,protected/private 为内部方法,不暴露为路由)
|
||
if (!method_exists($this, $app) || !(new \ReflectionMethod($this, $app))->isPublic()) {
|
||
$msg = "404 not found (" . str_replace("__", "/", $app) . ").";
|
||
return Base::ajaxError($msg);
|
||
}
|
||
//
|
||
$res = $this->__before($method, $action);
|
||
if ($res === true || Base::isSuccess($res)) {
|
||
return $this->$app();
|
||
} else {
|
||
return is_array($res) ? $res : Base::ajaxError($res);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @param $method
|
||
* @param $action
|
||
* @return bool|array|string
|
||
*/
|
||
public function __before($method, $action)
|
||
{
|
||
return true;
|
||
}
|
||
}
|