Upgrading MODX Evolution to 1.4.7 and Modern PHP

MODX Evolution · PHP · Update and Compatibility

Update to MODX Evolution 1.4.7 with custom code adaptation for PHP 7.2. The main task is to keep the site, administrative dashboard, forms and integrations working after changing the version of CMS and PHP.

The challenge of updating

The update affected the CMS core, custom snippets, plugins and site settings. The code needed to replace outdated features and fix errors that occurred when switching to another version of PHP.

Maintain functionality

Verify that forms, mailing, administration panel, and user improvements continue to work after the update.

Adapt the code

Update database access, type processing, and code sections with outdated PHP features.

The article describes the transition to the versions specified in the original task. Compatibility with later versions of PHP requires separate validation of CMS, extensions and custom code.

How the work went

1. Preparation

Create a backup of files and database. Verification of the PHP version, site configuration, plugins used and user components.

2. CMS Update

Installation of MODX Evolution 1.4.7 and check settings. Transfer user configuration and update site components.

3. Refining extensions

Adaptation of snippets and plugins. Incompatible components required correction of the code or replacement with a suitable version.

4. Interface verification

Verify JavaScript, jQuery libraries and related plugins. If necessary, adjust CSS and the behavior of page elements.

What changes are required in the PHP code

Connection to the database

User code calls mysql_* substitute mysqli_* or PDO. Below is an example of changing the connection from the original job description.

Before changing

$this->conn = mysql_connect($host, $user, $password);
mysql_select_db($database, $this->conn);

After the change

$this->conn = mysqli_connect(
    $host,
    $user,
    $password,
    $database
);

This snippet shows a replacement connection. The rest of the calls to the database are checked with him.

Verification of data before count()

There were challenges in the source code. count() for values of the wrong type. In places where logically expected array, added verification:

if (is_array($variable) && count($variable) > 0) {
    // Обработка непустого массива
}

Also corrected appeals that caused the message Use of undefined constant. Type checks were selected for the purpose of a specific section of the code.

Replacement of obsolete functions

In snippets and plugins checked calls create_function, split and ereg. They were replaced by corresponding constructions: anonymous functions and suitable means of processing strings and regular expressions.

Settings and caching

User settings were transferred to configuration files. Separately checked the cache structure and caching after the update.

The final stage included setting up the cache and checking the speed of the site. Quantitative acceleration values in the starting materials are not given.

What was checked after the update

User-generated scripts

  • Sending forms.
  • Postal notifications work.
  • Custom snippets and improvements.
  • Interface behavior and JavaScript.

Work by CMS

  • Administrative panel.
  • Plugin compatibility.
  • Settings and caching.
  • Mistakes discovered after a change in environment.

Timing and outcome

In the initial assessment, the work was assigned 5-7 working days. The term depended on the amount of user code and the compatibility of the plugins.

The result described in the project is a site on MODX Evolution 1.4.7 with adapted snippets and plugins, patched sections of the outdated PHP code and proven basic functions.

With such an update, it is important to evaluate the entire composition of the site: the CMS core, extensions, own code and server environment.

Frequent questions about MODX Evolution update

Is it enough to update only the core MODX Evolution?

In the described work, the update also affected snippets, plugins, configuration and user code. After installing the kernel, forms, mail, administration panel and other functions of the site were separately checked.

Does the PHP 7.2 adaptation mean compatibility with all subsequent versions?

Nope. The article describes the specific task of upgrading to MODX Evolution 1.4.7 and adapting to PHP 7.2. For another version of the PHP, you need to separately check the kernel, extensions and own improvements.

Can custom snippets and plugins be saved?

Maintaining the existing functionality was one of the objectives of the project. Compatible components were left behind, and problem areas of code were fixed. For an incompatible plugin, an adaptation or replacement with a suitable version was considered.

What errors did PHP correct in this project?

The original description indicates the replacement of calls mysql_*, the data validation before count(), the correction of requests with the message Use of undefined constant and the replacement of outdated create_function, split and ereg. The specific changes depended on the component code.

Why make a backup copy before updating?

A copy of the files and database saves the original state of the site until changes are made. In the described project, backup was included in the preparatory stage along with checking the environment and the list of extensions.

How long does this update take?

The initial assessment of the project indicates 5-7 working days. This is a guide for the volume of work described. For another site, the period depends on the number of user improvements, compatibility of extensions and the amount of verification after the update.


Let’s discuss your project

Tell me what you would like to build. I will reply by email.

Or message me on Telegram @ifwcom