php5.6/php7 compatibility + memleak fix

Discover FAST, a records keeping server control script with a public records system called Dedimania, which will show records from the server on

Moderators: Slig, TM-Patrol

Post Reply
speedy pilot
speedy pilot
Posts: 458
Joined: 05 Apr 2008 12:37
Owned TM-games: TMO, TMS, TMU/N(F)
Location: Germany

php5.6/php7 compatibility + memleak fix

Post by Bueddl » 30 Jan 2017 22:55

Hey everyone,

as some of you already noticed, there are some bigger issues for running some of the latest controllers on php 5.6/7.x. Mainly there are three tasks to perform in order to prepare the controllers to run on php 7.

1. Mysql deprecation

There is already a post [1] outside covering this for xaseco. It advertises a small plugin coded by reaby that basically does a wrap-up of the obsoleted mysql API and internally uses the mysqli api. I am not aware of the state of other controllers than xaseco and manialive here. Although this solution might work for you, there is a better way, which includes a little more effort. However, if you are just for an "it just works"-solution, you might be happy with it.

Anyway. it is only about replacing the old api. I always prefer using the object-orientated style. I did simply use some regex-enabled code editor and did a quick search and replace on those api parts. This worked for me very well, but keep in mind, that unless the plugin author will use the mysqli api in further releases, you would have to adapt this every time. So maybe, this is not the best solution for you. If you wanna go this way to hell, you can use these regexes for search-n-replace (each first line is search query, next is replacement):

Code: Select all





Manialive and dependent projects are by the way not affected by this, as the developers of NADEO did carefully write good and fresh code here (good job this time guys :thumbsup:).

2. Memory leaks

Even if you got your controller running with the patch of reaby listed above, it won't run for long as there are several memory leaks present in the current versions of xaseco (1.16), fast (3.2.3t/4.0.0t) and probably other server controllers as well. All of them reside in the fact, that the resource handling was changed to a more strict one beginning with PHP7.0.
For those controllers, this means the usage of the xml_parser component inside three major components:
  • Parsing incoming XMLRPC/GbxRemote messages from the gameserver
  • Parsing the mapfile metadata
  • Parsing various configuration files (not the variant that uses simplexml_load_xy)
The last one is not that big deal as it isn't a recurring task, the other two are more of interest. Anyway, fixing those issues is not a big deal, as it only requires explicitly unsetting the resources after invoking xml_parser_free. You can find a set of replacement files on the site linked below:

Manialive isn't affected again, as they did use the simplexml_load_string function, which does not use a resource and therefore is not affected.

3. Even more deprecation

There are a few more deprecated functions, here is a list of obsoleted functions and their possible replacement:
  • split() -> explode()
  • If I remember more, I will update this post ;-)
So, there is a little work to do for gaining full compatibility, but if you stick to reabys plugin and my patched core files, you should get a more-less working controller running on PHP5.6/7.x :-)



[1]: "modernizer" plugin by reaby for mysql/mysqli API convergence - viewtopic.php?f=127&t=35817
[2]: patched files including the memory leak fix -

smooth traffic navigator
smooth traffic navigator
Posts: 226
Joined: 16 Oct 2010 19:45
Owned TM-games: TMN! TMF
Location: Germany

Re: php5.6/php7 compatibility + memleak fix

Post by TheBigG » 01 Feb 2017 19:56

Great Work :1

Post Reply