WordPress.org

Support

Support » Plugins and Hacks » WP Statistics » [Resolved] Errors Everywhere!

[Resolved] Errors Everywhere!

  • After the last two or three updates i get errors in Admin Panel head.

    Warning: Invalid argument supplied for foreach() in /var/…/wp-content/plugins/wp-statistics/wp-statistics.php on line 102 Call Stack: 0.0004 746776
    1. {main}() /var/…/wp-admin/index.php:0 0.0007 872576
    2. require_once(‘/var/…/wp-admin/admin.php’) /var/customers/webs/Fischy/wp-admin/index.php:10 0.4535 83185576
    3. require(‘/var/…/wp-admin/menu.php’) /var/…/wp-admin/admin.php:120 0.458……….

    and much more 🙁 please fix it!

    http://wordpress.org/plugins/wp-statistics/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Greg Ross

    @gregross

    What version of WordPress are you running?

    i use version 3.8

    Plugin Author Greg Ross

    @gregross

    Are you using any plugins that change the roles/capabilities of WP?

    It looks like something has messed with WP’s internal roles and created an invalid entry.

    Edit wp_statistics.php, go down to line 102, there should be a code block like:

    function wp_statistics_validate_capability( $capability ) {
    
    		global $wp_roles;
    
    		$role_list = $wp_roles->get_names();
    
    		foreach( $wp_roles->roles as $role ) {
    
    			$cap_list = $role['capabilities'];
    
    			foreach( $cap_list as $key => $cap ) {
    				if( substr($key,0,6) != 'level_' ) {
    					$all_caps[$key] = 1;
    				}
    			}
    		}
    
    		if( $all_caps[$capability] == 1 ) { return $capability; }
    
    		return 'manage_options';
    
    	}

    Replace it with:

    function wp_statistics_validate_capability( $capability ) {
    
    		global $wp_roles;
    
    		$role_list = $wp_roles->get_names();
    
    		foreach( $wp_roles->roles as $role ) {
    
    			$cap_list = $role['capabilities'];
    
    			if( is_array( $cap_list ) ) {
    
    				foreach( $cap_list as $key => $cap ) {
    					if( substr($key,0,6) != 'level_' ) {
    						$all_caps[$key] = 1;
    					}
    				}
    			}
    		}

    okay i’ll try it.

    give you a feedback later 🙂

    btw. i dont use a plugin for change the roles … hmmmpf

    now i created a fatal error o.o and the plugin is automatically deactivated T_T

    could it be …. i tested a plugin for role change a long time ago … are there some pieces of code hidden?

    Plugin Author Greg Ross

    @gregross

    Sorry, copy and paste error on the second code snipit:

    function wp_statistics_validate_capability( $capability ) {
    
    		global $wp_roles;
    
    		$role_list = $wp_roles->get_names();
    
    		foreach( $wp_roles->roles as $role ) {
    
    			$cap_list = $role['capabilities'];
    
    			if( is_array( $cap_list ) ) {
    
    				foreach( $cap_list as $key => $cap ) {
    					if( substr($key,0,6) != 'level_' ) {
    						$all_caps[$key] = 1;
    					}
    				}
    			}
    		}
    
    		if( $all_caps[$capability] == 1 ) { return $capability; }
    
    		return 'manage_options';
    
    	}

    Dude … you are awesome 🙂 thank you 1000 times

    Karma +1000000

    You safed my day!

    thank you Greg

    It is really good stuff.

    Thank you very much 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] Errors Everywhere!’ is closed to new replies.
Skip to toolbar