فهرست منبع

Fix for PHP 8 RC2

Visman 4 سال پیش
والد
کامیت
97de25a05f

+ 1 - 1
app/Core/Router.php

@@ -157,7 +157,7 @@ class Router
                     'page' !== $name
                     || 1 !== $args[$name]
                 ) {
-                    $data['{' . $name . '}'] = \rawurlencode(\str_replace($this->subSearch, $this->subRepl, $args[$name]));
+                    $data['{' . $name . '}'] = \rawurlencode(\str_replace($this->subSearch, $this->subRepl, (string) $args[$name]));
                     continue;
                 }
             }

+ 2 - 2
app/Models/Page.php

@@ -240,9 +240,9 @@ abstract class Page extends Model
                        $navGen[$matches[4][$i]] = [$matches[3][$i], $matches[2][$i]];
                    } else {
                        $navGen = \array_merge(
-                           \array_slice($navGen, 0, $matches[1][$i]),
+                           \array_slice($navGen, 0, (int) $matches[1][$i]),
                            [$matches[4][$i] => [$matches[3][$i], $matches[2][$i]]],
-                           \array_slice($navGen, $matches[1][$i])
+                           \array_slice($navGen, (int) $matches[1][$i])
                        );
                    }
                }

+ 14 - 4
app/Models/Pages/Admin/Bans.php

@@ -380,7 +380,7 @@ class Bans extends Admin
         }
 
         $startNum = ($page - 1) * $this->c->config->o_disp_users;
-        $idsN     = \array_slice($idsN, $startNum, $this->c->config->o_disp_users);
+        $idsN     = \array_slice($idsN, $startNum, (int) $this->c->config->o_disp_users);
         $banList  = $this->c->bans->getList($idsN);
 
         $this->nameTpl    = 'admin/bans_result';
@@ -742,6 +742,7 @@ class Bans extends Admin
     {
         if (
             empty($v->getErrors())
+            && null !== $username
             && '' != \trim($username)
         ) {
             $user = $this->c->users->loadByName($username, true);
@@ -769,7 +770,10 @@ class Bans extends Admin
      */
     public function vIpBan(Validator $v, $ips)
     {
-        if ('' != \trim($ips)) {
+        if (
+            null !== $ips
+            && '' != \trim($ips)
+        ) {
             $ending6   = ['', '::'];
             $ending4   = ['', '.255', '.255.255', '.255.255.255'];
             $addresses = \explode(' ', $ips);
@@ -802,7 +806,10 @@ class Bans extends Admin
      */
     public function vEmailBan(Validator $v, $email)
     {
-        if ('' != \trim($email)) {
+        if (
+            null !== $email
+            && '' != \trim($email)
+        ) {
             $error = true;
 
             if (
@@ -832,7 +839,10 @@ class Bans extends Admin
      */
     public function vExpireBan(Validator $v, $expire)
     {
-        if ('' != \trim($expire)) {
+        if (
+            null !== $expire
+            && '' != \trim($expire)
+        ) {
             if (\strtotime($expire . ' UTC') - \time() < 86400) {
                 $v->addError('Invalid date message');
             }

+ 1 - 1
app/Models/Pages/Admin/Users/Result.php

@@ -107,7 +107,7 @@ class Result extends Users
         }
 
         $startNum = ($page - 1) * $this->c->config->o_disp_users;
-        $idsN     = \array_slice($idsN, $startNum, $this->c->config->o_disp_users);
+        $idsN     = \array_slice($idsN, $startNum, (int) $this->c->config->o_disp_users);
         $ids      = [];
         $userList = [];
 

+ 1 - 1
app/Models/Pages/Admin/Users/Stat.php

@@ -27,7 +27,7 @@ class Stat extends Users
         }
 
         $startNum = ($page - 1) * $this->c->config->o_disp_users;
-        $stat     = \array_slice($stat, $startNum, $this->c->config->o_disp_users);
+        $stat     = \array_slice($stat, $startNum, (int) $this->c->config->o_disp_users);
 
         $user = $this->c->users->load((int) $args['id']);
 

+ 1 - 1
app/Models/Pages/Userlist.php

@@ -91,7 +91,7 @@ class Userlist extends Page
 
         if ($number) {
             $this->startNum = ($page - 1) * $this->c->config->o_disp_users;
-            $ids            = \array_slice($ids, $this->startNum, $this->c->config->o_disp_users);
+            $ids            = \array_slice($ids, $this->startNum, (int) $this->c->config->o_disp_users);
             $this->userList = $this->c->users->loadByIds($ids);
 
             $links = [];

+ 1 - 1
app/Models/Search/ActionP.php

@@ -62,7 +62,7 @@ class ActionP extends Method
         $this->model->idsList = \array_slice(
             $list,
             ($this->model->page - 1) * $this->c->user->disp_posts,
-            $this->c->user->disp_posts
+            (int) $this->c->user->disp_posts
         );
 
         return $this->c->posts->view($this->model);

+ 1 - 1
app/Models/Search/ActionT.php

@@ -112,7 +112,7 @@ class ActionT extends Method
         $this->model->idsList = \array_slice(
             $list,
             ($this->model->page - 1) * $this->c->user->disp_topics,
-            $this->c->user->disp_topics
+            (int) $this->c->user->disp_topics
         );
 
         return $this->c->topics->view($this->model);