This topic is locked

After Table Initialised Event

4/19/2019 4:08:00 PM
PHPRunner General questions
T
thamestrader author

Has anyone else experienced the After Table Initialised (ATI) events behaving differently in v10.1 from how it behaved in v10 and earlier versions? It seems that ATI events for other tables can be called after the ATI event for the table being accessed. I discovered this when testing my application after upgrading to v10.1 and two features no longer worked as they did in v10 (and v9.6 before that).
In my application I have 6 tables with After Table Initialised (ATI) events, all of them using code to alter the where clause with $query->addWhere. Two of the ATI events obtain a table specific parameter (number of months) and then call the same function to calculate the archive before date, this date is included in the where clause to select records with a timestamp less than the archive before date, the archive before date is also saved in a shared $_SESSION variable. The $_SESSION variable is used to make the archive before date available in the Before Display event so that it can be displayed in a message to the user in the JSOnLoad event.
Table A is a custom view of the Master table, Table B is a custom view of the Detail table. All the other ATI events are for custom views of the Detail table. Tables A does have an inner join to the Detail table.
When accessing Table A its ATI event was called and the Where clause modified correctly with the archive before date, but the date displayed in the message was based on the parameter for Table B.
When accessing Table B its ATI event was called and the Where clause modified correctly with the archive before date, but the date displayed in the message was based on the parameter for Table A.
Putting some debug code into each ATI event enabled me to track which ATI events were called for each specific table access. The results showed many other ATI events were called for some tables, some multiple times.
I may well have coded something incorrectly which is causing this, but as it didn't happen in with V10 and earlier versions I'm not sure that is the reason.
Any thoughts or advice?
Thanks

admin 4/19/2019

There are multiple situations when AfterTableInit event maybe called ie master-details relationship is involved or one table is a source for a lookup wizard that another table uses. There is nothing wrong with it.
There is not enough info to fully understand the issue but my guess is that "shared $_SESSION variable" can be a problem. The order in which AfterAppInit events are called is not something you can reply on. You need to rethink your approach.