Changeset 11966
- Timestamp:
- 09/03/07 11:59:38 (1 year ago)
- Files:
-
- branches/MidCOM_2_8/midcom.core/midcom/baseclasses/core/dbobject.php (modified) (3 diffs)
- branches/MidCOM_2_8/midcom.core/midcom/baseclasses/database/attachment.php (modified) (1 diff)
- branches/MidCOM_2_8/midcom.core/midcom/baseclasses/database/parameter.php (modified) (1 diff)
- branches/MidCOM_2_8/midcom.helper.datamanager2/type/blobs.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/MidCOM_2_8/midcom.core/midcom/baseclasses/core/dbobject.php
r11474 r11966 426 426 427 427 // Delete all extensions: 428 $list = $object->list_attachments(); 429 foreach ($list as $attachment) 430 { 431 if (! $attachment->delete()) 432 { 433 debug_add("Failed to delete attachment ID {$attachment->id}", MIDCOM_LOG_ERROR); 434 // debug_print_r('Full record:', $attachment); 435 debug_pop(); 436 return false; 428 // Attachments can't have attachments so no need to query those 429 if (!is_a($object, 'midcom_baseclasses_database_attachment')) 430 { 431 $list = $object->list_attachments(); 432 foreach ($list as $attachment) 433 { 434 if (! $attachment->delete()) 435 { 436 debug_add("Failed to delete attachment ID {$attachment->id}", MIDCOM_LOG_ERROR); 437 // debug_print_r('Full record:', $attachment); 438 debug_pop(); 439 return false; 440 } 437 441 } 438 442 } … … 1884 1888 1885 1889 $qb = $_MIDCOM->dbfactory->new_query_builder('midcom_baseclasses_database_attachment'); 1886 $qb->add_constraint('ptable', '=', $object->__table__); 1887 $qb->add_constraint('pid', '=', $object->id); 1890 $qb->add_constraint('parentguid', '=', $object->guid); 1888 1891 1889 1892 debug_pop(); … … 1906 1909 debug_add('Cannot retrieve attachments on a non-persistant object.', MIDCOM_LOG_WARN); 1907 1910 debug_pop(); 1908 return false;1911 return array(); 1909 1912 } 1910 1913 1911 1914 $qb = $object->get_attachment_qb(); 1912 1915 $result = $_MIDCOM->dbfactory->exec_query_builder($qb); 1916 if ( !$result 1917 || !is_array($result)) 1918 { 1919 return array(); 1920 } 1913 1921 1914 1922 debug_pop(); branches/MidCOM_2_8/midcom.core/midcom/baseclasses/database/attachment.php
r5787 r11966 49 49 function get_parent_guid_uncached() 50 50 { 51 $possible_parent_classes = $_MIDCOM->dbclassloader->get_classes_for_table($this->ptable); 52 if (count($possible_parent_classes) == 0) 53 { 54 debug_push_class(__CLASS__, __FUNCTION__); 55 debug_add("Failed to retrieve the parent object for Attachment {$this->id}, parent table {$this->ptable} is unknown to the class loader.", MIDCOM_LOG_WARN); 56 debug_pop(); 51 if (!$this->parentguid) 52 { 57 53 return null; 58 54 } 59 55 60 $classname = $possible_parent_classes[0]['midcom_class_name']; 61 $_MIDCOM->dbclassloader->load_mgdschema_class_handler($classname); 62 $parent = new $classname($this->pid); 63 64 if ( ! $parent 65 || $parent->id != $this->pid) 66 { 67 debug_push_class(__CLASS__, __FUNCTION__); 68 debug_add("Failed to retrieve the parent object for Attachment {$this->id}, could not retrieve parent object.", MIDCOM_LOG_WARN); 69 debug_print_r('Retrieved object was:', $parent); 56 $parent = $_MIDCOM->dbfactory->get_object_by_guid($this->parentguid); 57 if (! $parent) 58 { 59 debug_push_class(__CLASS__, __FUNCTION__); 60 debug_add("Could not load Parameter parent {$this->parentguid} from the database, aborting.", 61 MIDCOM_LOG_INFO); 70 62 debug_pop(); 71 63 return null; branches/MidCOM_2_8/midcom.core/midcom/baseclasses/database/parameter.php
r4994 r11966 47 47 { 48 48 debug_push_class(__CLASS__, __FUNCTION__); 49 debug_add("Could not load Parameter ID {$this->up} from the database, aborting.",49 debug_add("Could not load Parameter parent {$this->parentguid} from the database, aborting.", 50 50 MIDCOM_LOG_INFO); 51 51 debug_pop(); branches/MidCOM_2_8/midcom.helper.datamanager2/type/blobs.php
r11014 r11966 563 563 if (! $this->update_attachment_by_handle($identifier, $filename, $title, $mimetype, $handle, true, $tmpname)) 564 564 { 565 fclose($handle);565 @fclose($handle); 566 566 debug_push_class(__CLASS__, __FUNCTION__); 567 567 debug_add('Failed to create attachment, see above for details.');
