Skip to content
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

update.php #633

Closed
unnikked opened this issue Mar 30, 2015 · 6 comments
Closed

update.php #633

unnikked opened this issue Mar 30, 2015 · 6 comments

Comments

@unnikked
Copy link
Contributor

update.php stopped working from this morning.

:/var/www/selfoss# php5 update.php 
Object of class stdClass could not be converted to string

I cannot track down the bug, even because I have not changed a think on the VPS during the last three months, any of you had a similar issue ?

@niol
Copy link
Collaborator

niol commented Mar 31, 2015

If you did not change anything, this comes from the data (RSS, etc.).

Maybe there is something relevant in data/logs/default.log. If there is not, put the following line in config.ini and try to reproduce. You should get a line number. Then I can workout a fix.

logger_level=DEBUG

@unnikked
Copy link
Contributor Author

I identified the problem, before to explain what happened I post the log entries after php update.php

03-31-15 14:17:28 Debug ---
03-31-15 14:17:28 Debug start fetching source "/r/compsci (id: 92) 
03-31-15 14:17:28 Debug spout successfully loaded: spouts\reddit\reddit2
03-31-15 14:17:28 Debug fetch content

Basically I recently changed the password on reddit. Obviously I forgot that the reddit spout requires username and password so the update process "crashed".

I suggest to implement a user reporting whenever the login fails because on the source section I was not notified by that.

Thank you for helping me.

@niol
Copy link
Collaborator

niol commented Mar 31, 2015

The reddit spout needs fixing for this. From a quick look at the code, it needs to check for login errors, and throw an exception if there is any so that the error can be reported to the user.

Maybe something like the following can help.

diff --git a/spouts/reddit/reddit2.php b/spouts/reddit/reddit2.php
index a2db306..251b32f 100644
--- a/spouts/reddit/reddit2.php
+++ b/spouts/reddit/reddit2.php
@@ -419,6 +419,9 @@ class reddit2 extends \spouts\spout {
         $data = @curl_exec( $ch );
         curl_close( $ch );

+        if( $data === false )
+            throw new exception('Could not get reddit content');
+
         return $data;
     }

@@ -480,11 +483,11 @@ class reddit2 extends \spouts\spout {
         $response = curl_exec($ch);
         $response = json_decode($response);
         if (curl_errno($ch)) {
-            print(curl_error($ch));
+            throw new \exception(curl_error($ch));
         } else {
             curl_close($ch);
             if (count($response->json->errors) > 0){
-                print($response);
+                throw new \exception($response);
             } else {
                 $this->reddit_session = "reddit_session={$response->json->data->cookie}";
                 if (function_exists("apc_store")) {

Unfortunately, I cannot test a possible fix as I do not use this spout.

@unnikked
Copy link
Contributor Author

If you can assign this issue to me, I will try to fix it as soon as possible.

@niol
Copy link
Collaborator

niol commented Mar 31, 2015

Also, while you're at it, you can use getJsonContent() from the github/commits spout which can replace custom usage of curl in the reddit2 spout. This would remove some code duplication.

@niol
Copy link
Collaborator

niol commented May 19, 2015

The new WebClient helper can help you fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants