Changeset 288

Show
Ignore:
Timestamp:
07/22/07 20:49:43 (1 year ago)
Author:
bermiferrer
Message:

- [286] Can make PHP4 to behave in odd ways because of its case insensitiveness. Now, forbidden columns are hardcoded to avoid that situation.
- Removing memory limit on testing environment.
- Forcing showing errors on development and testing environments. This removes a common annoyance that requires to modify the php.ini directive even is the same machine hosts production and development applications.
- Adding the possibility to handle database connection errors using a user defined function specified by the constant 'AK_DATABASE_CONNECTION_FAILURE_CALLBACK'.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/config/development.php

    r264 r288  
    44// See file boot.php for more info 
    55 
     6@ini_set('display_errors', 1); 
     7 
    68define('AK_ENABLE_STRICT_XHTML_VALIDATION', false); // At least until the validator is fully tested 
    79 
  • trunk/config/testing.php

    r252 r288  
    44// See file boot.php for more info 
    55 
     6@ini_set('display_errors', 1); 
     7@ini_set('memory_limit', -1); 
    68 
    79$GLOBALS['ak_test_db_dns'] = isset($dsn) ? $dsn : $testing_database; 
  • trunk/lib/Ak.php

    r285 r288  
    7979 
    8080            if (!$db[$connection_id] = (AK_DEBUG ? NewADOConnection($dsn) : @NewADOConnection($dsn))){ 
    81                 trigger_error(Ak::t('Connection to the database failed'), E_USER_ERROR); 
    82                 exit; 
     81                error_reporting(E_ALL); 
     82                if(defined('AK_DATABASE_CONNECTION_FAILURE_CALLBACK') && function_exists(AK_DATABASE_CONNECTION_FAILURE_CALLBACK)){ 
     83                    $fn = AK_DATABASE_CONNECTION_FAILURE_CALLBACK; 
     84                    $fn(); 
     85                } 
     86                die(Ak::t('Connection to the database failed.').' '. 
     87                (AK_DEBUG?preg_replace('/\/\/(\w+):(.*)@/i','//$1:******@', $dsn)."\n":'')); 
    8388            } 
    8489            $db[$connection_id]->debug = AK_DEBUG == 2; 
  • trunk/lib/AkInstaller.php

    r286 r288  
    555555    function _canUseColumn($column_name) 
    556556    { 
    557         static $invalid_columns; 
    558  
    559         if(empty($invalid_columns)){ 
    560             $invalid_columns = $this->_getInvalidColumnNames(); 
    561         } 
     557        $invalid_columns = $this->_getInvalidColumnNames(); 
    562558        if(in_array($column_name, $invalid_columns)){ 
     559             
    563560            $method_name_part = AkInflector::camelize($column_name); 
     561            require_once(AK_LIB_DIR.DS.'AkActiveRecord.php'); 
    564562            $method_name = (method_exists(new AkActiveRecord(), 'set'.$method_name_part)?'set':'get').$method_name_part; 
    565563 
     
    579577    function _getInvalidColumnNames() 
    580578    { 
    581         $methods = Ak::get_this_object_methods(new AkActiveRecord()); 
    582  
    583         $conditions = AK_ACTIVE_RECORD_ENABLE_CALLBACK_SETTERS ? 'set' : ''; 
    584         $conditions .= AK_ACTIVE_RECORD_ENABLE_CALLBACK_GETTERS ? (!empty($conditions)?'|':'').'get' : ''; 
    585  
    586         $invalid_column_names = array(); 
    587  
    588         if(!empty($conditions)){ 
    589             foreach ($methods as $method){ 
    590                 if(preg_match('/^('.$conditions.')/',$method)){ 
    591                     $column = AkInflector::underscore(substr($method,3)); 
    592                     if(!empty($column) && $column != 'id'){ 
    593                         $invalid_column_names[] = $column; 
    594                     } 
    595                 } 
    596             } 
    597         } 
    598         return $invalid_column_names; 
     579        return defined('AK_INVALID_ACTIVE_RECORD_COLUMNS') ? explode(',',AK_INVALID_ACTIVE_RECORD_COLUMNS) : array('sanitized_conditions_array','conditions','inheritance_column','inheritance_column', 
     580        'subclasses','attribute','attributes','attribute','attributes','accessible_attributes','protected_attributes', 
     581        'serialized_attributes','available_attributes','attribute_caption','primary_key','column_names','content_columns', 
     582        'attribute_names','combined_subattributes','available_combined_attributes','connection','connection','primary_key', 
     583        'table_name','table_name','only_available_atrributes','columns_for_atrributes','columns_with_regex_boundaries','columns', 
     584        'column_settings','column_settings','akelos_data_type','class_for_database_table_mapping','display_field','display_field', 
     585        'internationalized_columns','avaliable_locales','current_locale','attribute_by_locale','attribute_locales', 
     586        'attribute_by_locale','attribute_locales','attributes_before_type_cast','attribute_before_type_cast','serialize_attribute', 
     587        'available_attributes_quoted','attributes_quoted','column_type','value_for_date_column','observable_state', 
     588        'observable_state','observers','errors','base_errors','errors_on','full_error_messages','array_from_ak_string', 
     589        'attribute_condition','association_handler','associated','associated_finder_sql_options','association_option', 
     590        'association_option','association_id','associated_ids','associated_handler_name','associated_type','association_type', 
     591        'collection_handler_name','model_name','model_name','parent_model_name','parent_model_name'); 
    599592    } 
    600593