summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-04-27 10:46:37 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-04-27 10:46:37 +0200
commit1f839796998d2f0656d578c1f0ac19d773100789 (patch)
tree05ac82914f125c1343e1fc00c4e19a06a75cf686 /apps/files
parent5e96228eb1f7999a327dacab22055ec2aa8e28a3 (diff)
downloadnextcloud-server-1f839796998d2f0656d578c1f0ac19d773100789.tar.gz
nextcloud-server-1f839796998d2f0656d578c1f0ac19d773100789.zip
Do not stop at the first PHP error/warning in files:scan
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/lib/Command/Scan.php26
1 files changed, 15 insertions, 11 deletions
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php
index a59665c56e9..fbfc9cbca50 100644
--- a/apps/files/lib/Command/Scan.php
+++ b/apps/files/lib/Command/Scan.php
@@ -204,7 +204,7 @@ class Scan extends Base {
return 1;
}
- $this->initTools();
+ $this->initTools($output);
$user_count = 0;
foreach ($users as $user) {
@@ -236,15 +236,19 @@ class Scan extends Base {
/**
* Initialises some useful tools for the Command
*/
- protected function initTools() {
+ protected function initTools(OutputInterface $output) {
// Start the timer
$this->execTime = -microtime(true);
// Convert PHP errors to exceptions
- set_error_handler([$this, 'exceptionErrorHandler'], E_ALL);
+ set_error_handler(
+ fn (int $severity, string $message, string $file, int $line): bool =>
+ $this->exceptionErrorHandler($output, $severity, $message, $file, $line),
+ E_ALL
+ );
}
/**
- * Processes PHP errors as exceptions in order to be able to keep track of problems
+ * Processes PHP errors in order to be able to show them in the output
*
* @see https://www.php.net/manual/en/function.set-error-handler.php
*
@@ -252,15 +256,15 @@ class Scan extends Base {
* @param string $message
* @param string $file the filename that the error was raised in
* @param int $line the line number the error was raised
- *
- * @throws \ErrorException
*/
- public function exceptionErrorHandler($severity, $message, $file, $line) {
- if (!(error_reporting() & $severity)) {
- // This error code is not included in error_reporting
- return;
+ public function exceptionErrorHandler(OutputInterface $output, int $severity, string $message, string $file, int $line): bool {
+ if (($severity === E_DEPRECATED) || ($severity === E_USER_DEPRECATED)) {
+ // Do not show deprecation warnings
+ return false;
}
- throw new \ErrorException($message, 0, $severity, $file, $line);
+ $e = new \ErrorException($message, 0, $severity, $file, $line);
+ $output->writeln("\t<error>$e</error>");
+ return true;
}
/**