Important changes to 5.5.3 and Pro 2.3.8
Posted on April 15, 2014
We’re intending on releasing versions 5.5.3 and Pro 2.3.8 very soon, and included in this update are some inevitable changes that may impact some customizations made by users as well as creating incompatibilities with earlier versions of Events Manager Pro.
This does not affect users that are able to update both EM and Pro, only users that want to upgrade the Free plugin but cannot upgrade Pro for whatever reason.
Every effort is made to make the updates to Events Manager compatible with earlier versions of Pro, but sometimes for the good of the plugin or for inevitable reasons (like in this case), things have to change.
This post should help developers understand why this has happened and what’s needed to bring custom code up to date. For less tech-savvy Pro users, skip down to the “How to ‘fix’ earlier versions of Pro” section.
If you are experiencing errors due to this upgrade, feel free to ask on our support forums, stating any error messages you’re getting, and we’ll do our best to advise you on how to get things back on track again.
We’re sorry for the inconvenience caused. Hopefully these sorts of changes should be few and far (although preferably never!) between.
Why these changes are necessary.
We had to make changes to the code in order to prevent various PHP Strict error warnings when running later versions of PHP. These strict errors were mainly due to the fact that we’re calling static methods that aren’t declared as static.
At the time of writing the offending code, PHP versions commonly used with WordPress and web servers did not throw strict errors when you did this, but as hosts update their PHP versions these strict error warnings became prevalent.
The use of the word ‘error’ may be misleading here, because it’s not really an error but a warning that gets output to error log files as well as the browser if the server environment is set to display errors on-screen (or if using WP_DEBUG).
What has been changed
The bulk of the changes are in the main/free plugin, and they mainly involve these three situations:
- Changing functions so they are declared as public static functions
- Changing any instances where these modified functions were not being called staticly (very few of these)
- Changing method signatures (i.e. parameters) of extended classes so they match the function of parent classes
To make this as painless as possible, we’ve made a single commit in the WordPress SVN repo so that you can easily see the changes in one diff comparison, which you can find here.
The Pro version needed changing of two functions in the EM_Coupons class so they are static, given the parent EM_Object class are now also static.
Who they’ll affect
These changes will affect anyone running Events Manager Pro 22.214.171.124 or earlier. Additionally, this may affect users who have made customizations.
If you have followed the same convention we do in our plugin and tutorials when using functions such as EM_Events::get_search_defaults() or similar, then there likely shouldn’t be any problems, in fact you should see less warnings in your error log. However, if you are using any of these changes non-statically, then you will likely have fatal errors and the offending lines in your code should be changed.
Since it’s impossible to predict every situation when it comes to custom code, the general advise we can give to developers is to check the diff and see if there’s any functions they’re using that have changed, and if so, start calling that function statically instead. If you can test this out on a staging server, it may even be easier to update and fix errors as they’re reported, since there’s likely to be only a few lines requiring a change.
When will this affect me?
We will allow until at least Monday 21st April 2014 before pushing out a stable update. You can already download these changes in the latest dev versions.
How to ‘fix’ the Pro add-on
Fortunately, the changes in Pro are minimal, in fact, it just requires two line changes in one file to prevent fatal errors. For those that don’t have an active license, an renewal shouldn’t be required just for this, and we describe below how to fix this yourself.
Depending on your Pro version, the file will be located in one of these two locations:
Since this file may vary from version to version, we’ve created a search/replace instructions which will apply to all versions of the file. In a regular text editor, do a search and replace of these two phrases, which should be located near the bottom of the file. Do not replace the whole line, just the bits of text indicated below.
public static function build_sql_conditions
And search/replace this:
public static function get_default_search
Once you’re done with these changes, you’ll also need to correct one line in /events-manager-pro/events-manager-pro.php so that the plugin isn’t deactivated automatically to prevent this fatal error.
Replace this line (the number 123 will vary depending on your Pro version):