Cannot redeclare boolval() with PHP5.5 - slackero/phpwcms GitHub Wiki

You might be confronted by a fatal error message like this one here:
Fatal error: Cannot redeclare boolval() in /include/inc_lib/general.inc.php on line 2533
when upgrading to PHP5.5+ with an older installation of phpwcms.

The problem is caused by the function boolval() which was introduced with PHP 5.5.0 but is a function phpwcms has implemented since a long time.

To fix the error there is no need to update phpwcms. Sure, it's always recommend to have a newer release running but it can be solved very easy.

Open the file general.inc.php and search for function boolval or go directly to the given line number in the error message.

Change the section to:

/**
 * Try alternative way to test for bool value
 *
 * @param mixed
 * @param bool
 */
if(!function_exists('boolval')) {
	function boolval($BOOL, $STRICT=false) {

		if(is_string($BOOL)) {
			$BOOL = strtoupper($BOOL);
		}
	
		// no strict test, check only against false bool
		if( !$STRICT && in_array($BOOL, array(false, 0, NULL, 'FALSE', 'NO', 'N', 'OFF', '0'), true) ) {

			return false;

		// strict, check against true bool
		} elseif($STRICT && in_array($BOOL, array(true, 1, 'TRUE', 'YES', 'Y', 'ON', '1'), true) ) {

			return true;

		}

		// let PHP decide
	    return $BOOL ? true : false;
	}
}

Newer releases of phpwcms doesn't have the problem.