Support » Plugin: Medium » ‘Non-object error’ thrown when saving drafts/publishing posts (PHP 7.2/WP 4.9.5)

  • Hi,

    I have WordPress 4.9.5 running under nginx + php-fpm 7.2 on my server, and recently I’ve been seeing the Medium plugin throwing the following errors:

    2018/04/08 18:40:51 [error] 1561#1561: *9978 FastCGI sent in stderr: "PHP message: PHP Warning:  Attempt to assign property 'license' of non-object in [mypath]/wp-content/plugins/medium/lib/medium-admin.php on line 554
    PHP message: PHP Warning:  Attempt to assign property 'cross_link' of non-object in [mypath]/wp-content/plugins/medium/lib/medium-admin.php on line 558
    PHP message: PHP Warning:  Attempt to assign property 'follower_notification' of non-object in [mypath]/wp-content/plugins/medium/lib/medium-admin.php on line 562
    PHP message: PHP Warning:  Attempt to assign property 'publication_id' of non-object in [mypath]/wp-content/plugins/medium/lib/medium-admin.php on line 566
    PHP message: PHP Warning:  Attempt to assign property 'status' of non-object in [mypath]/wp-content/plugins/medium/lib/medium-admin.php on line 573" while reading upstream, client: [my IP address], server: [myserver.tld], request: "GET /wp-admin/post.php?post=3869&action=edit HTTP/1.1", upstream: "fastcgi://127.0.0.1:9015", host: "[myserver.tld]", referrer: "https://[myserver.tld]/wp-admin/edit.php"
    2018/04/08 18:58:07 [error] 1558#1558: *10902 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function save() on string in [mypath]/wp-content/plugins/medium/lib/medium-admin.php:502
    Stack trace:
    #0 [mypath]/wp-includes/class-wp-hook.php(288): Medium_Admin::save_post(3869, Object(WP_Post))
    #1 [mypath]/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #2 [mypath]/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #3 [mypath]/wp-includes/post.php(3581): do_action('save_post', 3869, Object(WP_Post), true)
    #4 [mypath]/wp-includes/post.php(3654): wp_insert_post(Array, false)
    #5 [mypath]/wp-admin/includes/post.php(377): wp_update_post(Array)
    #6 [mypath]/wp-admin/post.php(194): edit_post()
    #7 {main}
      thrown in [mypath]/wp-content/plugins/medium/lib/medium-admin.php on line 502" while reading response header from upstream, client: [my IP address], server: [myserver.tld], request: "POST /wp-admin/post.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9015", host: "[myserver.tld]", referrer: "https://[myserver.tld]/wp-admin/post.php?post=3869&action=edit"

    and that results into the browser showing a 500 Internal Error.

    I did some investigation — basically, putting a few try..catch instructions and checking if the culprits were actual objects or not. What I saw was that these objects were actually not objects, i.e. they were NULL and not initialised properly. This is a bug I hadn’t seen on the previous WordPress version, so maybe WP 4.9.5 brought a few tougher restrictions (or different ways of accessing $post_id); or it’s somehow the fault of PHP 7.2 which places new restrictions on how objects are instantiated and accessed — I don’t know.

    I’m fine in doing some more tests to help out fixing this issue. For now, the tests I do prevent the 500 error to pop up, meaning that the article draft gets saved properly, but of course, when publishing, the article will not be sent to Medium.

    I actually wonder why the Medium plugin is actually being invoked for drafts — theoretically it should remain dormant during draft saving and only be active during publishing/updating…

  • The topic ‘‘Non-object error’ thrown when saving drafts/publishing posts (PHP 7.2/WP 4.9.5)’ is closed to new replies.