Browse code

search.php: fix MySQL error message overwriting the Search Results header for a failed penname search - remove temp error suppression workaround

Clarissa Walker authored on 2026/09/11 17:52:01
Showing 1 changed files
... ...
@@ -21,18 +21,6 @@
21 21
 // To read the license please visit http://www.gnu.org/copyleft/gpl.html
22 22
 // ----------------------------------------------------------------------
23 23
 
24
-// 'temp' error suppression for MySQL/MariaDB behavior in PHP 8 starting with 8.1
25
-//
26
-// script works right to an extent, but...
27
-// mysqli STRICT enabled - shows a MYSQL error message in place of the Search Results header (not ideal)
28
-// mysqli STRICT disabled - brings up a PHP warning regarding accessing num_rows on false in another script
29
-//
30
-// this only affects searching a penname that is confirmed not to exist
31
-
32
-ini_set('display_errors', 0);
33
-ini_set('display_startup_errors', 0);
34
-error_reporting(0);
35
-mysqli_report(MYSQLI_REPORT_OFF);
36 24
 
37 25
 // Page Setup
38 26
 // Set the current page id.  Because search does multiple things there are multiple possibilities
... ...
@@ -92,7 +80,7 @@ if(isset($_POST['submit']) || isset($_GET['offset'])) {
92 80
 			while($auth = dbassoc($authorquery)) {
93 81
 				$authorlist[] = $auth['uid'];
94 82
 			}
95
-			if(count($authorlist) > 0) {
83
+			if(is_countable($authorlist) > 0) {
96 84
 				$authors = implode(",",$authorlist);
97 85
 				$query = "SELECT stories.*, "._PENNAMEFIELD." as penname, stories.date as date, stories.updated as updated FROM ("._AUTHORTABLE.", ".TABLEPREFIX."fanfiction_stories as stories) LEFT JOIN ".TABLEPREFIX."fanfiction_coauthors as coauth ON coauth.sid = stories.sid WHERE "._UIDFIELD." = stories.uid AND stories.validated > 0 AND (FIND_IN_SET(stories.uid, '$authors') > 0 OR FIND_IN_SET(coauth.uid, '$authors') > 0) ";
98 86
 				$countquery = "SELECT COUNT(stories.sid) FROM ".TABLEPREFIX."fanfiction_stories as stories LEFT JOIN ".TABLEPREFIX."fanfiction_coauthors as coauth ON coauth.sid = stories.sid WHERE stories.validated > 0 AND (FIND_IN_SET(stories.uid, '$authors') > 0 OR FIND_IN_SET(coauth.uid, '$authors') > 0)";