Page 1 of 1

ajax bug in 1.2.4

PostPosted: Thu Jun 17, 2010 5:04 pm
by kevinwen
Hi, Steve

I found a bug in 1.2.4 when deleting an attachement, while I do it well in 1.2.2. Our application uses E_ALL level for error reporting. Here's how I recreate the bug:

In 1.2.4, $fieldDef['mimetype'] is undefined at line 62 in xataface/actions/delete_file.php, and evaluating it will result in a E_NOTICE because of E_ALL level of error reporting. In chain, it returns this as part of the response to XHR object, even if all actions were completely done. That's why an exception is thrown in xataface/js/delete_file.js.

Code: Select all
$mimeTypeField =& $record->_table->getField($fieldDef['mimetype']);


In 1.2.2, since you put the following code in xataface/dataface-public-api.php at line 44, the problem above won't happen because E_NOTICE will not be reported:

Code: Select all
error_reporting(E_ALL^E_NOTICE);


Can we do something to solve this problem, or you would consider this as a bug?

Re: ajax bug in 1.2.4

PostPosted: Fri Jun 18, 2010 9:51 am
by shannah
I have fixed this in SVN. Here is the DIFF:

Code: Select all
Index: delete_file.php
===================================================================
--- delete_file.php   (revision 1867)
+++ delete_file.php   (revision 1868)
@@ -59,9 +59,11 @@
         @unlink($filePath);
         
         $record->setValue($fieldDef['Field'], null);
-         $mimeTypeField =& $record->_table->getField($fieldDef['mimetype']);
-         if ( !PEAR::isError($mimeTypeField) ){
-            $record->setValue($fieldDef['mimetype'], null);
+         if ( @$fieldDef['mimetype'] ){
+            $mimeTypeField =& $record->_table->getField($fieldDef['mimetype']);
+            if ( !PEAR::isError($mimeTypeField) ){
+               $record->setValue($fieldDef['mimetype'], null);
+            }
         }
         $res = $record->save();
         if ( PEAR::isError($res) ) return $res;