• 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/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Ajay

    (@ajay)

    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

    Thread Starter sem101

    (@sem101)

    (see below)

    Thread Starter sem101

    (@sem101)


    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

    Thread Starter sem101

    (@sem101)

    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.

    Thread Starter sem101

    (@sem101)

    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…

    Thread Starter sem101

    (@sem101)

    Maybe it’s a caching problem? I cannot verify nonce 🙁

    Thread Starter sem101

    (@sem101)

    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!

    Thread Starter sem101

    (@sem101)

    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;
      }
    }
    Plugin Author Ajay

    (@ajay)

    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.

    Thread Starter sem101

    (@sem101)

    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;
      }
    }
    Plugin Author Ajay

    (@ajay)

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

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Debug mode headers already sent’ is closed to new replies.