WordPress.org

Ready to get started?Download WordPress

Forums

Contextual Related Posts
Debug mode headers already sent (12 posts)

  1. sem101
    Member
    Posted 2 months ago #

    Hi, when DEBUG is true, I get white screen and these warnings when trying to save a Post or Page...

    Notice: Undefined offset: 0 in /public_html/wp-includes/capabilities.php on line 1102
    
    Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-includes/capabilities.php:1102) in /public_html/wp-admin/post.php on line 235
    
    Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-includes/capabilities.php:1102) in /public_html/wp-includes/pluggable.php

    Plugins we use have to pass debug mode :-/

    Thanks for any help!

    https://wordpress.org/plugins/contextual-related-posts/

  2. Ajay
    Member
    Plugin Author

    Posted 2 months ago #

    Why do you think this is a problem with Contextual Related Posts. Is there a way for me to replicate this?

    I test my plugins with WP_DEBUG set to true

  3. sem101
    Member
    Posted 2 months ago #

    (see below)

  4. sem101
    Member
    Posted 2 months ago #


    Maybe it's the META BOX ???

    Here are the steps to replicate...

    1. DEBUG is true
    2. MultiSite is true
    3. All plugins deactivated
    4. Twentyfourteen theme only
    5. Activate CRP plugin
    6. Create and Save a "test" post

    Get white screen and notices above.

    I have repeated steps with popular plugins like CF7, EMP, etc. This seems to happening with Contextual Related Posts.

    *** I have not tried with WP clean install or single blog. I have only tried with the steps listed above on MultiSite only.

    localhost
    WP 3.9.1
    MultiSite
    PHP 5.4.4

  5. sem101
    Member
    Posted 2 months ago #

    OK, it appears to be the meta box as assumed. I am currently debugging now. I have currently disabled the meta box:

    admin.inc.php (760)

    function crp_add_meta_box( $post_type, $post ) {
    
        	add_meta_box(
        		'crp_metabox',
        		__( 'Contextual Related Posts', CRP_LOCAL_NAME ),
        		'crp_call_meta_box',
        		$post_type,
        		'advanced',
        		'default'
        	);
    
    }
    //add_action( 'add_meta_boxes', 'crp_add_meta_box' , 10, 2 );

    When I disable meta box, I can easily save a post.

  6. sem101
    Member
    Posted 2 months ago #

    Line 773, admin.inc.php

    wp_nonce_field( 'crp_meta_box', 'crp_meta_box_nonce' );

    Commenting out the nonce solves the problem. I will investigate further...

  7. sem101
    Member
    Posted 2 months ago #

    Maybe it's a caching problem? I cannot verify nonce :(

  8. sem101
    Member
    Posted 2 months ago #

    Okay, it's NOT the nonce. It's user roles. I should've know (because capabilities.php warning):

    admin.inc.php
    (809)

    if ( ! current_user_can( 'edit_post' ) ) return;

    I am done debugging. I'm just going to comment out that line and figure it out later. FYI, there are returns with no error handlers. Also, textdomain's should not use DEFINED vars ;-)

    Cool plugin, thanks!

  9. sem101
    Member
    Posted 2 months ago #

    I'm going to add this for now...what do you think?

    if ( isset( $_POST['crp_meta_box_nonce'] ) ) {
      if ( ! current_user_can( 'edit_post', $post_id ) ) {
        return;
      }
    }
  10. Ajay
    Member
    Plugin Author

    Posted 2 months ago #

    Hi,

    Thanks for the detailed debugging steps. I followed the tutorial at http://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes--wp-20336 with these steps.

    Does your code above work or have you disabled the nonce ?

    I'm wondering if the problem is with multisite because although the plugin works with multisite, I don't think it is 100% compatible.

  11. sem101
    Member
    Posted 2 months ago #

    Hi Ajay,

    So far, seems to work great WITHOUT removing nonce. I see you have 2 nonces in your form, but haven't looked at all code so I don't know reference.

    This seems to be most non intrusive code that does not modify anything greatly. Hope it helps!

    if ( isset( $_POST['crp_meta_box_nonce'] ) ) {
      if ( ! current_user_can( 'edit_post', $post_id ) ) {
        return;
      }
    }
  12. Ajay
    Member
    Plugin Author

    Posted 2 months ago #

    Thank you. I'll relook at the code and add what you've put and run some tests.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags