Changeset 22751

Show
Ignore:
Timestamp:
06/30/09 18:05:47 (1 year ago)
Author:
bergie
Message:

Bulletproofing related to Ragnaland, refs #1251

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ragnaroek/midcom/midcom.core/midcom/baseclasses/core/dbobject.php

    r22723 r22751  
    106106        debug_push_class($object, __FUNCTION__); 
    107107 
    108         if ($object->_use_rcs)  
     108        if (   $GLOBALS['midcom_config']['midcom_services_rcs_enable'] 
     109            && $object->_use_rcs)  
    109110        { 
    110111            $rcs =& $_MIDCOM->get_service('rcs'); 
     
    423424        { 
    424425            $tmp = new $object->__mgdschema_class_name__(); 
    425             if (! $tmp->get_by_id($object->id)) 
     426            if (   !$object->id 
     427                || !$tmp->get_by_id($object->id)) 
    426428            { 
    427429                debug_push_class($object, __FUNCTION__); 
    428                 debug_add('Workaround for #72/#118, failed to get_by_id to load the GUID, this is bad. We abort.', 
     430                debug_add('Workaround for #72/#118/#1251, failed to get_by_id to load the GUID, this is bad. We abort.', 
    429431                    MIDCOM_LOG_CRIT); 
    430432                debug_add("We tried to load object {$object->id} and got: " . midgard_connection::get_error_string()); 
    431433                $object->delete(); 
    432434                $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 
    433                     'Workaround for #72/#118: Failed to load GUID for ID {$object->id} (' 
     435                    "Workaround for #72/#118/#1251: Failed to load GUID for ID {$object->id} (" 
    434436                    . midgard_connection::get_error_string() 
    435437                    . '). Object could not be created.'); 
     
    447449        $object->_on_created(); 
    448450        $_MIDCOM->componentloader->trigger_watches(MIDCOM_OPERATION_DBA_CREATE, $object); 
    449         if ($object->_use_rcs)  
     451        if (   $GLOBALS['midcom_config']['midcom_services_rcs_enable'] 
     452            && $object->_use_rcs)  
    450453        { 
    451454            $rcs =& $_MIDCOM->get_service('rcs'); 
     
    478481    function delete_pre_checks(&$object) 
    479482    { 
     483        if (!$object->id) 
     484        { 
     485            debug_push_class($object, __FUNCTION__); 
     486            debug_add("Failed to delete object, object " . get_class($object) . " is non-persistent (empty ID).", MIDCOM_LOG_ERROR);                
     487            debug_pop(); 
     488            return false; 
     489        } 
     490 
    480491        // Current language is not zero, selective delete to prevent deleting too much of objects. 
    481492        // Object will not be deleted if it doesn't have a language property at all or if its 
     
    682693        $object->_on_deleted(); 
    683694        $_MIDCOM->componentloader->trigger_watches(MIDCOM_OPERATION_DBA_DELETE, $object); 
    684         if ($object->_use_rcs)  
     695        if (   $GLOBALS['midcom_config']['midcom_services_rcs_enable'] 
     696            && $object->_use_rcs)  
    685697        { 
    686698            $rcs =& $_MIDCOM->get_service('rcs'); 
     
    12821294    function get_by_id(&$object, $id) 
    12831295    { 
     1296        if (!$id) 
     1297        { 
     1298            debug_push_class($object, __FUNCTION__); 
     1299            debug_add("Failed to load " . get_class($object) . " object, incorrect ID provided.", MIDCOM_LOG_ERROR); 
     1300            self::_clear_object($object); 
     1301            debug_pop(); 
     1302            return false; 
     1303        } 
     1304 
    12841305        if (   !isset($object->__object) 
    12851306            || !$object->__object)