mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 21:19:58 +09:00
Update to laravel 7
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Symfony\Component\HttpKernel\CacheWarmer;
|
||||
*/
|
||||
abstract class CacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
protected function writeCacheFile($file, $content)
|
||||
protected function writeCacheFile(string $file, $content)
|
||||
{
|
||||
$tmpFile = @tempnam(\dirname($file), basename($file));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
|
||||
@@ -26,6 +26,9 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
private $optionalsEnabled = false;
|
||||
private $onlyOptionalsEnabled = false;
|
||||
|
||||
/**
|
||||
* @param iterable<mixed, CacheWarmerInterface> $warmers
|
||||
*/
|
||||
public function __construct(iterable $warmers = [], bool $debug = false, string $deprecationLogsFilepath = null)
|
||||
{
|
||||
$this->warmers = $warmers;
|
||||
@@ -44,27 +47,24 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Warms up the cache.
|
||||
*
|
||||
* @param string $cacheDir The cache directory
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function warmUp($cacheDir)
|
||||
public function warmUp(string $cacheDir): array
|
||||
{
|
||||
if ($this->debug) {
|
||||
if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
|
||||
$collectedLogs = [];
|
||||
$previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL');
|
||||
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
|
||||
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
|
||||
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
|
||||
if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type) {
|
||||
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
|
||||
}
|
||||
|
||||
if (isset($collectedLogs[$message])) {
|
||||
++$collectedLogs[$message]['count'];
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
||||
$backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
||||
// Clean the trace by removing first frames added by the error handler itself.
|
||||
for ($i = 0; isset($backtrace[$i]); ++$i) {
|
||||
if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) {
|
||||
@@ -81,9 +81,12 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
'trace' => $backtrace,
|
||||
'count' => 1,
|
||||
];
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
$preload = [];
|
||||
try {
|
||||
foreach ($this->warmers as $warmer) {
|
||||
if (!$this->optionalsEnabled && $warmer->isOptional()) {
|
||||
@@ -93,28 +96,30 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
$warmer->warmUp($cacheDir);
|
||||
$preload[] = array_values((array) $warmer->warmUp($cacheDir));
|
||||
}
|
||||
} finally {
|
||||
if ($this->debug && true !== $previousHandler) {
|
||||
if ($collectDeprecations) {
|
||||
restore_error_handler();
|
||||
|
||||
if (file_exists($this->deprecationLogsFilepath)) {
|
||||
if (is_file($this->deprecationLogsFilepath)) {
|
||||
$previousLogs = unserialize(file_get_contents($this->deprecationLogsFilepath));
|
||||
$collectedLogs = array_merge($previousLogs, $collectedLogs);
|
||||
if (\is_array($previousLogs)) {
|
||||
$collectedLogs = array_merge($previousLogs, $collectedLogs);
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($this->deprecationLogsFilepath, serialize(array_values($collectedLogs)));
|
||||
}
|
||||
}
|
||||
|
||||
return array_values(array_unique(array_merge([], ...$preload)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this warmer is optional or not.
|
||||
*
|
||||
* @return bool always false
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isOptional()
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ interface CacheWarmerInterface extends WarmableInterface
|
||||
* A warmer should return true if the cache can be
|
||||
* generated incrementally and on-demand.
|
||||
*
|
||||
* @return bool true if the warmer is optional, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function isOptional();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ interface WarmableInterface
|
||||
/**
|
||||
* Warms up the cache.
|
||||
*
|
||||
* @param string $cacheDir The cache directory
|
||||
* @return string[] A list of classes or files to preload on PHP 7.4+
|
||||
*/
|
||||
public function warmUp($cacheDir);
|
||||
public function warmUp(string $cacheDir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user