introduced isSqlResult() which encapsulates checking MySQL/i results
authorRoland Haeder <roland@mxchange.org>
Mon, 6 Jun 2016 20:05:26 +0000 (22:05 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 6 Jun 2016 20:05:26 +0000 (22:05 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
inc/db/lib-mysql.php
inc/db/lib-mysqli.php
inc/module-functions.php
inc/modules/admin/what-list_notifications.php

index 1cb749c44c05f6e02cded7f688e027903deca362..56cfe52861e791f6fa7a9c6dbc9cf989a2980cd9 100644 (file)
@@ -360,5 +360,11 @@ function isValidSqlLink ($linkResource) {
        return is_resource($linkResource);
 }
 
+// Checks whether given result is a valid SQL result
+function isSqlResult ($result) {
+       // TODO: Can't this be made better?
+       return is_resource($result);
+}
+
 // [EOF]
 ?>
index bfce1564a0d2447ff6f1980d7bf2b693eb093f34..b3559bf7e807a03548b5e511da1dd46517b9e87a 100644 (file)
@@ -346,7 +346,7 @@ function setSqlError ($file, $line, $message) {
 
 // Checks whether given link is a valid SQL link
 function isValidSqlLink ($linkInstance) {
-       // Is it a resource?
+       // Is it an object?
        $isValid = (($linkInstance instanceof mysqli) || ($linkInstance instanceof mysqli_result));
 
        // Debug message
@@ -356,5 +356,17 @@ function isValidSqlLink ($linkInstance) {
        return $isValid;
 }
 
+// Checks whether given result is really a result
+function isSqlResult ($resultInstance) {
+       // Is it a resource?
+       $isValid = ($resultInstance instanceof mysqli_result);
+
+       // Debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'resultInstance[]=' . gettype($resultInstance). ',isValid=' . intval($isValid));
+
+       // Return result
+       return $isValid;
+}
+
 // [EOF]
 ?>
index f5782820c8d024d4ba2b22660dd7377af9ee4432..41c45b648c6c39a751aff54cb80cf6a9f8633b2c 100644 (file)
@@ -80,7 +80,7 @@ function getModuleTitle ($module) {
                        }  else {
                                // No name found
                                $data['title'] = '{%message,UNKNOWN_MODULE_DETECTED_TITLE=' . $module . '%}';
-                               if ((is_resource($result)) && (ifSqlHasZeroNumRows($result))) {
+                               if ((isSqlResult($result)) && (ifSqlHasZeroNumRows($result))) {
                                        // Add module to database and ignore return value
                                        checkModulePermissions($module);
                                } // END - if
index 05fad58a3e016bd2ce0ab2940b64ae679265b9b3..eb8b135e4875ea0752cb229836293af84171af78 100644 (file)
@@ -74,7 +74,9 @@ ORDER BY
 $add = ' LIMIT ' . (bigintval(getRequestElement('offset')) * bigintval(getRequestElement('page')) - bigintval(getRequestElement('offset'))) . ', ' . bigintval(getRequestElement('offset'));
 
 // Add limitation
-if (!empty($SQL2)) $SQL2 .= $add;
+if (!empty($SQL2)) {
+       $SQL2 .= $add;
+} // END - if
 
 if ((isExtensionActive('bonus')) && (!ifSqlHasZeroNumRows($result_max)) && (!empty($SQL2))) {
        // Run SQL query for notification mails
@@ -107,7 +109,7 @@ if ((isExtensionActive('bonus')) && (!ifSqlHasZeroNumRows($result_max)) && (!emp
                // Load main template
                loadTemplate('admin_list_notify_emails', FALSE, $content);
        }
-} elseif ((sqlNumRows($result_max) === 0) && (is_resource($result_max))) {
+} elseif ((sqlNumRows($result_max) === 0) && (isSqlResult($result_max))) {
        // No notifications found
        displayMessage('{--ADMIN_NO_NOTIFICATIONS--}');
 }