Welcome Guest, Not a member yet? Register   Sign In
[CI4] Toolbar DB Query And Event Duplication
#5

After quite some investigations here are my findings regarding Event duplications.
It happened to be Events.php file being included twice by CI Event Object.

PHP Code:
public static function initialize()
    {
        
// Don't overwrite anything....
        
if (static::$initialized)
        {
            return;
        }

        
$config config('Modules');

        
$files = [APPPATH 'Config/Events.php'];

        if (
$config->shouldDiscover('events'))
        {
            
$locator Services::locator();
            
$files   $locator->search('Config/Events.php');
        }

        static::
$files $files;


        foreach (static::
$files as $file)
        {
            if (
is_file($file))
            {
                include 
$file;
            }
        }

        static::
$initialized true;
    } 
this piece of code is finding two Events.php with two different paths (even though they're one file).
Code:
array(2) {
  [0]=>
  string(74) ".../public_html/Deli/Config/Events.php"
  [1]=>
  string(22) "Deli/Config/Events.php"
}

Although both files are in the same path, CI4 has decided that it is required for the files to be included.

Now I have slightly modified the function to:
Code:
if(false) //if ($config->shouldDiscover('events'))
{
$locator = Services::locator();
$files  = $locator->search('Config/Events.php');
}
this will disable auto discovery of Events.php and only includes the Events.php file defined previously.

Now I'm back at db queries, still looking for answers; I will post the solution if I found one.
Reply


Messages In This Thread
RE: [CI4] Toolbar DB Query And Event Duplication - by Awlikhaleghi - 10-16-2020, 07:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB