The great thing about software is that it always behaves in a logical and predictive pattern but sometimes that does not seem to be the case. When I added a date first elected report to my Australian Parliament pages I started to question this principle.
Using my Delphi CGI web frame work coupled with an Indy server allows Interactive Testing and Debugging of the various page calculations and database interactions so the additional code was quite trivial and using Indy on port 8080 of my development machine a site was soon working and tested.
Deployment only required compiling the code without the Indy server and copying the new CGI executable to the active server. Once done all looked great but closer examination raised concern over the figures shown. One Nation reports crashed and no Green entered parliament before age 40.
Made a local copy of the actual site database to the development machine and retested as there was obviously a Db error. All still works well locally. Reviewed the ini files as maybe an old db it being used by the server. Set up a WEB server on the local test platform and used the CGI executable there. Copy the Indy port 8080 server to the WEB server and it still worked fine so remote Interactive debugging on the server via Delphi and Indy offered no solution. Fell back to inserting Writelns and log messages into the code to Debug this impossible situation. This was made more difficult as it required extended copying for each iteration.
Finally it all made sense and I record the situation here so that it might help others but also will hopefully set it in my mind.
A secure working web server operates under a special account which has great powers but with very specific restrictions so the world is not able to substitute pages etc. At first I thought maybe these restrictions were causing issues but an exception should have been reported.
The problem was more subtle. If an MP’s date of birth is not found then they fall into the less than 10 years old column and are rejected. This is what was happening but only when we went live. I knew I had manually added the few missing birth dates to the live database. Light bulb moment – a little library routine first tests a date using standard date decoding and only when that fails do we look at other possible ways of entering a date. My test platform and my user accounts on the server all had Australian Format date settings and worked fine.
The Web Server account however defaulted to US formatting and the standard decoder erroneously felt it was receiving valid dates from some of the entries on the Parliamentary Web Site. The fix was to simply specify the global format settings in the application to align with Australia making the world stop behaving weirdly and allowing order to return.