Frankly, the template system in MyBB 1.8 is not very bad. It works pretty fast, but has few serious drawbacks:
1. Unlike
the include() the
eval() function can't be cached by built-in PHP OPcache. Also there are some difficulties with the debugging
2. The user can't use his custom PHP code in templates. I'm talking about conditions, cycles and formatting functions. It's OK when you just changing the color or add a class, but it is the big pain, when you want to implemetnt some serious changes. Yes, this allows the user to run the PHP code in templates, but is it bad? The PHP is the best templating engine. The most popular CMS are using it. I'm talking about WordPress with WooCommerce, Joomla, Drupal, OpenCart and a lot others.
3. There number of templates is very big. There are nearly 935 (!!!) different templates. Partially it caused by a previous drawback. It makes the theme support and developing really hard. I've even wrote some script that saves all the templates in the files to make it easier. The system is using them during the theme development.
The creation of MyBB 1.9 should start with a huge refactoring to migrate to MVC.
First of all, we need to refactor the whole template system, move the templates in a PHP files and reduce their number. The whole process of the migration can be splitted in few stages.
On the first stage the template calls like:
eval("\$searchforum = \"".$templates->get("forumdisplay_searchforum")."\";");
can be replaced with:
$searchforum = $templates->get("forumdisplay_searchforum", array('lang' => $lang, 'fid' => $fid));
The
get method should be changed in this case. It should extract the passed variables, turn on the output buffering, include the template and return the outbut buffer contents. There are only 49 files with template calls. This changes will not affect the most part of extensions and plugins.
The second stage is more complicated. The templates should be reorganized. A lot of them should be merged to make it easier to understand and support.
To clearify whan I mean lets take a
forumdisplay.php file. This script is parsing the request, retreives the data from the database and builds the page using the plain templates. The template building logic is hardcoded in this script. It is very bad.
I suggest that the whole templating code should be moved to the separate template. The
forumdisplay.php script should prepare a data, compose an array with threads, pass it through filter and send the whole data a single template. This template should include the foreach cycle for threads and a call the other template to build a single thread, for example.
This changes will dramatically simplify the
forumdisplay.php code and make it support much easier. The steps in the second stage can be implemented sequentially and they doesn't break the existing code.
On the third stage the existing database queries shold be moved to functions/methods in appropriate files.
Yes, the second and third stage will break the compitability with a lot of extensions, but I think, that this is the only easy way of MyBB evolution.
I have a serious doubts that the MyBB 2.0 will be finished in near future, because it will require a huge amount of time and work. The current MyBB software is very complicated. You can't just throw it away and write the new one even using the modern tools and frameworks.
I can't say that I like the MyBB 2.0. It uses a lot of libraries like FontAwesome and some controversial methodologies like BEM. As the result the size of the front page is nearly 734 Kb comparing to 74 Kb on MyBB 1.8. The MyBB 2.0 page generation time is nearly 100 ms on empty board comparing to 10 ms on MyBB 1.8 with a lot of posts.