指定了非法的长度修饰符

Illegal length modifier specified

当我在清除站点缓存后尝试加载几个不同的管理页面时,我的 Drupal 8 站点开始出现此错误。

Fatal error: Illegal length modifier specified 'f' in s[np]printf call in /public_html/mysite.com/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php on line 88

有问题的代码行是以下代码段中的最后一行。

// Move the temporary file into the proper directory. Note that POSIX
// compliant systems as well as modern Windows perform the rename operation
// atomically, i.e. there is no point at which another process attempting to
// access the new path will find it missing.
$directory = $this->getContainingDirectoryFullPath($name);
$this->ensureDirectory($directory);
$full_path = $this->getFullPath($name, $directory, $mtime);
$result = rename($temporary_path, $full_path);

我记录了php重命名函数

中使用的变量
$temporary_path = sites/default/files/php/twig/.Lmc1W8Ah3a0Ti25OSi6EWRhRrak
$full_path = sites/default/files/php/twig/5eb6d88f951ea_input.html.twig_BDyoxtSNo6EAtdqLkk7vWqrEZ/Y3dUT4hvb70S6IlToElkUoP3liser_VNlYRsxFliuEg.php

MTimeProtectedFastFileStorage.php 文件中的 rename() 函数是 Drupal 缓存系统的一部分。清除站点缓存后,Drupal 会根据需要在页面加载时重建这些 php twig 缓存文件。

rename() 函数在页面加载崩溃并显示 spprintf "Fatal error: Illegal length modifier specified 'f'" php_error 消息之前成功地在正确的目录中创建了 $full_path twig 文件。 php_error 消息代码生成于第 741 行

https://github.com/php/php-src/blob/master/main/spprintf.c

fmt_error:
php_error(E_ERROR, "Illegal length modifier specified '%c' in s[np]printf call", *fmt);
/*
* The default case is for unrecognized %'s.
* We print %<char> to help the user identify what
* option is not understood.

我不确定在 rename() 文件更改过程中 php spprintf 字符串格式化函数会在哪里被调用。经过一些测试,我认为该问题与文件字符长度、非法字符或文件权限无关。

每次刷新页面时,都会在抛出 spprintf php_error 之前成功创建一个新的 twig 文件。在多次页面刷新后,php_error 问题将停止,其余的 twig 缓存文件将被创建而不会出现任何进一步的问题。

我不确定如何测试内部 php 错误,也不确定 "Illegal length modifier specified 'f'" 在 spprintf.c 文件中指的是什么。任何对此问题的见解将不胜感激。

我不确定问题出在哪里,但切换到 PHP 7.4 后问题就消失了。我是 运行 PHP 7.4.8,我不再遇到这个问题。