dshanske / parse-this

Parse This Parsing Library for WordPress- Can Act as a Standalone Plugin
GNU General Public License v2.0
15 stars 3 forks source link

PHP Fatal error: Object of class WP_Error could not be converted to string #64

Closed bekopharm closed 4 years ago

bekopharm commented 4 years ago

Trace:

PHP Fatal error:  Uncaught Error: Object of class WP_Error could not be converted to string in wp-content/plugins/indieweb-post-kinds/lib/parse-this/includes/class-parse-this.php:369
Stack trace:
#0 wp-content/plugins/indieweb-post-kinds/lib/parse-this/includes/class-parse-this.php(369): str_replace()
#1 wp-content/plugins/indieweb-post-kinds/lib/parse-this/includes/class-rest-parse-this.php(120): Parse_This->parse()
#2 wp-includes/rest-api/class-wp-rest-server.php(1015): REST_Parse_This::read()
#3 wp-content/plugins/activitypub/includes/rest/class-server.php(29): WP_REST_Server->dispatch()
#4 wp-includes/rest-api/class-wp-rest-server.php(342): Activitypub\Rest\Server->dispatch()
#5 wp-includes/rest-api.php(312): WP_REST_Server->serve_request()
#6 wp-includes/class-wp-hook.php(287): rest_api_loaded()

Affected version shipped with indieweb-post-kinds 3.3.4 Tried also with 95375c08b483b39e00f5c4ed63a284c16c13e8a7

Solution: Catch WP_Error thrown by own/self function redirect()

Error in question is:

PHP_Error Object
(
    [errors] => Array
        (
            [invalid-url] => Array
                (
                    [0] => A valid URL was not provided.
                )
[...]

This probably happened because the summary seems to be shortened (by what I don't know) and an URL was cut in the middle. wp_extract_urls() (regex fn) returns the partial $url with content string https://www.gamingonlinu... in this case and yeah… that's not a valid URL.

dshanske commented 4 years ago

Do you have the URL you were using?

bekopharm commented 4 years ago

That'd be https://beko.famkos.net/2020/07/03/releases-for-linux-pc/

dshanske commented 4 years ago

This should be fixed now.