Undefined index notice
-
Hi,
I’m getting an undefined index error on line 45 of
stop-user-enumeration.php, which is part of thell_detect_enumeration()function.This is happening on requests to a page without the trailing slash, e.g. request to
/about-usrather than/about-us/. In this instance, the firstpreg_matchstatement is returning false (because ‘author’ is not in the query string) so the second check is running:($_POST['author']). This is emitting an undefined index notice, because the key ‘author’ does not exist in the$_POSTarray.This is in-turn breaking the redirect, because a PHP notice is being emitted before the redirect headers can be sent. Of course this only happens if PHP is configured to output notice messages – typically this means that
WP_DEBUGis enabled.Suggested fix
Replace
($_POST['author'])withisset($_POST['author'])to check whether the author key has been set.Thanks
The topic ‘Undefined index notice’ is closed to new replies.