magicstickuk / multisite-post-duplicator

27 stars 14 forks source link

Undefined index: master_site_setting in /wp-content/plugins/multisite-post-duplicator/addons/restrictSites-mpd-addon.php on line 325 #64

Open Jon007 opened 6 years ago

Jon007 commented 6 years ago

In certain circumstances it is possible to produce: Notice: Undefined index: master_site_setting in /wp-content/plugins/multisite-post-duplicator/addons/restrictSites-mpd-addon.php on line 325

This can be resolved in this case by testing if the option is set:

    $options = get_option( 'mdp_settings' );
    if ( isset( $options[ 'master_site_setting' ] ) ) {
        $master_id = $options[ 'master_site_setting' ];

though a better solution is to ensure default options are always available plugin-wide

michaelw85 commented 3 years ago

For anyone stumbling upon this page as I did here's how to fix it without code changes. This setting is available on the network level and by default is not set.

After this, the option is set and exists preventing the error. You can now change back the "Restrict MPD" setting to what you want.

IMHO, this should be resolved in the plugin by either requiring this setting to be configured regardless of the restrict setting or code should check if it is set and perform the expected behavior when set.