Project

General

Profile

« Previous | Next » 

Revision 9a9a6b3e

Added by Kristof Provost over 2 years ago

Fix config_del_path() if the node doesn't exist

If the node we're trying to delete with config_del_path() doesn't exist
array_del_path() will fail as follows:

Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /etc/inc/util.inc:3459
Stack trace:
thrown in /etc/inc/util.inc on line 3459
PHP ERROR: Type: 1, File: /etc/inc/util.inc, Line: 3459, Message: Uncaught TypeError: Cannot access offset of type string on string in /etc/inc/util.inc:3459
Stack trace:
thrown

Check to make sure the element we found is an array and contains the key
we're trying to delete before we try to delete it.

View differences:

src/etc/inc/util.inc
3452 3452
			return null;
3453 3453
		}
3454 3454
	}
3455

  
3456
	if (!(is_array($el) && array_key_exists($vkey, $el))) {
3457
		return null;
3458
	}
3459

  
3455 3460
	$ret = $el[$vkey];
3456 3461
	unset($el[$vkey]);
3457 3462
	return ($ret);

Also available in: Unified diff