• Resolved jimbo777

    (@jimbo777)


    Hi,

    I am getting the following notices within debug.log when running this plugin.

    PHP Notice: Trying to access array offset on value of type int in /wp-admin/includes/plugin.php on line 429

    Any clues how to resolve?

    Thx

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jose Mortellaro

    (@giuse)

    Hi @jimbo777
    thank you for making me notice this issue.

    I’ve tested any kind of operation
    – activating and deactivating Freesoul Deactivate Plugin
    – activating and deactivating another plugin
    – visiting all backend pages
    – visiting all kind of page and post on the frontend
    – saving FDP options for all kind of option

    Unfortunately, I haven’t seen that PHP notice.

    Please help me to reproduce the issue. Can you tell me the following information?:

    – PHP version
    – WordPress version
    – Process that triggers that notice

    About the last point, is that notice written in the debug.log file after you do something in the backend or visiting the frontend? Do you notice any malfunctions?

    If you don’t see any malfunctions, if you don’t want to see anymore the warning set “false” to the constant WP_DEBUG in your wp-config.php

    define(‘WP_DEBUG’,false );

    (Before the comment /* That’s all, stop editing! Happy publishing. */).

    I’m sure after other tests I will reproduce the problem and the next version will fix this warning. Until then, if your website is live and you don’t use it for developing, I suggest you disable the PHP warnings and errors in the wp-config.php file.

    Plugin Author Jose Mortellaro

    (@giuse)

    HI @jimbo777

    I’ve found it.

    As said next version will be ok. Now you have these options:

    – You change the code yourself. I will tell you how to do it.
    – You disable the PHP warning and errors in wp-config.php as written in my previous comment.
    – You wait for the new version
    – You ignore the issue. I confirm this notice doesn’t give any problem.

    If you feel confident and decide to change the code in the pluginn, do the following.

    – Open the file wp-content/plugins/freesoul-deactivate-plugins/admin/eos-dp-helper.php
    – Go to line 371 where you see this line of code:

    uasort( $plugins,'_sort_uname_callback' );

    replace it with this line of code:

    uasort( $plugins,'eos_dp_sort_uname_callback' );

    – Before the commment ” //It returns the updated plugins table after a third plugin activation” add this function:

    //Callback to sort array by a 'Name' key.
    function eos_dp_sort_uname_callback( $a, $b ) {	
    	if( !is_array( $a ) || !is_array( $b ) ) return false;
    	return strnatcasecmp( $a['Name'], $b['Name'] );
    }

    – Save the file.

    The new code will appear so:

    function eos_dp_get_plugins() {
    	$plugin_root = WP_PLUGIN_DIR;
    	// Files in wp-content/plugins directory
    	$plugins_dir = @ opendir( $plugin_root);
    	$plugin_files = array();
    	if ( $plugins_dir ) {
    		while (($file = readdir( $plugins_dir ) ) !== false ) {
    			if ( substr($file, 0, 1) == '.' || strpos( '_'.$file,'freesoul-deactivate-plugins' ) > 0 ) continue;
    			if ( is_dir( $plugin_root.'/'.$file ) ) {
    				$plugins_subdir = @ opendir( $plugin_root.'/'.$file );
    				if ( $plugins_subdir ) {
    					while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
    							if ( substr($subfile, 0, 1) == '.' )
    									continue;
    							if ( substr($subfile, -4) == '.php' )
    									$plugin_files[] = "$file/$subfile";
    					}
    					closedir( $plugins_subdir );
    				}
    			}
    			else {
    				if( substr($file, -4) == '.php' ) $plugin_files[] = $file;
    			}
    		}
    		closedir( $plugins_dir );
    	}
    	if ( empty( $plugin_files ) ) return array();
    	foreach ( $plugin_files as $plugin_file ) {
    		if ( !is_readable( "$plugin_root/$plugin_file" ) ) continue;
    		$plugins[plugin_basename( $plugin_file )] = 1;
    	}
    	uasort( $plugins,'eos_dp_sort_uname_callback' );
    	return $plugins;
    }
    
    //Callback to sort array by a 'Name' key.
    function eos_dp_sort_uname_callback( $a, $b ) {	
    	if( !is_array( $a ) || !is_array( $b ) ) return false;
    	return strnatcasecmp( $a['Name'], $b['Name'] );
    }

    If you don’t feel confident modifying the code, I suggest you ignore this notice and disable the PHP warnings and errors.

    I can’t say now when the next version will be realized.

    Thread Starter jimbo777

    (@jimbo777)

    Perfect! Thank you. I will try this right now.

    Thread Starter jimbo777

    (@jimbo777)

    The original PHP notice has now dissappeared but now, I am also getting:

    22-Oct-2020 09:21:55 UTC] PHP Notice: Trying to get property ‘post_type’ of non-object /wp-content/mu-plugins/eos-deactivate-plugins.php on line 105

    [22-Oct-2020 09:21:55 UTC] PHP Notice: Trying to access array offset on value of type /wp-content/mu-plugins/eos-deactivate-plugins.php on line 108

    I am not really sure if this effects the functionality at all. Let me know if you have any suggestions.

    Thanks again!

    Plugin Author Jose Mortellaro

    (@giuse)

    Hi @jimbo777

    This is already fixed in the future new version.

    If you don’t want to see them, until the new version is not public, do the following:

    – Open the file wp-content/mu-plugins/eos-deactivate-plugins.php
    – Go to line 105 where you should see this line:

    $post_types_matrix_pt = isset( $post_types_matrix[$p->post_type] ) ? $post_types_matrix[$p->post_type] : 0;

    replace it with this one:

    $post_types_matrix_pt = is_object( $p ) && isset( $post_types_matrix[$p->post_type] ) ? $post_types_matrix[$p->post_type] : 0;

    – Go to line 108 where you should see this line:

    if( isset( $post_types_matrix_pt ) && '0' == $post_types_matrix_pt[0] ){

    replace it with this one:

    if( isset( $post_types_matrix_pt ) && isset( $post_types_matrix_pt[0] ) && '0' == $post_types_matrix_pt[0] ){

    – Save the file

    – Copy the entire file and paste it in wp-content/plugins/freesoul-deactivate-plugins/mu-plugins/eos-deactivate-plugins.php (In another case deactivating and reactivating the plugin you will have again the notices).

    In any case, also those notices don’t give any malfunction. But better to don’t have them, because if you have the debug active, every time they are written in the debug.log file, they make increase the size of that file, and when that file becomes very big, every time you have a PHP notice it consumes time during the PHP parsing.

    Moreover, if the debug is active, you can reach the file debug.log on the frontend and read the information that is always better to don’t give to anyone (e.g. folder path).
    This is why I suggest disabling the debug if you don’t use the website for developing.

    Thread Starter jimbo777

    (@jimbo777)

    Just did the changes. Thanks very much!

    Plugin Author Jose Mortellaro

    (@giuse)

    Hi @jimbo777, you are welcome! I will close this thread if you have again problems don’t hesitate to open a new one.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Trying to access array offset on value of type int-wp-admin/includes/plugin.php’ is closed to new replies.