We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents eda2cd4 + fe0eb54 commit 134b0a9Copy full SHA for 134b0a9
1 file changed
src/Magic.php
@@ -252,7 +252,17 @@ public static function start(bool $light): void
252
self::$isIpcWorker = \defined('MADELINE_WORKER_TYPE') ? MADELINE_WORKER_TYPE === 'madeline-ipc' : false;
253
// Important, obtain root relative to caller script
254
$backtrace = debug_backtrace(0);
255
- self::$script_cwd = self::$cwd = \dirname(end($backtrace)['file']);
+
256
+ $last_entry = end($backtrace);
257
+ $_cwd = '/tmp';
258
+ if (array_key_exists('file', $last_entry))
259
+ $_cwd = \dirname($last_entry['file']);
260
+ else {
261
+ if (preg_match('/^\{closure\:(.+?)\:/ui', $last_entry['function'], $m))
262
+ $_cwd = \dirname($m[1]);
263
+ }
264
265
+ self::$script_cwd = self::$cwd = $_cwd;
266
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
267
try {
268
error_reporting(E_ALL);
0 commit comments