簡體   English   中英

出於安全原因已禁用 setlocale()

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM