ThinkUpLLC / ThinkUp

ThinkUp gives you insights into your social networking activity on Twitter, Facebook, Instagram, and beyond.
http://thinkup.com
GNU General Public License v3.0
3.3k stars 676 forks source link

Undefined property: stdClass::$annotation in plugins/googleplus/model/class.GooglePlusCrawler.php #1405

Closed petdance closed 11 years ago

petdance commented 11 years ago

I now constantly get warnings from my cron job saying:

PHP Warning:  json_encode(): Invalid UTF-8 sequence in argument in /srv/thinkup/_lib/class.DashboardModuleCacher.php on line 225
PHP Notice:  Undefined property: stdClass::$annotation in /srv/thinkup/plugins/googleplus/model/class.GooglePlusCrawler.php on line 210
PHP Notice:  Undefined property: stdClass::$annotation in /srv/thinkup/plugins/googleplus/model/class.GooglePlusCrawler.php on line 210

The line of code in DashboardModuleCacher.php is the return from getHotPostVisualizationData()

        return json_encode(array('rows' => $result_set, 'cols' => $metadata));

The lines of code in GooglePlusCrawler.php are in fetchInstanceUserPosts() and look like:

                } elseif ($item->verb == "share") {
                    $post['post_text'] = $item->annotation;
                    $should_capture_post = true;
                }

Are the warnings related? I don't know.

ginatrapani commented 11 years ago

Would love to see the data coming out of the db that's causing the Invalid UTF-8 sequence error. Any way you could do a print_r on $result_set and $metadata?

petdance commented 11 years ago

Anything magic I need to do besides just kicking off a run from the command line rather than my normal cron job?

ginatrapani commented 11 years ago

Nope, should be able to just do a run from the command line (and capture the output). Thanks for troubleshooting this Andy.

OnTheFenceDevelopment commented 11 years ago

I'm getting the same problem, here is the output from my configuration:

$result_set: 2012-11-09 07:53:25 | 4.4MB | SUCCESS| DilbertDave | TwitterPlugin::crawl,106 | Starting to collect data for DilbertDave on Twitter. $metadata: 2012-11-09 07:53:25 | 4.8MB | INFO | DilbertDave | TwitterAPIAccessorOAuth::__construct,111 | Errors to tolerate: 5

Hope this is useful

petdance commented 11 years ago

Here's one example from DashboardModuleCacher.php

Array
(
    [0] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => Ending the cults of personality in free software http://t.co/6pJGjFKt (The term I use is "hero worsh...
                        )

                    [1] => Array
                        (
                            [v] => 0
                        )

                    [2] => Array
                        (
                            [v] => 1
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

    [1] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => Attention Fox News: You are the #1 news network.  YOU ARE THE MAINSTREAM MEDIA.  http://t.co/QACbd5K...
                        )

                    [1] => Array
                        (
                            [v] => 0
                        )

                    [2] => Array
                        (
                            [v] => 1
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

    [2] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => The NYT interactive scenario chart is getting updated real-time. http://t.co/mcxT8vpV...
                        )

                    [1] => Array
                        (
                            [v] => 1
                        )

                    [2] => Array
                        (
                            [v] => 29
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

    [3] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => Common resume mistakes to avoid, by technical hiring manager @vmbrasseur http://t.co/hwB1z0Q2...
                        )

                    [1] => Array
                        (
                            [v] => 0
                        )

                    [2] => Array
                        (
                            [v] => 1
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

    [4] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => I'm going to start a new single-purpose site, like http://t.co/csuqTyTh, for all the "How do I write...
                        )

                    [1] => Array
                        (
                            [v] => 1
                        )

                    [2] => Array
                        (
                            [v] => 0
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

    [5] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => "No matter how many mistakes you make or how slow you progress, you are still way ahead of everyone ...
                        )

                    [1] => Array
                        (
                            [v] => 0
                        )

                    [2] => Array
                        (
                            [v] => 2
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

    [6] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => Tracing the history of the "'I know, I'll use regexes'. Now they have two problems" quote. http://t....
                        )

                    [1] => Array
                        (
                            [v] => 0
                        )

                    [2] => Array
                        (
                            [v] => 2
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

    [7] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => Fascinating interactive chart of which states each candidate needs to win. http://t.co/e7Xzviek...
                        )

                    [1] => Array
                        (
                            [v] => 0
                        )

                    [2] => Array
                        (
                            [v] => 1
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

    [8] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => I'm very glad to see that StackOverflow officially has banned "LMGTFY" links. http://t.co/9qPE8fck ‚...
                        )

                    [1] => Array
                        (
                            [v] => 0
                        )

                    [2] => Array
                        (
                            [v] => 2
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

    [9] => Array
        (
            [c] => Array
                (
                    [0] => Array
                        (
                            [v] => If the GOP won't believe scientists re: climate change, maybe they'll listen to corporate insurers? ...
                        )

                    [1] => Array
                        (
                            [v] => 0
                        )

                    [2] => Array
                        (
                            [v] => 1
                        )

                    [3] => Array
                        (
                            [v] => 0
                        )

                )

        )

)
Array
(
    [0] => Array
        (
            [type] => string
            [label] => Tweet
        )

    [1] => Array
        (
            [type] => number
            [label] => Replies
        )

    [2] => Array
        (
            [type] => number
            [label] => Retweets
        )

    [3] => Array
        (
            [type] => number
            [label] => Favorites
        )

)
PHP Warning:  json_encode(): Invalid UTF-8 sequence in argument in /srv/thinkup/_lib/class.DashboardModuleCacher.php on line 227
OnTheFenceDevelopment commented 11 years ago

Lol - looks nothing like what was sent to my log file, if you can post what you did to create that output (like I said above, I'm not a PHP dev) then I can try to provide some additional data.

petdance commented 11 years ago

@OnTheFenceDevelopement The dump is per Gina's request a few entries back. It's not in my log file.

OnTheFenceDevelopment commented 11 years ago

Hmm ... I've added print_r($result_set) & print_r($metadata) statements just before the 'offending' line and run the thinkup script via the command line while redirecting the output to a file - that's what I get.

Oddly, my system has stopped complaining now and it ran to conclusion just now.

petdance commented 11 years ago

I have stopped receiving the Invalid UTF-8 sequence errors in my cron runs, but the Undefined property: stdClass::$annotation is still alive and kicking. I have updated no software.

ginatrapani commented 11 years ago

The Undefined property error happens when you share a Google+ post without making a comment about it. (Your comment is "annotation", and the property doesn't exist if there is none.) I'm working on a fix now with tests. Thank you!