[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Avoid NaN offset in customsearch pagination links

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69294018e8524_2a17b7a42193d@gitlab-sidekiq-low-urgency-cpu-bound-v2-5df5c99858-sjf46.mail>

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


Commits:
586db726 by Doddy MATABARO at 2025-11-28T06:16:31+00:00
[FIX] Avoid NaN offset  in customsearch pagination links
---
* [FIX] Improve offset calculation in custom search by using maxRecords attribute

* [FIX] Correct offset initialization in custom search plugin

See merge request tikiwiki/tiki!9140

- - - - -


2 changed files:

- lib/jquery_tiki/customsearch.js
- lib/wiki-plugins/wikiplugin_customsearch.php


Changes:

=====================================
lib/jquery_tiki/customsearch.js
=====================================
@@ -158,8 +158,10 @@
 
         const pagenum = parseInt($('.pagination .active').text());
         if (pagenum > 1) {        // offset
-            const max = $("#max", $csForm).val();
-            ser += "offset=" + (pagenum - 1) * max;
+            const max = customsearch_0.maxRecords || $("#max", $csForm).val();
+            if (max) {
+                ser += "offset=" + (pagenum - 1) * max;
+            }
         }
 
         const $sortLink = $("th a .icon-sort-up,th a .icon-sort-down", ".customsearch_results").parent();


=====================================
lib/wiki-plugins/wikiplugin_customsearch.php
=====================================
@@ -212,7 +212,7 @@ function wikiplugin_customsearch($data, $params)
     } else {
         $recalllastsearch = 0;
     }
-    $offset = (int) $_REQUEST["offset"] ?? 0;
+    $offset = (int) ($_REQUEST["offset"] ?? 0);
     if (isset($_REQUEST['maxRecords'])) {
         $maxRecords = (int) $_REQUEST['maxRecords'];
     } elseif ($recalllastsearch && ! empty($_SESSION["customsearch_$id"]['maxRecords'])) {



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/586db726fe474014ccf3510615911f7b7d5953b3
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.