The information in this post has been documented in our Official phpBB Extension Documentation.
Please read What’s New for phpBB 3.2
*******************************************
Extensions should, for the most part, be compatible with phpBB 3.2 with no need for specific changes, and they should be able to maintain backwards compatibility with 3.1. However, there are many changes in phpBB 3.2 that can be made to extensions to keep them current, or may be needed in a few rare cases where compatibility between 3.1 and 3.2 has been broken. This topic should cover what you need to know to keep your extensions working in phpBB 3.2.
There following tags are used to distinguish what types of changes are being described:
- (3.1/3.2) For changes that should be made for 3.2, but are also compatible with 3.1 and are probably good to do no matter what.
- (3.2 optional) For changes that can be made for 3.2, but are not required yet. These are changes that will break backwards compatibility with 3.1, so they should only be made if your extension is no longer supporting 3.1. If you can support 3.1 and 3.2, then these changes can be skipped.
- (3.2 only) For changes required for 3.2 compatibility. If your extension makes these changes, it will no longer support 3.1, and should in effect represent a new major version development cycle for your extension.
Replace
$user->lang
with $language->lang
(3.2 optional)The language class has been de-coupled from the user class. This means the language class in 3.2 can now be accessed from
\phpbb\language\language
. The old \phpbb\user
class is still available for backwards compatibility with 3.1, but the user's lang methods have been deprecated and will be removed in a future phpBB version. Also, the old user class' add_lang_ext()
method is deprecated and handled by the smarter language class' add_lang
method.
Code: Select all
// phpBB 3.1 and 3.2 compatible
$user->add_lang('posting');
$user->add_lang_ext('phpbb/boardrules', 'common');
$user->lang('HELLO_WORLD');
// phpBB 3.2 only
$language->add_lang('posting');
$language->add_lang('common', 'phpbb/boardrules');
$language->lang('HELLO_WORLD');
If your extension uses the notifications system by extending the notifications class, then you should take a look at how the notifications classes have changed for 3.2. The notable changes are made to the
find_users_for_notification
and create_insert_array
methods.
Code: Select all
public function find_users_for_notification($data, $options = array())
{
...
// phpBB 3.1 usage:
$users[$row['user_id']] = array('');
// phpBB 3.2 usage:
$users[$row['user_id']] = $this->notification_manager->get_default_methods();
...
}
Code: Select all
public function create_insert_array($data, $pre_create_data = array())
{
...
// phpBB 3.1 usage:
return parent::create_insert_array($data, $pre_create_data);
// phpBB 3.2 usage:
parent::create_insert_array($data, $pre_create_data);
}
The link to the BBCode FAQ can now be handled using the route system:
Code: Select all
//phpBB 3.1 and 3.2 compatible:
<a href="' . append_sid("{$this->root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">
//phpBB 3.2 only:
<a href="' . $this->controller_helper->route('phpbb_help_bbcode_controller') . '">
get_name()
Method (3.2 optional)There's a new method for displaying the name of a user group in 3.2:
Code: Select all
//phpbb 3.1 and 3.2 compatible:
($row['group_type'] == GROUP_SPECIAL) ? $this->user->lang('G_' . $row['group_name']) : $row['group_name'];
//phpBB 3.2 only:
$this->group_helper->get_name($group_row['group_name'])
BBCode engine (3.1/3.2)
The BBCode engine has been replaced by the s9e/textformatter. Most extensions should not be affected by this. Unless your extension directly modifies how BBCodes are configured, processed or rendered, via the
bbcodes.php
class. In most cases even if you do need to make changes to work with the new textformatter, you can do so via many of its strategically positioned events which should allow you to have events and code compatible with the 3.2 engine and simultaneously keep code for the old engine in place, thus able to maintain backwards compatibility with 3.1. The BBCode changes are too extensive to detail here, so if you need to explore the new engine further, you can start with this thread by the new engine's author.Text Reparser (3.2 optional)
If your extension is storing text with BBCodes in its own tables in the database, you may want to consider adding a text reparser class. When phpBB updates a board to 3.2, it reparses all posts and a few other spots where phpBB uses BBCodes, updating them to the new BBCode format. Unparsed old bbcodes should still work as expected, but it can be piece of mind, especially if your extension stores a lot of messages with BBCodes, to have them updated to the new format. Doing so requires two things:
- Extend a reparser plugin class to scan your extension's tables containing messages for reparsing (the table is defined in the service).
- Write a migration to put your reparser into action.
TEMPLATE CHANGES:
Twig
loops
prefix (3.2 optional)If you are already using Twig template syntax, and you have been using template loops, the
loops
prefix is no longer needed for 3.2. However, it is still needed if backwards compatibility with 3.1 is desired.
Code: Select all
// phpBB 3.1 and 3.2 compatible
{% for item in loops.items %}
item.MY_VAR
{% endfor %}
// phpBB 3.2 only
{% for item in items %}
item.MY_VAR
{% endfor %}
phpBB 3.2 has replaced almost every icon with a font icon using the Font Awesome toolkit. This has resulted in significant template changes to Prosilver, including many new classes. If your extension makes use of any of Prosilver's icons, or in any way recreates any of Prosilver's template layouts that include any iconography, you should examine if and how your template files may be impacted and need to be adjusted to be compliant with phpBB 3.2. Some backwards compatibility has been retained so, for example, extensions adding links to the nav bars should still work as expected. You may also consider leveraging the new font icons to your advantage as they make it quite easy now to add any of the available Font Awesome icons to improve GUI elements of your extension. For example, if you extension has a "delete" link or button, you could add a nice little Trash Can icon to that link or button.
INCLUDECSS
changes (3.2 only)Now, in phpBB 3.2, the INCLUDECSS syntax can be used anywhere in a template. In phpBB 3.1, this tag only worked in an event like
overall_header_head_append
, or before including overall_header.html
. As of 3.2 it will be easier to implement this tag anywhere, just like the INCLUDEJS tag.MISC CHANGES:
Quote service variables (3.1/3.2)
Symfony will require wrapping services definitions prefixed with @ and % in single-quotes (non-quoted strings is deprecated in Symfony 2.8 and will throw parser errors in 3.0). This has always been allowed but not practiced in phpBB 3.1. So this should be done for 3.2 at least (which is using Symfony 2.8), but is highly recommended for any extension since it is phpBB 3.1 and 3.2 compatible. For example:
Code: Select all
vendor.package.class:
class: vendor\package\classname
arguments:
- '@dbal.conn'
- '%custom.tables%'
calls:
- [set_controller_helper, ['@controller.helper']]
Symfony has deprecated the prototype scope in 2.8, and it will be removed in 3.0. As a result you should make this simple change if any of your services are defined to use the protoype scope. That means replace any occurrences of:
Code: Select all
scope: prototype
Code: Select all
shared: false
Code: Select all
vendor.package.class:
class: vendor\package\classname
shared: false