• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
config log_threshold, log_path, et al ill not work if set from assign_to_config

#1
Lightbulb 
Hi guys,

Instead of editing config/config.php, I used $assign_to_config instead so that I will not have to touch what's inside config/config.php

But I noticed that the following will not work if set from $assign_to_config:


PHP Code:
$assign_to_config['log_threshold']
$assign_to_config['log_path']
$assign_to_config['log_date_format'


This is due to the fact that load_class itself uses log_message which will use the config inside config/config.php because $assign_to_config has not been added to $config during it's first init.

The $assign_to_config array eventually get copied to the $config but log_message will not be able to use it anymore .

My workaround was to edit directly Codeigniter.php and insert the array right after the subclass_prefix


PHP Code:
/*
 * ------------------------------------------------------
 *  Set the subclass_prefix
 * ------------------------------------------------------
 *
 * Normally the "subclass_prefix" is set in the config file.
 * The subclass prefix allows CI to know if a core class is
 * being extended via a library in the local application
 * "libraries" folder. Since CI allows config items to be
 * overridden via data set in the main index.php file,
 * before proceeding we need to know if a subclass_prefix
 * override exists. If so, we will set this value now,
 * before any classes are loaded
 * Note: Since the config file data is cached it doesn't
 * hurt to load it here.
 */
if ( ! empty($assign_to_config['subclass_prefix']))
{
 
   get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
}

// -- log temporary workaround --
if ( ! empty($assign_to_config['log_threshold']))
{
 
   get_config(array('log_threshold' => $assign_to_config['log_threshold']));
}
if ( ! empty(
$assign_to_config['log_path']))
{
 
   get_config(array('log_path' => $assign_to_config['log_path']));
}
if ( ! empty(
$assign_to_config['log_date_format']))
{
 
   get_config(array('log_date_format' => $assign_to_config['log_date_format']));
}
// -- 


I'm just a newbie to CodeIgniter and there might be a better solution to fix this and would love to hear your suggestions.

CI v3.1.9

Thanks a lot.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.