Project Beehive ForumNull values from query functions.

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Matt  
 To:  Peter (BOUGHTONP)      
42762.8 In reply to 42762.2 
$db->query (which is a wrapper around mysqli::query) can return false, so adding a call to ->num_rows to it won't always work (as you now already know), but you could check for $result->num_rows afterwards, e.g.:
 
Code: 
if (!($result = $db->query($sql))) return false;

if ($result->num_rows === 0) return false;
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)   
 To:  Matt     
42762.9 In reply to 42762.8 
So I finally got around to checking this properly and confirmed there are just three files where that num_rows check needs to be added - all the others already have suitable code in place.
(Are you ok with me pushing that direct to main GitHub repo, or would you prefer it done as a pull request?)


There's also an issue of get_magic_quotes_gpc being deprecated in PHP 7.x and removed in PHP 8.0

The easy fix for PHP 7.x is to not error on deprecation warnings (except in developer mode), so would you be ok with this change:

diff --git a/forum/boot.php b/forum/boot.php
index e98cf631e..64ecb8a7b 100644
--- a/forum/boot.php
+++ b/forum/boot.php
@@ -47,7 +47,12 @@ require_once BH_INCLUDE_PATH . 'constants.inc.php';
 require_once BH_INCLUDE_PATH . 'errorhandler.inc.php';

 // Set the error reporting level to report all errors
-error_reporting(E_ALL | E_STRICT);
+error_reporting(E_ALL);
+
+// Only show deprecation warnings to developers
+if (!defined("BEEHIVE_DEVELOPER_MODE")){
+    error_reporting(error_reporting() & ~E_DEPRECATED);
+}

 // Enable the error handler
 set_error_handler('bh_error_handler');
?

I think the backwards-compatible fix for PHP 8.x involves switching "get_magic_quotes_gpc()" with "ini_get('magic_quotes_gpc')", but there are also people saying such checks should assume "false" and/or relevant code removed entirely...?

0/0
 Reply   Quote More 

Reply to All    
 

1–9

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2021 Project Beehive Forum

Forum Stats