Thread Rating:
  • 4 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get simple 3.3.16 support for php 8.0
Migrating my website CMS to PHP 8.1 which is now the current version.

I found two deprecations which affect GetSimple (will probably become hard errors when PHP9 comes):

1. They changed null parameter handling in built-in string functions like trim(), substr(), htmlentities() etc.
Until PHP 8.0, these functions silently handled a null argument as an empty string. Starting with PHP 8.1, a warning is thrown that passing null parameter is deprecated.
There are a few places in GetSimple cms, and unfortunately also in i18N plugings.
It is easy to fix this change by adding a null coalescing operator and an empty string (parameter ?? "") in any place where the warning pops up.

Fixes in GetSimple core:

/admin/inc/basic.php: line 85:
  $text = mb_convert_encoding($text ?? "",'HTML-ENTITIES',$from_enc);

/admin/inc/cookie_functions..php: line 23:
  return setcookie($id, $value, $expire, $cookie_path, $cookie_domain ??"", $cookie_secure??"", $cookie_httponly);

/admin/inc/cookie_functions..php: line 35:
return setcookie($id,false,1,$cookie_path,$cookie_domain??"",$cookie_secure??"", $cookie_httponly);

Also fixed some warnings of the same type in i18N Bases and i18N Search, but I do not know what Mvlcek thinks about modifying his plugins.

2. FILTER_SANITIZE_STRING is deprecated and must be removed.
It is used in admin/inc/security_functions.php in function var_out($var, $filter = "special").

I changed this function like this:

PHP Code:
function var_out($var,$filter "special"){
$var = (string)$var;

// php 5.2 shim
$filter == "full") return htmlspecialchars($varENT_QUOTES);

// php 8.1: FILTER_SANITIZE_STRING deprecated
if(function_exists"filter_var") && ($filter !== "string" )){
$aryFilter = array(
$aryFilter[$filter])) return filter_var$var$aryFilter[$filter]);
 else if (
$filter === "string") {
 else {

With these additional fixes, my GetSimple site seems to run flawlessly and without warnings on PHP 8.1. However, there are probably parts of the CMS I currently did not use, which also would throw such warnings.

Hope this helps a little further in making GetSimple "future-proof" Wink

Messages In This Thread
RE: Get simple 3.3.16 support for php 8.0 - by Knobbles - 2022-09-29, 04:52:35

Users browsing this thread: 1 Guest(s)