Exception while creating PDO object

Hi everyone,

I have an issue with my ttrss instance very similar to the one encountered in this post : [SyntaxError: JSON parse: unexpected character at line 1 column 1 of the JSON data]

(Sorry I can’t add links to post but it’s on this forum by user Louis on Feb,14 2019)

Everything worked fine but this afternoon I went to my ttrss an I got this unhandled exception :

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 5771 of the JSON data

Stack trace:

backendSanityCallback@domain/tt-rss/js/AppBase.js?1552979839:296:18
constructor/<@domain/tt-rss/js/tt-rss.js?1552979839:89:8
onComplete@domain/tt-rss/js/common.js?1552979837:26:32
respondToReadyState@domain/tt-rss/lib/prototype.js?1552979845:1827:8
onStateChange@domain/tt-rss/lib/prototype.js?1552979845:1756:7

Like the other user I cannot access my administration panel nor my prefs.php page.

I tried changing LOG_DESTINATION to blank and syslog but everything seems normal.

The only other error message I get is when I do a sanity check : domain/tt-rss/backend.php?op=rpc&subop=sanityCheck

Exception while creating PDO object:Cannot modify header information - headers already sent by (output started at /home/userfolder/www/private/tt-rss/classes/rpc.php:330)

I guess the problem is related to my database but I can’t figure out what’s going on.

Platform versions :

  • PHP : 7.0
  • MYSQL 5.6
  • OS : Linux
  • Hosting: shared

Thanks!

the problem with shared hosting is that its impossible to tell what kind of shit they may pull at any given moment

try dropping this (as a file, something like db-check.php) in tt-rss directory and open it with your browser

<?php
        require_once "config.php";
        require_once "classes/db.php";

        $pdo = Db::pdo();

        var_dump($pdo);

I agree but it’s hosted at OVH and I kind of trust them :wink:

Here is the result :

object(PDO)#2 (0) { }

well, PDO object is created successfully with your tt-rss settings. i’m afraid i have no idea why it doesn’t work within tt-rss itself.

Ok, thanks for you help :wink: .

Is there a way I can programmatically export an opml file for a future reinstall?

since you can’t open tt-rss i think a better idea would be dumping your entire database for safekeeping. you can use import it later instead of OPML.

i don’t think a reinstall would help though. maybe you should contact your webhosting first.

Thanks I’ll look into it.

Out of curiosity, I checked for console error on page load and noticed two things.

The initial error

SyntaxError: “JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 5771 of the JSON data”

is triggered because by a < pre > tag in the reply object

},"runtime-info":{"max_feed_id":81,"num_feeds":78,"cdm_expanded":false,"labels":[]}}<pre>Exception while creating PDO object:Cannot modify header information - headers already sent by (output started at /home/folder/www/private/tt-rss/classes/rpc.php:330)</pre>

And this error log on AppBase.js line 422

[Error.report] log response {“error”:{“code”:6,“message”:“Request not authorized.”}}

What is the correlation between malformed JSON and a “Request not authorized” error message?

the only thing of value that you should somehow get is contents of that PDO exception

any other errors are pointless to discuss because tt-rss can’t talk to the database so obviously nothing works

you can also try commenting this line in classes/db.php:68:

$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
which might force PDO to show some error message when you open index.php or maybe log something to http error log.

You can try to add
php_flag output_buffering On
to .htaccess file and see, if that helps to see actual error (assuming Apache).

No change…

500 Internal Server Error

PHP doesn’t seem to be running as an Apache module.

“GET /tt-rss/ HTTP/1.1” 500 551 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0”

I think it’s the end of the road… I’ll contact my host this afternoon and post an update.

Thanks again for your help!

that’s the access log, there should be a separate error log somewhere

should have started with that tbh

I know but my error log is empty.

EDIT: log are delayed my bad.

[Thu Apr 04 12:38:18 2019] [alert] [client IP] [host domain] /homez.36/folder/www/private/tt-rss/.htaccess: Invalid command ‘php_flag’, perhaps misspelled or defined by a module not included in the server configuration

Ok, without mod_php php_flag does not work. What confuses me, is the location of already sent output in original error. Otherwise I would suspect something in config.php before opening <?php tag. But configuring php with output buffering (if possible) is worth trying.