WordPress.org

Ready to get started?Download WordPress

Forums

Role Scoper
[resolved] Debug mode: need safer checking (patch) (3 posts)

  1. daveagp
    Member
    Posted 1 year ago #

    Hi,

    I run a version of my site with WP_DEBUG on and I get some warnings from your plugin. I'm attaching the patch of what I changed to prevent this (the changes are all trivial). Are you interested in merging this with the main repository? Thanks!

    diff -Naur ./cap-interceptor_rs.php ../role-scoper/cap-interceptor_rs.php
    --- ./cap-interceptor_rs.php	2012-02-24 16:29:50.000000000 -0500
    +++ ../role-scoper/cap-interceptor_rs.php	2012-06-18 00:18:52.000000000 -0400
    @@ -190,7 +190,7 @@
     		);
    
     		// for scoped menu management roles, satisfy edit_theme_options cap requirement
    -		if ( ( 'edit_theme_options' == $orig_reqd_caps[0] ) && empty( $wp_blogcaps['edit_theme_options'] ) ) {
    +		if ( array_key_exists(0, $orig_reqd_caps) && ( 'edit_theme_options' == $orig_reqd_caps[0] ) && empty( $wp_blogcaps['edit_theme_options'] ) ) {
     			if ( in_array( $GLOBALS['pagenow'], array( 'nav-menus.php', 'admin-ajax.php' ) ) || $doing_admin_menus ) {
     				$key = array_search( 'edit_theme_options', $rs_reqd_caps );
     				if ( false !== $key ) {
    @@ -222,7 +222,7 @@
     		} elseif ( is_admin() && ( 'edit-tags.php' == $GLOBALS['pagenow'] ) && ( 'link_category' == $_REQUEST['taxonomy'] ) ) {
     			$src_name = 'link';
     			$object_type = 'link_category';
    -		} elseif ( in_array( $orig_reqd_caps[0], array( 'manage_nav_menus', 'edit_theme_options' ) ) ) {
    +		} elseif ( array_key_exists(0, $orig_reqd_caps) && in_array( $orig_reqd_caps[0], array( 'manage_nav_menus', 'edit_theme_options' ) ) ) {
     			$src_name = 'nav_menu';
     		}
    
    @@ -712,7 +712,7 @@
     		$rs_reqd_caps = array_fill_keys( $rs_reqd_caps, true );
    
     		if ( ! $this_id_okay ) {
    -			if ( ( 'edit_posts' == $orig_reqd_caps[0] ) && strpos( $_SERVER['REQUEST_URI'], 'async-upload.php' ) ) {  // temp workaround for ACF with Revisionary
    +		  if ( array_key_exists(0, $orig_reqd_caps) && ( 'edit_posts' == $orig_reqd_caps[0] ) && strpos( $_SERVER['REQUEST_URI'], 'async-upload.php' ) ) {  // temp workaround for ACF with Revisionary
     				return $wp_blogcaps;
     			}
    
    diff -Naur ./hardway/cache-persistent.php ../role-scoper/hardway/cache-persistent.php
    --- ./hardway/cache-persistent.php	2012-02-24 16:29:50.000000000 -0500
    +++ ../role-scoper/hardway/cache-persistent.php	2012-06-17 21:19:51.000000000 -0400
    @@ -615,7 +615,7 @@
     		//rs_errlog ("<br />setting $id/$group:<br />");
    
     		// is_404() function is no longer available at the execution of this wpp_cache_close, so check it here
    -		if ( function_exists( 'is_404' ) && is_404() && empty( $this->is_404 ) )
    +		if ( function_exists( 'is_404' ) && isset( $wp_query ) && is_404() && empty( $this->is_404 ) )
     			$this->is_404 = true;
    
     		if ( ! empty( $this->is_404 ) )
    diff -Naur ./role-scoper_main.php ../role-scoper/role-scoper_main.php
    --- ./role-scoper_main.php	2012-02-24 16:29:50.000000000 -0500
    +++ ../role-scoper/role-scoper_main.php	2012-06-18 00:16:53.000000000 -0400
    @@ -889,7 +889,7 @@
    
     			if ( 'post' == $src_name ) {
     				if ( ! $operation )
    -					$operation = ( $this->is_front() || ( 'profile.php' == $pagenow ) || ( is_admin() && ( 's2' == $GLOBALS['plugin_page'] ) ) ) ? 'read' : 'edit';  // hack to support subscribe2 categories checklist
    +				  $operation = ( $this->is_front() || ( 'profile.php' == $pagenow ) || ( is_admin() && array_key_exists('plugin__page', $GLOBALS) && ( 's2' == $GLOBALS['plugin_page'] ) ) ) ? 'read' : 'edit';  // hack to support subscribe2 categories checklist
    
     				$status = ( 'read' == $operation ) ? 'publish' : 'draft';

    http://wordpress.org/extend/plugins/role-scoper/

  2. kevinB
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks, Dave

    I have applied those changes to my local development source and will include them in the next release (minus the 'plugin__page' typo).

  3. daveagp
    Member
    Posted 1 year ago #

    Awesome thanks for catching the typo too!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic