Hello,
I’m trying to understand the NextCloud code a bit. I would like to see the sequence of method calls and php scripts that get used/executed when I run this command from the CLI:
sudo -u www-data php /var/www/nextcloud/occ files:scan --all
I guess there are lots of ways to do this such as debugging in an IDE but from googling I figure you can capture and log a trace of the call stack quite easily with something like this:
$e = new Exception;
error_log(var_export($e->getTraceAsString(), true));
And here is the technique fleshed out a bit more:
function test() {
throw new Exception;
}
try {
test();
} catch(Exception $e) {
error_log(var_export($e->getTraceAsString(), true));
}
?>
My Question:
Where do I put that bit of code so I can trigger the exception to log the call stack?
So far I found out that running the command php occ files:scan
would start off in the Nextcloud install dir in the web server in a file called: occ
<?php
//$argv = $_SERVER['argv'];
require_once __DIR__ . '/console.php';
And this is an excerpt from console.php…
..
...
....
$application = new Application(
\OC::$server->getConfig(),
\OC::$server->getEventDispatcher(),
\OC::$server->getRequest(),
\OC::$server->get(\Psr\Log\LoggerInterface::class),
\OC::$server->query(\OC\MemoryInfo::class)
);
$application->loadCommands(new ArgvInput(), new ConsoleOutput());
$application->run();
}catch (Exception $ex) {
exceptionHandler($ex);
} catch (Error $ex) {
exceptionHandler($ex);
}
Does anyone know where I plug in my bit of code e.g: throw new Exception;
to trigger the exception then catch it so I can log the call stack when I execute the command occ files:scan
?
Thank you,
Flex