Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Improved performance of LoggerDataCollector #29762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improved performance of LoggerDataCollector
  • Loading branch information
javiereguiluz authored and fabpot committed Jan 6, 2019
commit 3b8d6d19ec3f0655bf400bdc7c0e82b10165147c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function lateCollect()
if (null !== $this->logger) {
$containerDeprecationLogs = $this->getContainerDeprecationLogs();
$this->data = $this->computeErrorsCount($containerDeprecationLogs);
$this->data['compiler_logs'] = $this->getContainerCompilerLogs();
// get compiler logs later (only when they are needed) to improve performance
$this->data['compiler_logs'] = array();
$this->data['compiler_logs_filepath'] = $this->containerPathPrefix.'Compiler.log';
$this->data['logs'] = $this->sanitizeLogs(array_merge($this->logger->getLogs($this->currentRequest), $containerDeprecationLogs));
$this->data = $this->cloneVar($this->data);
}
Expand Down Expand Up @@ -110,7 +112,7 @@ public function countScreams()

public function getCompilerLogs()
{
return isset($this->data['compiler_logs']) ? $this->data['compiler_logs'] : array();
return $this->cloneVar($this->getContainerCompilerLogs($this->data['compiler_logs_filepath'] ?? null));
}

/**
Expand Down Expand Up @@ -143,14 +145,14 @@ private function getContainerDeprecationLogs()
return $logs;
}

private function getContainerCompilerLogs()
private function getContainerCompilerLogs(?string $compilerLogsFilepath = null): array
{
if (null === $this->containerPathPrefix || !file_exists($file = $this->containerPathPrefix.'Compiler.log')) {
if (!file_exists($compilerLogsFilepath)) {
return array();
}

$logs = array();
foreach (file($file, FILE_IGNORE_NEW_LINES) as $log) {
foreach (file($compilerLogsFilepath, FILE_IGNORE_NEW_LINES) as $log) {
$log = explode(': ', $log, 2);
if (!isset($log[1]) || !preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)++$/', $log[0])) {
$log = array('Unknown Compiler Pass', implode(': ', $log));
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.