4892: ContentDAO.isFieldsValid() return value should not be tied to $msg->containsErr...
authorTJ <acontent@iam.tj>
Thu, 20 Oct 2011 12:51:55 +0000 (13:51 +0100)
committerTJ <acontent@iam.tj>
Thu, 20 Oct 2011 13:42:01 +0000 (14:42 +0100)
This function would erroneously return 'false' if the $msg array contained errors prior to
entry into the function. This sometimes caused unexplained IMS CC import failures when
inserting new lessons into the database.

Use a local return result to ensure accurate result.

include/classes/DAO/ContentDAO.class.php

index af77fe3..7112966 100644 (file)
@@ -269,6 +269,7 @@ class ContentDAO extends DAO {
        private function isFieldsValid($action_type, $row_id, $title)
        {
                global $msg;
+               $result = true;
                
                $missing_fields = array();
                
@@ -284,15 +285,12 @@ class ContentDAO extends DAO {
                
                if ($missing_fields)
                {
-                       $missing_fields = implode(', ', $missing_fields);
-                       $msg->addError(array('EMPTY_FIELDS', $missing_fields));
+                       $msg->addError(array('EMPTY_FIELDS', implode(', ', $missing_fields)));
+                       $result = false;
                }
                
-               if (!$msg->containsErrors())
-                       return true;
-               else
-                       return false;
+               return $result;
        }
 
 }
-?>
\ No newline at end of file
+?>