Migrating from PHP 5.6 to 7.3

Migrating from php 5.6 to 7.3

So finally I decided to upgrade digi77.com from PHP version 5.6 to 7.3 in order to catch up with the security enhancements and speed improvements. Honestly i do not regret doing so however I faced few issues that i would like to share with you in case you face the same it would be easier for you to solve it.

wp-code-highlight plugin:

Once I updated to PHP 7.3 WordPress crashed and its due to one of the plugins which is wp-code-highlight. This plugin uses preg_replace with \e to convert a double quote ” into \” but the bad news is \e is deprecated in php 7. In order to solve this you would have to use an anonymous function to pass the matches to your function and here is how I did it.

File which had to be changed is wp-code-highlight.php

Old function code was:
Please replace the word xre to pre I had to change it because I am using the same plugin on this post!

function wp_code_highlight_filter($content) {


		$line_numbers=' linenums:1';





	return preg_replace("/<xre(.*?)>(.*?)<\/xre>/ise",

		"'<xre class="wp-code-highlight prettyprint$line_numbers">'.wch_stripslashes('$2').'</xre>'", $content);


New code function in order to make it work is to use preg_replace_callback and here how I implemented it:
Please replace the word xre to pre I had to change it because I am using the same plugin on this post!

function wp_code_highlight_filter($content) {
/*  Warith new code */
	return preg_replace_callback("/<xre(.*?)>(.*?)<\/xre>/is",function($m) { if(get_option('wp_code_highlight_line_numbers')=='enable'){ $line_numbers=' linenums:1'; } else{ 	$line_numbers=''; }; return '<xre class="wp-code-highlight prettyprint'.$line_numbers.'">'.wch_stripslashes($m[2]).'</xre>'; },$content);


That made WordPress work smoothly again with PHP 7.3.


Mcrypt function:

The other issue that I faced is that Stealthwalker VPN software uses mcrypt on the server side to decrypt login details and this encryption function was removed from PHP 7! So in order to have it back I used the following commands on centOS:

# Install epel-release repo if you do not already have it installed
yum install epel-release
# Install libmycrpt and libmcrypt-devel rpms needed for the PHP extensions.
# Update all Pecl php versions.
yum install libmcrypt libmcrypt-devel
Update all Pecl php versions.
for version in $(ls /opt/cpanel|grep ea-php); do /opt/cpanel/${version}/root/usr/bin/pecl channel-update pecl.php.net; done
# Install Mcrypt PHP extensions via Pecl for PHP72 and PHP73
/opt/cpanel/ea-php72/root/usr/bin/pecl install channel://pecl.php.net/mcrypt-1.0.1
/opt/cpanel/ea-php73/root/usr/bin/pecl install channel://pecl.php.net/mcrypt-1.0.2
# Restart Apache/Litespeed to make the new PHP extensions active.
service httpd restart
# Basically you are done by now but to check for the mcrypt extensions showing. credits goes to whattheserver.com
for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do echo "PHP $phpver" ; /opt/cpanel/ea-php$phpver/root/usr/bin/php -m |grep -E 'mcrypt'; done



Digiprove sealCopyright protected by Digiprove © 2019 Eagle Eye Digital Solutions
The following two tabs change content below.
Crypto currency , security , coding addicted I am not an expert or a professional I just love & enjoy what I am addicted on🤠

Latest posts by Warith Al Maawali (see all)

commentJoin the Discussion

Pin It on Pinterest