Cannot Redeclare Class 'MT' in mt.php

While the dynamic publishing model of Movable Type is not heavily used, it is actually a very useful feature. Probably not as a complete CMS – mostly because it is not full-featured – but certainly to provide some nice functionality on the side as it were.

Unfortunately the dynamic publishing functions are not documented much, if at all, so when you run into some issues, it can be difficult to troubleshoot. One of the more common problems you may find is an error message such as this one – when you cannot redeclare the ‘MT’ class, it will prevent the entire dynamic publishing subsystem from starting up, and you will be dead in the water!

Luckily, the problem is one that is easily solved.

There are two things to notice in this error message that are important and that will help us to resolve the problem.

The first is the class that is causing the problem. In this case, it is the class ‘MT’. This is the base Movable Type class – that is to say, Movable Type itself. If you happen to find another class or function of some kind, you may have other issues, perhaps with a database call or maybe a plugin. But here, it is actually Movable Type that cannot load.

The second is the file that cannot load – that file name is mt.php. The problem is that the file it is referencing (mt.php) is almost definitely not where the problem lies. More than likely you will find that the problem is instead in the dynamic viewer, which is mtview.php.

Open this file – found in the root of your web site – and take a look at it.

Generally there are two reasons for this error.

The most common is that there are two include statements in the file. Comment out one of them if this is the case.

The other problem can be that the path to the mt.php file is incorrect. This is usually the issue if you have moved your installation directory and the file is not rebuilt (it should be rebuilt automatically by MT, but sometimes this is not done automatically). If you update the path manually, it will take care of the problem.

If you fix both of these problems and still have the error, there could be something else amiss – perhaps an extra line or call to a non-existent variable or something. But these are definitely the most common problems that you will find.


Posted

in