XF 2.2 Significant backwards compatibility break in XF 2.2: From Zend to Laminas

Chris D

XenForo developer
Staff member
XenForo has a long history with Zend Framework starting with our usage of some parts of the Zend Framework dating all the way back to XenForo 1.0 and, even now, in XenForo 2.x we still use some specific components including some related to processing incoming mail and reading/writing RSS feeds.

However, the leadership structure of Zend Framework has undergone some changes in recent years and it has now gone through its most significant change, yet:


Put simply, Zend Framework has now become Laminas Project - an open source and community-supported project which aims to continue the work started in Zend Framework.

Because we still intend to use the aforementioned components going forward, as they are generally robust and well supported, we have decided that in XenForo 2.2 we will migrate the Zend Framework components we use to use the Laminas Project equivalents.

While this is actually a relatively straight forward change, this does potentially impact add-ons. There are two distinct ways this may affect your add-on code:

  1. You have included additional Zend Framework components (that we do not include in XF) which you call from within your code.
  2. You have used Zend Framework components that we do include in XF which you call from within your code.

If you have code which falls into the situation mentioned in 1. we encourage you to migrate that yourselves - sooner rather than later - to the equivalent Laminas Project component.

If you have a significant reliance on Zend/Laminas code in your add-on, you may wish to follow their migration guide which does some of the heavy lifting for you automatically:


If you have code which falls into the situation mentioned in 2. then we are urging you to prepare a 2.2 specific version of your add-on ready for release as quickly as possible after the release of XenForo 2.2 - ideally while XenForo 2.2 is still in beta.

As a specific example of the type of change required in XenForo 2.2, please look at this example from XenForo Media Gallery related to rendering RSS feeds.

The XenForo Media Gallery 2.1 code is (XFMG\Pub\View\Rss\Index::renderRss()):

PHP:
$feed = new \Zend\Feed\Writer\Feed();

This has been changed to the following to ensure compatibility with XenForo 2.2 in XenForo Media Gallery 2.2:

PHP:
$feed = new \Laminas\Feed\Writer\Feed();

The changes required are very small, but given that the Zend classes may no longer exist (or no longer called by the autoloader) then without changes functionality within your add-on may break when a user upgrades to XenForo 2.2.

If you have any questions please post them below.
 

briansol

Well-known member
Suggestion to get a jump -- release the next 2.1.x with both framework libs. Dev's can get a head start and update their mods to the new library and maintain compatibility across multiple versions and in 2.2 remove zend as planned.
 

Vanjoe

Member
Is there a simple way to check if an addon is using the Zend Framework? For users that want a smooth transition to 2.2 without having to wait for addon developers. I sure would hate to upgrade only to find out an addon I require doesn't work while the addon developer is MIA.
 

TickTackk

Well-known member
Suggestion to get a jump -- release the next 2.1.x with both framework libs. Dev's can get a head start and update their mods to the new library and maintain compatibility across multiple versions and in 2.2 remove zend as planned.
If moving Zend component usage to Laminas is going to be as easy as this:
The XenForo Media Gallery 2.1 code is (XFMG\Pub\View\Rss\Index::renderRss()):

PHP:
$feed = new \Zend\Feed\Writer\Feed();

This has been changed to the following to ensure compatibility with XenForo 2.2 in XenForo Media Gallery 2.2:

PHP:
$feed = new \Laminas\Feed\Writer\Feed();
Then it is just a matter of using using if-else condition, eg:
PHP:
        if (\XF::$versionId >= 2020010) // xf 2.2 confirmed?
        {
            $feed = new \Laminas\Feed\Writer\Feed();
        }
        else
        {
            $feed = new \Zend\Feed\Writer\Feed();
        }
 

Ozzy47

Well-known member
Is there a simple way to check if an addon is using the Zend Framework? For users that want a smooth transition to 2.2 without having to wait for addon developers. I sure would hate to upgrade only to find out an addon I require doesn't work while the addon developer is MIA.

Simply wait to upgrade till addon developers indicated that their addons are compatible with 2.2
 

Dadparvar

Well-known member
Just did a search-all for the word "Zend" in my addons... thankfully found nothing!

(I'm an awful programmer)
Jax: Ctrl+Shift+F "Zend"
IntelliJ IDEA: GTFOOH!
Notepad++: STFU!
Notepad: WTFWT?!
localhost: lmfao!
Chris: working on the new announcements to help developers be prepared.
 

Karelke

Well-known member
If moving Zend component usage to Laminas is going to be as easy as this:

Then it is just a matter of using using if-else condition, eg:
PHP:
        if (\XF::$versionId >= 2020010) // xf 2.2 confirmed?
        {
            $feed = new \Laminas\Feed\Writer\Feed();
        }
        else
        {
            $feed = new \Zend\Feed\Writer\Feed();
        }

Or do it the Symfony way and just check if the class in the given namespace exists.

PHP:
use Laminas\Feed\Writer\Feed;
use Zend\Feed\Writer\Feed as LegacyFeed;

if (class_exists(Feed::class)) {
    $feed = new Feed();
} else {
    $feed = new LegacyFeed();
}
 
Top