Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-20510

PHP 8 deprecated notice in "CCookieSession.php", "CScreenProblem.php" and "MysqlDbBackend.php"

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Won't fix
    • Icon: Trivial Trivial
    • None
    • 5.4.9
    • Frontend (F)
    • Linux: 5.16.3-arch1-1 #1 SMP PREEMPT Thu, 27 Jan 2022 14:18:25 +0000 x86_64 GNU/Linux
      PHP: PHP 8.1.2 (cli) (built: Jan 19 2022 17:12:32) (NTS)
      MariaDB: Server version: 10.6.5-MariaDB Arch Linux

      Steps to reproduce:

      1. Open the dashboard

      Result:

      Multiple div's having errors like the following inside.

       
      mysqli::real_connect(): Passing null to parameter #7 ($flags) of type int is deprecated [zabbix.php:22 → require_once() → ZBase->run() → ZBase->initDB() → DBconnect() → MysqlDbBackend->connect() → mysqli->real_connect() in include/classes/db/MysqlDbBackend.php:173]
          Return type of CCookieSession::open($save_path, $session_name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
          Return type of CCookieSession::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
          Return type of CCookieSession::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
          Return type of CCookieSession::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
          Return type of CCookieSession::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
          Return type of CCookieSession::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25] 

      {{}}

      Expected:

      No Errors.

       

      My fixes per file as `diff` below.

       

      diff include/classes/core/CCookieSession.php include/classes/core/CCookieSession.php.original
      49c49
      <       public function close() : bool {
      ---
      >       public function close() {
      62c62
      <       public function destroy($session_id) : bool {
      ---
      >       public function destroy($session_id) {
      75,76c75,76
      <       public function gc($maxlifetime) : int|false {
      <               return 1;
      ---
      >       public function gc($maxlifetime) {
      >               return true;
      87c87
      <       public function open($save_path, $session_name) : bool {
      ---
      >       public function open($save_path, $session_name) {
      100c100
      <       public function read($session_id) : string|false {
      ---
      >       public function read($session_id) {
      104c104
      <                       return false;
      ---
      >                       return '';
      122c122
      <       public function write($session_id, $session_data) : bool {
      ---
      >       public function write($session_id, $session_data) { 
      diff include/classes/screens/CScreenProblem.php include/classes/screens/CScreenProblem.php.original
      699,704d698
      <         $clock_datetime = new DateTime();
      <         $last_clock_datetime = new DateTime();
      <
      <         $clock_datetime->setTimestamp($clock);
      <         $last_clock_datetime->setTimestamp($last_clock);
      <
      706d699
      <
      710,711c703,704
      <             elseif ($last_clock_datetime->format('H') != $clock_datetime->format('H')) {
      <                 $breakpoint = $last_clock_datetime->format('H:00');
      ---
      >                       elseif (strftime('%H', $last_clock) != strftime('%H', $clock)) {
      >                               $breakpoint = strftime('%H:00', $last_clock);
      720c713
      <                       $breakpoint = $last_clock_datetime->format('Y');
      ---
      >                       $breakpoint = strftime('%Y', $last_clock);
      722,723c715,716
      <         elseif ($last_clock_datetime->format('Ym') != $clock_datetime->format('ym')) {
      <                       $breakpoint = getMonthCaption($last_clock_datetime->format('m'));
      ---
      >               elseif (strftime('%Y%m', $last_clock) != strftime('%Y%m', $clock)) {
      >                       $breakpoint = getMonthCaption(strftime('%m', $last_clock)); 
      diff include/classes/db/MysqlDbBackend.php include/classes/db/MysqlDbBackend.php.original
      173,177c173
      <         if (is_null($tls_mode)) {
      <                   @$resource->real_connect($host, $user, $password, $dbname, $port);
      <         } else {
      <                   @$resource->real_connect($host, $user, $password, $dbname, $port, null, $tls_mode);
      <         }
      ---
      >               @$resource->real_connect($host, $user, $password, $dbname, $port, null, $tls_mode); 

            zabbix.support Zabbix Support Team
            artodeto Stev Leibelt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: