![]() |
[CI4] Toolbar DB Query And Event Duplication - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: [CI4] Toolbar DB Query And Event Duplication (/showthread.php?tid=77765) Pages:
1
2
|
[CI4] Toolbar DB Query And Event Duplication - Awlikhaleghi - 10-15-2020 Hi everybody. I'm relatively new with the CI4, I've been learning it as I go and to be honest loving the changes so far. My DB Queries are happening twice, no matter where they're executed from. ![]() these queries are being executed from several different files. the function which runs the query is a helper as follows: PHP Code: function getOption(string $key) and the `getOption()` function inside OptionsModel is as: PHP Code: public function getOption(string $key){ no matter how the query is being executed, the CI4 toolbar is always recording two of each SELECT query. my inserts are fine and are happening only once. and also my Events are happening twice as well. Meaning having the following code in a view file: PHP Code: \CodeIgniter\Events\Events::trigger('TEST'); PHP Code: Events::on('TEST', function () { if anyone can point me to the right direction so I can troubleshoot this it'd be greatly appreacated. RE: [CI4] Toolbar DB Query And Event Duplication - InsiteFX - 10-15-2020 Try renaming your function to getOpt() RE: [CI4] Toolbar DB Query And Event Duplication - Awlikhaleghi - 10-16-2020 (10-15-2020, 11:04 PM)InsiteFX Wrote: Try renaming your function to getOpt()didn't work. as I mentioned it doesn't matter where the query is executing from whether its a model or a direct query in a view. RE: [CI4] Toolbar DB Query And Event Duplication - Awlikhaleghi - 10-16-2020 I'm really hanging here, I need to fix this fast but so far I can't figure out why these duplications are happening. Any other ideas out there? RE: [CI4] Toolbar DB Query And Event Duplication - Awlikhaleghi - 10-16-2020 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() Code: array(2) { 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')) Now I'm back at db queries, still looking for answers; I will post the solution if I found one. RE: [CI4] Toolbar DB Query And Event Duplication - Awlikhaleghi - 10-16-2020 WOW! Actually that one simple modification fixed both events and db queries, I guess they were linked somehow. I'm done, thanks anyways. RE: [CI4] Toolbar DB Query And Event Duplication - InsiteFX - 10-16-2020 PHP Code: // Change this to the below. RE: [CI4] Toolbar DB Query And Event Duplication - Awlikhaleghi - 10-16-2020 That would not have helped either, I've posted my fix and it's being moderated. thanks for the effort anyways! RE: [CI4] Toolbar DB Query And Event Duplication - paulbalandan - 10-20-2020 You are modifying the core Events class, which on subsequent CI updates your changes will unfortunately be overridden. I think you hit the jackpot there but instead of modifying the check on events discovery, you should check instead if the file to be included is not the same app file in app/Config/Events.php . I think you should open an issue ticket in the Github repo to properly address this. RE: [CI4] Toolbar DB Query And Event Duplication - paulbalandan - 10-24-2020 Good news!! This has been fixed in latest develop branch. |