[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] PHP 8 deprecated warning when substr_count receives null

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <698601d57905a_3b14d12a4179ca@gitlab-sidekiq-low-urgency-cpu-bound-v2-59b6c466cd-bv99r.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
ff6fa10a by Yves Ngalamulume at 2026-02-06T14:43:10+00:00
[FIX] PHP 8 deprecated warning when substr_count receives null
---
* Avoid calling showWatchers with an invalid event

* Ensure non-null event is passed from Feedback::showWatchers

* Ensure non-null event is passed from Feedback::showWatchers

* Note that you can achieve the same effect just by typing the  argument in the function signature

* Fail fast when get_event_watches is called with a null event

* [FIX] PHP 8 deprecated warning when substr_count receives null

* [FIX] PHP 8 deprecated warning when substr_count receives null

See merge request tikiwiki/tiki!9474

- - - - -


3 changed files:

- lib/core/Feedback.php
- lib/core/Services/Comment/Controller.php
- lib/tikilib.php


Changes:

=====================================
lib/core/Feedback.php
=====================================
@@ -462,7 +462,7 @@ class Feedback
      *
      * @return void
      */
-    public static function showWatchers($watch_event, $object, $extra_event = null)
+    public static function showWatchers(string $watch_event, $object, $extra_event = null)
     {
         global $prefs;
         if ($prefs['feature_user_watches'] === 'y') {


=====================================
lib/core/Services/Comment/Controller.php
=====================================
@@ -218,6 +218,8 @@ class Services_Comment_Controller
                     $version
                 );
                 if ($threadId) {
+                    $watch_event = null;
+
                     switch ($type) {
                         case 'wiki page':
                             $watch_event = 'wiki_comment_changes';
@@ -257,8 +259,10 @@ class Services_Comment_Controller
                             $notification_url = '';
                             break;
                     }
-                    Feedback::showWatchers($watch_event, $objectId, 'thread_comment_replied');
-                    Feedback::sendHeaders();
+                    if ($watch_event) {
+                        Feedback::showWatchers($watch_event, $objectId, 'thread_comment_replied');
+                        Feedback::sendHeaders();
+                    }
 
                     // Set watch if requested
                     if ($prefs['feature_user_watches'] == 'y' && $watch == 'y') {


=====================================
lib/tikilib.php
=====================================
@@ -1120,7 +1120,7 @@ class TikiLib extends TikiDb_Bridge
      * @param null $info
      * @return array
      */
-    public function get_event_watches($event, $object, $info = null)
+    public function get_event_watches(string $event, $object, $info = null)
     {
         global $prefs;
         $ret = [];



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/ff6fa10a1ebbde781dadb47dfb504e6a58a8a327

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/ff6fa10a1ebbde781dadb47dfb504e6a58a8a327
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.