• Adam

    (@adamf321)


    The following error shows at the top of the screen when I click “Add New”. The same happens when I edit an existing article.

    I’ve disabled all other plugins and have switched back to Twenty Nineteen. I’m running WP v5.3 and WP-Help v1.7.0.

    Notice: Trying to get property ‘id’ of non-object in /app/web/wp-content/plugins/wp-help/classes/plugin.php on line 107

    Call Stack:
    0.0013 432888 1. {main}() /app/web/wp/wp-admin/post-new.php:0
    0.3948 3684824 2. include(‘/app/web/wp/wp-admin/edit-form-blocks.php’) /app/web/wp/wp-admin/post-new.php:72
    0.3951 3686096 3. array_reduce() /app/web/wp/wp-admin/edit-form-blocks.php:77
    0.6000 4965488 4. rest_preload_api_request() /app/web/wp/wp-admin/edit-form-blocks.php:77
    0.6000 4966984 5. rest_do_request() /app/web/wp/wp-includes/rest-api.php:1539
    0.6001 4966984 6. WP_REST_Server->dispatch() /app/web/wp/wp-includes/rest-api.php:429
    0.6119 5099576 7. WP_REST_Posts_Controller->get_item() /app/web/wp/wp-includes/rest-api/class-wp-rest-server.php:946
    0.6122 5100024 8. WP_REST_Posts_Controller->prepare_item_for_response() /app/web/wp/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:472
    0.6270 5121688 9. WP_REST_Posts_Controller->add_additional_fields_to_object() /app/web/wp/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:1658
    0.6276 5123024 10. CWS_WP_Help_Plugin->{closure:/app/web/wp-content/plugins/wp-help/classes/plugin.php:106-108}() /app/web/wp/wp-includes/rest-api/endpoints/class-wp-rest-controller.php:403

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Adam

    (@adamf321)

    Seems this only happens on my local install so it’s not urgent.

    I’m seeing this whenever I have WP_DEBUG = true. If you’re seeing this with a generic theme and no other plugins, then it’s a problem w/ the plugin, and needs to be fixed.

    Okay, I’ve made the following change to classes/plugin.php:

    – check that $doc->id is set before using it. If it’s not, use NULL, since the is_default_doc method has NULL as its default value.

    FIND around line 106:

    
    'get_callback' => function ( $doc ) {
      return $this->is_default_doc( $doc->id  );
    },
    

    REPLACE WITH:

    
    'get_callback' => function ( $doc ) {
      $doc_id = ( isset( $doc->id ) ) ? $doc->id : NULL;
      return $this->is_default_doc( $doc_id );
    },
    

    This gets rid of the notice, and checking / unchecking the “Default Help Document” checkbox continues to work as it should.

    Hope this helps someone!

    cc @markjaquith

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error When Adding New Help Article’ is closed to new replies.