Monday 23 May 2022

MapGuide dev diary: ... and now we begin the great migration

Previously, we made some important breakthroughs on the PHP8 binding for MapGuide. Our sanity PHP tests passed (meaning that the core essentials of the MapGuide API were working), but the main PHP test suite itself had a large amount of failures.


Thanks to dead-easy PHP debugging in VSCode, I was able to step into the PHP test code line-by-line and was able to discover that most of these failures was due to a change in how we're meant to be reading out expected test results from our test fixture SQLite databases. We were reading out test results as SQLite BLOBs which broke test result comparison in PHP8. Switching over to reading out these test results as strings instead fixed up along with updating how we check for exceptions thrown by the MapGuide API fixed up all but one test case.

That one remaining test case failure is due deleting a resource created in a preceding test that doesn't exist. While I could spend more time finding out why, the fact of the matter is that 99.9% of the current test suite is now passing on Windows, and it would be more fruitful now to sort out the revised bundling and configuration story with PHP 8 and try to get a working MapGuide installation with the PHP 8 bundled installation, fixing up whatever code and configurations along the way until we have all of our PHP-based MapGuide applications fully functional, which for reference is the following:

  • The Site Administrator
  • The Feature Source schema report/preview
  • The AJAX viewer with PHP backend
  • Fusion
In the process of getting a new MapGuide installation with bundled PHP 8 setup, I've changed how Apache httpd is set up to talk to PHP. Previously, we actually did something incorrect. We previously bundled the thread-safe build of PHP and used that for both Apache and IIS setups. It turns out we bundled the wrong kind of build for the IIS configuration, as we should have actually been using the NTS (non-thread-safe) build of PHP if setting up a MapGuide Web Tier with IIS and FastCGI.

In the interest of getting things right this time round and not have to bundle 2 copies of PHP (TS and NTS builds), I've decided to go all in on using the NTS build of PHP for both IIS and Apache. This means that setting up IIS will now use the correct binaries for FastCGI, but means that we can no longer use mod_php when setting up Apache httpd as that can only be used with the thread-safe builds of PHP. Instead, for Apache httpd we will now set up FastCGI for use with PHP as well via mod_fcgid.

So I grabbed a compatible copy of mod_fcgid.so from apachelounge and dropped it into my httpd installation, updated httpd.conf to use FastCGI for PHP, flipped display_errors = On in php.ini, spun up both the MapGuide Server and httpd, opened the MapGuide Site Administrator and was greeted with the following.


And I am so glad to see this error message :)

Because that is an error message reported by PHP, so we know PHP itself (via FastCGI) is working.

Also the error is about a missing constants.php file, which if you've been following my previous posts is a file that is no longer necessary as our new PHP 8 bindings defines the constants within the binary extension itself.

This error is one of who-knows-how-many things in our PHP applications that will need fixing up to be PHP 8 compatible.

Time to start a-fixing!

No comments: