[英]setlocale() has been disabled for security reasons
PHP 7.4.16 (ZTS) 安裝了parallel
擴展,運行 Laravel 7。
ini_get('disable_functions');
返回一個空字符串。
我可以編寫一個從主進程調用setlocal(0,0)
的腳本,它可以正常工作而不會引發異常。 當庫嘗試從parallel/Runtime
線程中調用它時會引發此錯誤。
$disabled = ini_get('disable_functions'); // empty string
//works
setlocale(0,0);
$thread = new \parallel\Runtime(app_path().'/../bootstrap/parallel.php');
$future = $thread->run(function() {
$disabled = ini_get('disable_functions'); // empty string
// throws setlocale() has been disabled for security reasons
setlocale(0, 0);
});
var_dump([
'value' => $future->value(),
'cancelled' => $future->cancelled(),
'done' => $future->done(),
]);
我已經轉儲了parallel\\Runtime
線程內部和外部的所有 ini 設置。 它們完全匹配並且該功能未標記為禁用。
編譯時指令是否以某種方式禁用了此功能?
這里的問題出在我的引導程序/自動加載功能中。 原來是這樣做的
<?php
require __DIR__ . '/autoload.php';
/** @var \Illuminate\Foundation\Application $app */
$app = require __DIR__.'/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
return $app;
\\Illuminate\\Contracts\\Console\\Kernel->bootstrap()
以某種方式破壞了 setlocale(),即使它沒有設置 ini_set()。 我還沒有在調試中通過它來確定。
工作引導程序代碼是
<?php
require __DIR__ . '/autoload.php';
/** @var \Illuminate\Foundation\Application $app */
$app = require __DIR__.'/app.php';
$app->register(\App\Providers\AppServiceProvider::class)
->runningInThread(true);
return $app;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.