Support » Plugin: NoSpamNX » Undefined index notices in getOptions

  • Resolved Mikko Saari

    (@msaari)


    The getOptions() function is still throwing “undefined index” notices in some cases. Could this be fixed in the next version? Thanks! Here’s a version of the getOptions() function that doesn’t throw a notice:

    function getOptions() {
    	$options = get_option('nospamnx');
    	isset($options['nospamnx_names']) ? $this->nospamnx_names = $options['nospamnx_names'] : $this->nospamnx_names = "";
    	isset($options['nospamnx_count']) ? $this->nospamnx_count = $options['nospamnx_count'] : $this->nospamnx_count = "";
    	isset($options['nospamnx_operate']) ? $this->nospamnx_operate = $options['nospamnx_operate'] : $this->nospamnx_operate = "";
    	isset($options['nospamnx_blacklist_part']) ? $this->nospamnx_blacklist_part = $options['nospamnx_blacklist_part'] : $this->nospamnx_blacklist_part = "";
    	isset($options['nospamnx_blacklist_global_url']) ? $this->nospamnx_blacklist_global_url = $options['nospamnx_blacklist_global_url'] : $this->nospamnx_blacklist_global_url = "";
    	isset($options['nospamnx_blacklist_global_update']) ? $this->nospamnx_blacklist_global_update = $options['nospamnx_blacklist_global_update'] : $this->nospamnx_blacklist_global_update = "";
    	isset($options['nospamnx_blacklist_global_lu']) ? $this->nospamnx_blacklist_global_lu = $options['nospamnx_blacklist_global_lu'] : $this->nospamnx_blacklist_global_lu = "";
    	isset($options['nospamnx_activated']) ? $this->nospamnx_activated = $options['nospamnx_activated'] : $this->nospamnx_activated = "";
    	isset($options['nospamnx_commentid']) ? $this->nospamnx_commentid = $options['nospamnx_commentid'] : $this->nospamnx_commentid = "";
    	isset($options['nospamnx_salt']) ? $this->nospamnx_salt = $options['nospamnx_salt'] : $this->nospamnx_salt = "";
    	$this->nospamnx_blacklist_global		= get_option('nospamnx-blacklist-global');
    	$this->nospamnx_blacklist				= get_option('nospamnx-blacklist');
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author kubi23

    (@kubi23)

    Hi,

    does the error message say which field throwns an “undefined index”?

    Best,
    Sven

    It did, but since I already fixed it a month ago, I don’t remember which one it was. I think it was one of the blacklist ones.

    In any case I think it’s reasonable to make sure all of them get initialized.

    Plugin Author kubi23

    (@kubi23)

    Hi Mikko,

    as you already fixed this, would you mind sharing you code? Would save me a lot of time and I could release a new version for all user asap.

    Thanks and best regards,
    Sven

    The relevant part of the code is in the first message, that’s the fixed version of the getOptions() function. No other changes are necessary.

    Thanks!

    Plugin Author kubi23

    (@kubi23)

    Fixed version is out. Thanks for reporting this.

    Best,
    Sven

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Undefined index notices in getOptions’ is closed to new replies.