Changeset 6176

Show
Ignore:
Timestamp:
06/04/07 10:17:28 (1 year ago)
Author:
bergie
Message:

Make datamanager2 autoset_storage handle situations with changed schema databases more gracefully, fixes #52 (accept liberal input, be strict in output)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.datamanager2/datamanager.php

    r6087 r6176  
    221221     * @param mixed $object A reference to either a MidCOM DBA class or a subclass of 
    222222     *     midcom_helper_datamanager2_storage. 
     223     * @param bool $strict Whether we should strictly use only the schema given by object params 
    223224     * @return bool Indicating success. 
    224225     */ 
    225     function autoset_storage(&$object
     226    function autoset_storage(&$object, $strict = false
    226227    { 
    227228        if (is_a($object, 'midcom_helper_datamanager2_storage')) 
     
    239240        } 
    240241 
    241         if (! $this->set_schema($schema)) 
    242         { 
    243             return false; 
     242        if (!$this->set_schema($schema)) 
     243        { 
     244            if (   $strict 
     245                || $schema == null) 
     246            { 
     247                return false; 
     248            } 
     249            else 
     250            { 
     251                debug_push_class(__CLASS__, __FUNCTION__); 
     252                debug_add("Given schema name {$schema} was not found, reverting to default.", MIDCOM_LOG_INFO); 
     253                debug_pop(); 
     254                // Schema database has probably changed so we should be graceful here 
     255                if (!$this->set_schema(null)) 
     256                { 
     257                    return false; 
     258                } 
     259            } 
     260 
    244261        } 
    245262        return $this->set_storage($object);