Welcome Guest, Not a member yet? Register   Sign In
Why BaseController & public/index.php file is loaded again & again in a single call?
#1
Star 
(This post was last modified: 08-05-2021, 04:11 AM by myo.)

Hi,
I was trying to dig into an issue & during that I observed that if I call the following URL, the files & classes: AdminControllerBaseControllerpublic/index.php are loaded and/or called multiple times during a single call. 
I don't have any redirects and have even no routing rules. Its a simple call to an index method of AdminController which extends BaseController.

Upto point 6 below looks normal but after that multiple calls make no sense. Can anyone please explain?

URL: http://localhost/web/public/admincontroller/index
==========================================
1)  public/index.php: 2021-08-05 10:45:38.630
----------------------------------------------------------------------
2)  AdminController.php (file included): 2021-08-05 15:45:38.795
----------------------------------------------------------------------
3)  BaseController.php (file included): 2021-08-05 15:45:38.796
----------------------------------------------------------------------
4)  AdminController/__construct(): 2021-08-05 15:45:38.825
----------------------------------------------------------------------
5)  BaseController/initController(): 2021-08-05 15:45:38.828
----------------------------------------------------------------------
6)  AdminController/index(): 2021-08-05 15:45:38.840
----------------------------------------------------------------------
//********************************************************************

7)  AdminController/__construct(): 2021-08-05 15:45:38.873
----------------------------------------------------------------------
8)  BaseController/initController(): 2021-08-05 15:45:38.876
----------------------------------------------------------------------
9)  AdminController/__construct(): 2021-08-05 15:45:38.894
----------------------------------------------------------------------
10) BaseController/initController(): 2021-08-05 15:45:38.898
----------------------------------------------------------------------
11) public/index.php: 2021-08-05 10:45:40.664
----------------------------------------------------------------------
12) public/index.php: 2021-08-05 10:45:41.096
----------------------------------------------------------------------
Reply
#2

We would need line numbers to be able to follow this trace in a meaningful way. I would say this definitely doesn’t seem normal.
Reply
#3

(08-07-2021, 04:41 AM)MGatner Wrote: We would need line numbers to be able to follow this trace in a meaningful way. I would say this definitely doesn’t seem normal.

Its very easy to reproduce. Just put the following code in public/index.php, BaseController.php, AnyController.php(extended from BaseController). 

In class files, put this code two times, once at the class level & then inside constructor. Now run the app & review the log.

Replace the path to your actual path & replace FileName with the file you are putting the code in.

PHP Code:
$file fopen('D:/apache2/htdocs/web/writable/' "logs/my_log.txt""a");
$date date_create();
fwrite($file"FileName: " date_format($date"Y-m-d H:i:s.v"));
fclose($file); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB