Skip to content

Conversation

@jtojnar
Copy link
Member

@jtojnar jtojnar commented Dec 25, 2021

Tracy produces much nicer error messages and allows us to get rid of F3.

The version supporting PHP 5.6 unfortunately produces warnings on PHP 8.0. Also until Tracy 2.9 (for PHP 7.3+) starts a session, which conflicts with session_set_cookie_params.

  • we need to convince tracy to log even in dev mode – likely by subclassing
  • Find out why ajax requests do not appear in tracy panel seems to work with 2.9
  • integrate PDO into tracy panel can be done later

@netlify
Copy link

netlify bot commented Dec 24, 2025

Deploy Preview for selfoss canceled.

Name Link
🔨 Latest commit 34fff94
🔍 Latest deploy log https://app.netlify.com/projects/selfoss/deploys/694c997e6be7d100080e079f

Once we switch to Tracy, it would show a error 500 screen that would instruct user to set up a debug mode. But when the `Configuration` throws an exception, we have no way to determine the `Configuration->debug` property.

Let’s end early with a boot error instead of relying on Tracy catching the exception.

Nothing else in the file should throw either.
It offers much nicer error traces and the code is significantly cleaner.

This was the last thing we used F3 framework for.
Now we are officially fat-free-free.

So long and thanks for all the fish.
This already existed in 2.19 but was not documented.
@jtojnar jtojnar marked this pull request as ready for review December 25, 2025 01:56
@jtojnar jtojnar added this to the 2.20 milestone Dec 25, 2025
@jtojnar
Copy link
Member Author

jtojnar commented Dec 25, 2025

Okay, I went over the code again and re-tested it and it appears to work as expected:

  • When accessing an endpoint
    • unless non-HTML Content-type header is sent:
      • with debug=1, debugging bluescreen is shown
      • with debug=0, error 500 is shown
        • if log file is not writeable, the !$logged variant of the message will be shown
    • otherwise, error 500 with empty body is sent
  • when running cliupdate.php
    • with debug=1, trace is shown
    • with debug=0, only error message is shown and user is prompted to see logs
Exception throwing patch

The relevant hunk was applied when testing individual endpoint/script:

diff --git a/cliupdate.php b/cliupdate.php
index 19bcbaac..795e91f1 100644
--- a/cliupdate.php
+++ b/cliupdate.php
@@ -12,6 +12,7 @@ require __DIR__ . '/src/common.php';
 $loader = $container->get(helpers\ContentLoader::class);
 $updateVisitor = new class implements UpdateVisitor {
     public function started(int $count): void {
+        throw new Exception('CLI error');
     }
 
     public function sourceUpdated(): void {
diff --git a/src/controllers/About.php b/src/controllers/About.php
index 0a3847be..3d806faa 100644
--- a/src/controllers/About.php
+++ b/src/controllers/About.php
@@ -24,6 +24,7 @@ final readonly class About {
      * json
      */
     public function about(): never {
+        throw new \Exception('API error');
         $wallabag = !empty($this->configuration->wallabag) ? [
             'url' => $this->configuration->wallabag, // string
             'version' => $this->configuration->wallabagVersion, // int
diff --git a/src/controllers/Index.php b/src/controllers/Index.php
index 4c862037..1b6d7f81 100644
--- a/src/controllers/Index.php
+++ b/src/controllers/Index.php
@@ -39,6 +39,7 @@ final readonly class Index {
         $options = $_GET;
 
         if (!$this->view->isAjax()) {
+            throw new \Exception('HTML error');
             $home = BASEDIR . '/public/index.html';
             if (!file_exists($home) || ($homeData = file_get_contents($home)) === false) { // For PHPStan: Error will be already handled by global error handler.
                 http_response_code(500);
@@ -54,6 +55,7 @@ final readonly class Index {
 
         $this->authentication->ensureCanRead();
 
+        throw new \Exception('AJAX error');
         // load tags
         $tags = $this->tagsDao->getWithUnread();
 

@jtojnar jtojnar merged commit 34fff94 into master Dec 25, 2025
12 checks passed
@jtojnar jtojnar deleted the tracy branch December 25, 2025 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants