phpHtmlLib updated to v2.6.4.3566

I received another report from a user experiencing blank pages on some of the wp-SwimTeam tabs.  I had run into this previously and determined it to be a PHP issue in the early 5.3.x releases (.1 and .2 for sure).  PHP was terminating with a fatal error which resulted in an incomplete HTML page.  If you looked at the page source for these “blank” pages you would see nice HTML simply terminate with no closing tags which obviously resulted in missing content.

It turns out that phpHtmlLib was the culprit (which I suspected) and it was behavior that is inconsistent between releases of PHP including PHP4.

Many of the widgets in phpHtmlLib build upon one another by extending classes.  It is not uncommon to find some classes that are extended 3-4 levels.  No problem, that is one of the beauties of classes.  The problem came from some classes having constructors where some of their descendants did not AND the grand child (or great grand child) class referenced the parent constructor.

Because phpHtmlLib originated in PHP4, all of the syntax remains in PHP4 format including the use of class constructors.  The following example illustrates the problem I had run into:

<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */

class Sample_A {
    /**
     * Constructor
     */
    function Sample_A() {
        printf('<h3>%s::%s - Sample A Constructor</h3>', basename(__FILE__), __LINE__);
    }
}

class Sample_B extends Sample_A {
    /**
     * No Constructor!
     */
}

class Sample_C extends Sample_B {
    /**
     * Constructor
     */
    function Sample_C() {
        printf('<h4>%s::%s - Sample C Constructor</h4>', basename(__FILE__), __LINE__);
        parent::Sample_B() ;
    }
}


ini_set('display_errors','stdout');
error_reporting(E_STRICT | E_ALL) ;

printf('<h2>%s::%s - Instantiating Sample A</h2>', basename(__FILE__), __LINE__);
$A = new Sample_A() ;
printf('<h2>%s::%s - Instantiating Sample B</h2>', basename(__FILE__), __LINE__);
$B = new Sample_B() ;
printf('<h2>%s::%s - Instantiating Sample C</h2>', basename(__FILE__), __LINE__);
$C = new Sample_C() ;

?>

Running the code above results in the following with certain versions of PHP (e.g. 5.3.1).

<h2>sample.php::33 - Instantiating Sample A</h2>
<h3>sample.php::9 - Sample A Constructor</h3>
<h2>sample.php::35 - Instantiating Sample B</h2>
<h3>sample.php::9 - Sample A Constructor</h3>
<h2>sample.php::37 - Instantiating Sample C</h2>
<h4>sample.php::24 - Sample C Constructor</h4>

Fatal error: Call to undefined method Sample_B::Sample_B() in /var/www/clients/client3/web44/web/sample.php on line 25

Why does this happen? It turns out that earlier (and now later) versions of PHP would handle the missing constructor in Sample_B implicitly. Because some constructors are fairly complex and pass multiple arguments, I don’t really want to add all of the intermediate constructors just because some versions of PHP don’t handle the constructor chain properly (or at least consistently). So I came up with the following solution:

class Sample_B extends Sample_A {
    /**
     * Constructor - needed for early PHP 5.3.x compatibility
     *
     * @param Parent Constructor
     * @param array of Constructor Arguments
     */
    function Sample_B() {
	    call_user_func_array('parent::Sample_A', func_get_args()) ;
    }
}

Adding this constructor to the Sample_B class results in the following (which is what I want):

<h2>sample.php::39 - Instantiating Sample A</h2>
<h3>sample.php::9 - Sample A Constructor</h3>
<h2>sample.php::41 - Instantiating Sample B</h2>
<h3>sample.php::9 - Sample A Constructor</h3>
<h2>sample.php::43 - Instantiating Sample C</h2>
<h4>sample.php::30 - Sample C Constructor</h4>
<h3>sample.php::9 - Sample A Constructor</h3>

There is a chance there are more places within phpHtmlLib that could have this problem with some versions of PHP5.3.x. Now that I know how to solve them, fixing them is pretty simple and very quick. If you run into any blank pages within wp-SwimTeam, let me know ASAP and more than likely a solution like the above within phpHtmlLib will address the issue.

The phpHtmlLib plugin has been updated to v2.6.4.3566 and committed to the WordPress plugin repository.

wp-SwimTeam v1.34-beta with Hy-tek HY3 meet entries!

Tonight I posted an early build of wp-SwimTeam v1.34.  You can download it and manually install it if you would like to try it.  This build introduces the ability to export Meet Entries in Hy-tek HY3 format which can be imported directly into Team Manager and Meet Manager.

This build also addresses a number of bugs I’ve encountered, the most notable being the inability to generate a single swimmer roster export in SDIF and HY3 formats.  Instead of just one swimmer, the entire roster was exported.  This has been fixed.  The CSV export was not affected by the bug.

Please let me know if you run into any issues.  I plan to release this later today after some more testing.

Download:  [download#14]

If you run into any problems, please let me know.  I’d like to release this update in the next day or so.

wp-SwimTeam v1.33.949 now available

After a day of testing on the MacDolphins site without any issues, I have released v1.33.949.  There are no changes between this build and the v1.33 beta build except the version number and the removal of the beta tag.

This build fixes a number of problems related to swimmer and user data which surfaced after I changed the database queries I was using in v.1.32.

  • Fixed bug which prevented generating roster report.
  • Fixed bug which prevented scratching swimmers from Meet tab.
  • Added additonal table to Meet Report when operating in Stroke mode which reports number of swimmers Opting In or Opting Out per age group.
  • Completed first phase Meet Entries export in Hy-tek HY3 format. Not exposed on the GUI yet.
  • Fixed bug which prevented Job Reminder emails from being sent.

You can find the update on the Download & Installation page or in the WordPress Plugin Repository.

Working on Hy-tek Entries

Over the last few days I have been working the Hy-tek HY3 equivalent of exporting SDIF meet entries.  For the most part the logic is largely the same but the Hy-tek Meet Entries format is different enough that it isn’t a simple port.  In particular, relay entries have me a bit stumped.

In SDIF it is possible to assign any number of swimmers to a relay event as an “Alternate” using the “A” designation in the leg field of the F0 record.  As near as I can tell, the Hy-tek equivalent doesn’t exist.  A relay team can be defined in the HY3 F1 record and the heat and lane assignment can be set in the F2 record.  Swimmers are designated in the F3 record.  So I am somewhat stumped – do I just define the relay teams and then let the assignment of swimmers to the relay teams happen within either Team Manager or Meet Manager or do I keep track of the number of potential swimmers and create the maximum number of relay teams and simply assign swimmers to each team so they can be sorted out later?

The other dilemma I face has to do with the swimmer id field which is not the same as the registration number field.  The swimmer id field is an internal database field which connects D1, E1, and F3 records to the same swimmer.  Within my plugin I have unique swimmer ids in the form of database record identifiers that I know will be unique.  Should I use them or is simply starting at 1 and sequencing the number of swimmers as using that as an id sufficient?

My guess is the answer to both of these questions will be “it depends” and I’ll need to experiment.  Life would be so much easier if Hy-tek would simply support the SDIF format correctly instead of the half assed way they do it now.

wp-SwimTeam v1.31.918 now available

This morning I released an update for wp-SwimTeam.  This version addresses a few issues and completes the Hy-tek Team Manager Roster Import functionality.  You can find it on the Download and Installation page or through the WordPress Dashboard and the Plugin Repository.

  • Completed Hy-tek Roster export. All fields that can be mapped into some sort of logical Hy-tek Team Manager field are now supported. TM supports up to three custom fields in the roster import file, if optional swimmer fields are enabled, the first three (or fewer) will be mapped into the corresponding TM custom field.
  • Fixed bug where in some instances, the first name would be blank.
  • Fixed alignment (right instead of left) of Swimmer Id field on SDIF F0 records in entries export.
  • Fixed minor white space issue in PHP source code which in some cases seems to cause the Job Commitment Report to hang.

Early build of wp-SwimTeam v1.31 now available

This afternoon I posted an early build of wp-SwimTeam v1.31.  You can download and manually install it if you want to try it.  This build completes the work for exporting the roster to Hy-tek Team Manager.  All of the swimmer and parent fields that can be logically mapped into the Team Manager Athlete profile have been mapped.  I was even able to map some of the Swimmer Optional fields (if they’re used) as Hy-tek Team Manager supports importing up to three custom fields.

Download:  [download#14]

If you run into any problems, please let me know.  I’d like to release this update in the next day or so.

And there was much rejoicing – Hy-tek HY3 export now in beta!

I have made an early release of wp-SwimTeam v1.28 available for download.  This new version introduces a long requested a feature:  Hy-tek HY3 format export of the roster!  The exported HY3 can be read into Hy-tek Team Manager eliminating the need to hand enter your roster.

The Hy-tec HY3 support is not complete but I wanted to get it out there.  Currently only D1 records are exported, the other record types which contain the contact information and address for the swimmer will be added soon.  Once the roster is complete I plan to move on to meet entries in HY3 format.

Special thanks to Joe Hance and Troy Delano both who have helped me with the Hy-tek checksum and file format.

Download:  [download#14]

Please give it a shot and let me know if you run into any issues.

wp-SwimTeam v1.26.871 released tonight

I released a second build today, v1.26.871 was pushed out late tonight.  I don’t like to do this as constantly having the Update notice on your Dashboard can be a bit of a nuisance.  We’re gearing up for Swim Team, he have our season opening party in one week so I’ve am trying to get ready and have been working on the plugin a lot over the past few days.

This build addresses a few minor nits but the primary new feature is the ability to display the meet time as part of the wpst_meet_schedule short code.

  1. I’ve added a new option to Miscellaneous tab to control how time is formatted. Usage of the format is not yet pervasive through the plugin.
  2. Enhanced wpst_meet_schedule shortcode with two new attributes: fmt=’time format’ and ‘showtime=yes|no’. Default is not to show the time and use the time setting from the Miscellaneous tab. The fmt attribute expects a string formatted following the conventions outlined in the PHP date function.
  3. Removed redundant code from Swim Meet module.

The build has been pushed to the WordPress plugin repository and also appears on my Download & Installation page.

wp-SwimTeam v1.25 beta release

I have made an early release of wp-SwimTeam v1.25 available for download.  This new version addresses a number of issues when running wp-SwimTeam under WordPress Multi-Site.

Update 5/10/2012 @ 23:16:  I have updated the 1.25 beta release, fixing a number of issues where PHP warning were issues due to passing the wrong format of the date to strtotime().  I have also fixed a few other minor issues with the various Options forms so they work consistently across all forms.

Download:  [download#14]

Please give it a shot and let me know if you run into any issues.

wp-SwimTeam v1.24.846 now available

This afternoon I posted an update to wp-SwimTeam.  This release, v1.24.846, addresses a couple of issues.

  1. In ability to add a new season to a new installation.  Made it kind of hard to get started!  This bug was introduced when I added action checking and the action checking on the Seasons had a flaw in it.
  2. Added B1 and B2 records to the SDIF export of Meet Entries.  These records are required and I had simply overlooked them.  The Meet Entries successfully import into WinSwim, I hope to validate with Team Manager in the next day or two.

WordPress multi-site is not functional at this time.  I’ve been alerted to a bug which I am chasing which prevents the Users from being displayed.  Access to the user tables is critical and multi-site handles it differently than regular WordPress does so I need to account for it.