Potential backward compatibility issues in Joomla 4

Other languages:
Deutsch • ‎English • ‎Nederlands • ‎Türkçe • ‎español • ‎français • ‎português • ‎日本語
Quill icon.png
Content is Incomplete

This article or section is incomplete, which means it may be lacking information. You are welcome to assist in its completion by editing it as well. If this article or section has not been edited in several days, please consider helping complete the content.
This article was last edited by FuzzyBot (talk| contribs) 9 months ago. (Purge)

This document tracks potential backward compatibility issues for Joomla! 4. Listed are issues which potentially break extensions.

The base of this comparison is Joomla! 3.10.

Updated System Requirements

The system requirements have been updated as follows:

PHP MySQL Extension

'STRICT_TRANS_TABLES',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_AUTO_CREATE_USER',
'NO_ENGINE_SUBSTITUTION',

As a consequence, Joomla 4 will only use NULL date defaults. The use of the invalid default date of 0000-00-00 00:00:00 in Joomla 4 has been deprecated.

PHP PostgreSQL Extension

PHP GMP Extension

This is required for using the WebAuthn Passwordless Login feature. Note the PHP GMP Extension is installed by default on the majority of hosting sites. The WebAuthn Passwordless Login System Plugin is enabled by default in Joomla 4 on HTTPS sites.

PHP mcrypt Extension

This is required for using the Joomla\CMS\Crypt\Cipher\CrytoCipher class and its alias JCryptCipherCrypto.

CMS Libraries

The following changes have been made to Joomla! CMS libraries (this is primarily code that was found in the “libraries/cms” directory in Joomla! 3.7 and earlier).

Installer

Removed Classes

The following classes have been removed in Joomla! 4.0:

JInstallerAdapter Inheritance

JInstallerAdapter no longer extends from JAdapterInstance and inherently JObject.

Custom Installer Adapters must now be autoloaded.

Menu

JMenu is Now an Abstract Class

JMenu is now an abstract class. Subclasses of JMenu must now also implement a load method.

Manual Include Behavior Removed

The logic in JMenu::getInstance() to manually include a file from the application's includes/menu.php path has been removed. The JMenu subclass should be autoloaded instead.

JMenuItem

Pagination

Pathway

Manual Include Behavior Removed

The logic in JPathway::getInstance() to manually include a file from the application's includes/pathway.php path has been removed. The JPathway subclass should be autoloaded instead.

Router

Manual Include Behavior Removed

The logic in JRouter::getInstance() to manually include a file from the application's includes/router.php path has been removed. The JRouter subclass should be autoloaded instead.

Method Signature Changes

The attachBuildRule and attachParseRule are now typehinted to require callables.

JVersion

Support for accessing the JVersion class constants as class properties is no longer supported. The constants were introduced in Joomla! 3.5 to prevent the old class properties from being edited.

The following deprecated constants have been removed:

JHtml

Updater

Platform

The following changes have been made to Joomla! Platform libraries. This is primarily code found in the libraries/joomla or libraries/legacy directories in Joomla! 3.

Access

Application

Removed Classes

The following classes have been removed in Joomla! 4.0:

All references to JSite and JAdministrator have been removed (these were just class alias' since Joomla 3.2)

Deprecated Classes

The following classes have been deprecated and scheduled for removal in Joomla! 5.0:

CLI/Web Class Changes

The JApplicationCli and JApplicationWeb classes have been recomposed to extend from the Framework's Application package instead. This breaks type checks for a JApplicationBase object. For forward compatibility, it is recommended to check if application classes are an instance of Joomla\Application\AbstractApplication (JApplicationBase has extended this class since Joomla! 3.4).

Additionally, both of these classes are now abstract. Developers implementing these classes must provide a doExecute method with their application's logic.

The registerEvent method is now typehinted to require a callable for the $handler parameter.

Applications that want to support both Web and CLI Applications should now typehint against the \Joomla\CMS\Application\ CMSApplicationInterface - this contains common methods (some of which in Joomla 3.x were only found in the JApplicationCms class) that can be used by all code. It's strongly recommended any custom applications (especially CLI applications) implement this interface to make compatibility checks easier, simultaneously any typehints should use the interface rather than a concrete class.

JApplicationCli
JApplicationWeb
CMSApplication
JApplicationSite

The $_language_filter and $_detect_browser class properties have all been renamed to remove their underscore prefix.

The deprecated method JApplicationSite::getPageParameters has been removed in favour of its alias JApplicationSite::getParams

JApplicationHelper

JApplicationHelper::parseXMLLangMetaFile has been removed without replacement.

Archive

Client

\Joomla\CMS\Client\ClientWrapper has been removed. Use the static methods in \Joomla\CMS\Client\ClientHelper

Crypt

Removed Classes

The following ciphers have been removed in Joomla! 4.0:

These have been removed without replacement. Use JCryptCipherCrypto

Removed Methods

Cache

Component

Document

Inheritance Change

The following classes have had their inheritance changed:

Note as a result of this change rendering an error page resets the document object in Joomla\CMS\Factory::$document, the rationale being we want a clean document to work from; if the error page is triggered we aren't interested in the metadata your component has set, or the media added from some bad module, or whatever plugins are adding to the display. We want a clean environment for rendering the error page only containing the error page's loaded data.

Renderers

JDocumentFeed

The property type of JDocumentFeed::$lastBuildDate has changed from a string to a JDate object. The property was previously unused by the core Joomla API but extensions may have used it.

Database

Factory

Environment

Filesystem

Filter

All of the above deprecations and removals are to allow the class to be reunified with the framework parent class.

Form

Fields

Media Field

The Media field type now encodes image metadata into the internal value. This is a sample value:
images/banners/osmbanner1.png#joomlaImage://local-images/banners/osmbanner1.png?width=468&height=60

To produce the final Image URL or the relative image file path, you can use the new helper:
echo \Joomla\CMS\HTML\HTMLHelper::cleanImageURL($oldValue);

To get the clean value (without adapter information and metadata) from the value which is stored in media form field:
echo \Joomla\CMS\Helper\MediaHelper::getCleanMediaFieldValue($oldValue);

Function cleanImageURL does not clean the image URL but returns object where one part of the object is cleaned URL. Using echo throws an error. For more information visit [2]

Wrapper

HTTP

Deprecated Classes and Interfaces

The following classes and interfaces have been deprecated and scheduled for removal in Joomla! 5.0:

Class Changes

The Framework's HTTP package is now included in Joomla! 4.0 and JHttp and the JHttpTransport subclasses have been refactored to use the upstream package.

JHttp

The JHttp class constructor has been loosened with the following changes:

JHttpTransport

The now deprecated JHttpTransport interface extends Joomla\Http\TransportInterface now and has caused backward compatibility breaking changes in the interface. The constructor is no longer part of the interface, and the interface's `request()` method has had a signature change. Specifically, the second parameter which previously typehinted the JUri class now typehints Joomla\Uri\UriInterface.

JHttpResponse

In refactoring the response object to inherit from the Framework's HTTP package, which is now using the PSR-7 ResponseInterface API, a minor compatibility break has been made in the structure of the response headers. As of 4.0, this will now always be a multi-dimensional array where the key is the header name and the value is an array of values for that header (previously, this was a string).

Image

Deprecated Classes and Interfaces

The following classes and interfaces have been deprecated and scheduled for removal in Joomla! 5.0:

Class Changes

The classes from Framework's Image package have been inlined into CMS and JImage and the JImageFilter subclasses have been refactored to use them. I.e. all classes under Joomla\Image namespace moved to Joomla\CMS\Image namespace.

Menu

New MVC Layer

Keychain

Removing the keychain with 4.0 has resulted in the removal of the following class:

Pathway

Profiler

Table

Mail

The following methods have been removed in Joomla! 4.0:

Exceptions

JMail no longer catches exceptions from PHPMailer. It is now the object calling JMail's responsibility to handle these exceptions as appropriate. In addition if mail sending is disabled in global configuration calling \ Joomla\CMS\Mail\Mail::send() will throw a \Joomla\CMS\Mail\Exception\MailDisabledException.

Language

Legacy MVC Layer

Legacy Controller

Legacy View

Library

Session

The session package has undergone a major refactoring to use the Framework's Session package. This change primarily affects the internals of the package; changes to the primary public API through the JSession class are minimal.

String

The old JString class alias has been removed. Use \Joomla\String\StringHelper instead.

Removed Classes and Interfaces

The following classes and interfaces have been removed in Joomla! 4.0:

JSession

JSession now extends from the Framework's Joomla\Session\Session class. Many of the methods have a modified signature and a compatibility layer exists to help with the transition.

Namespace Parameter Deprecated

The get, set, has and clear methods previously supported a namespace parameter. This parameter is now deprecated. The namespace should be prepended to the name before calling these methods.

JSession::clear() Repurposed

In the Joomla\Session\Session class, the clear method is used to clear all data from the session store. In JSession, this method is used to remove a single key. When this method is called with parameters, it will call the new Joomla\Session\Session::remove() method.

JSession::getInstance() Deprecated

The singleton getInstance() method has been deprecated. The session object should be retrieved from the active application or the dependency injection container instead.

Session Handlers

In Joomla! 3.x and earlier, session handlers were represented by the JSessionStorage class and its subclasses. In Joomla! 4.0, session handlers are now implementations of Joomla\Session\HandlerInterface (which is an extension of PHP's SessionHandlerInterface. All handlers which were supported in Joomla! 3.x are still available in 4.0 in addition to two additional handlers: a handler natively implementing the APCu extension and a handler supporting Redis.

Social Media Libraries

The facebook, github, google, linkedin, openstreetmap, mediawiki and twitter packages have all been removed from the CMS.

User

Helper

Classes Removed Without Replacement

Utilities

Removed Classes and Interfaces

The following classes and interfaces have been removed in Joomla! 4.0:

use Joomla\Utilities\ArrayHelper; instead.

External Libraries

The following changes have been made to the external libraries that Joomla! packages and ships.

PHPMailer

Joomla! 4.0 ships with PHPMailer 6. Please review the GitHub repository for relevant changes.

PHPUTF8

At Joomla! 3.4, the PHPUTF8 library lived in two locations in the Joomla! package; `libraries/phputf8` and `libraries/vendor/joomla/string/src/phputf8`. In Joomla! 4.0, the copy of the library in `libraries/phputf8` has been removed. The Joomla\String\StringHelper class exposes many of the library's functions and the Composer autoloader definition imports much of the library as well, however, if you need a feature that is not already included then you should import the required functions from the `libraries/vendor/joomla/string/src/phputf8` path.

SimplePie

The SimplePie library is no longer included with Joomla! 4.0.

jQuery

Joomla! 4.0 ships with jQuery 3. Please review the upgrading guide for relevant changes. Note that we are not including jQuery Migrate anymore either. We recommend using it locally to help debug your code if there are any issues.

jQuery UI

jQuery UI has been removed from Joomla 4. Whilst it hasn't been officially announced as dead, there hasn't been a release of jQuery UI since 2016.

Bootstrap

Joomla! 4.0 ships with Bootstrap 5. Bootstrap 2.3.2 has been removed, however we have left some BS2 classes in to ease the migration (e.g. The old BS2 element-invisible still exists for screenreaders)

FOF

FOF 2.x has been removed.

Templates

All the Joomla! 3 templates - ISIS and Hathor in the Backend (Administrator), and Protostar and Beez in the Frontend (Site) are no longer supported. The new 4.0 Backend template is called Atum and the Frontend template is Cassiopeia.

As a consequence, all extensions must migrate to the new Bootstrap 5 style, away from the current Bootstrap 2.3.2 implementation. For more information about Bootstrap, visit the Bootstrap 5 Website and the Bootstrap 2.3.2 Website.

There where also changes to options of the core components that you should take a look at when your tempalte should support 3.x and 4.x at the same time: https://docs.joomla.org/J4.x:Changed_parameters_for_template_providers

Other

Media in Libraries

No media is allowed in the libraries root folder in the CMS. All assets associated with Joomla libraries should be put in the media folder per best practices. Direct access is blocked with a .htaccess and the web.config file in the root of the libraries directory.

Bin

Removing the keychain with 4.0 has resulted in the removal of the entire Bin directory as it only contained keychain.

Components

Plugins

Plugins (Events)

Administrator Helpers

Modules

Error Handling

Base Tag

Previous Joomla versions set a <base> header tag of the current URL in the Frontend. This has been removed as it served no clear purpose.

JavaScript

The caption.js file has been removed from Joomla. Use the native HTML elements figure and figcaption. (You can look at JLayout in layouts/joomla/content/intro_image.php for an example).

saveOrderAjax does not send complete form data (like it did in Joomla 3), only cid and order variable. This may be insufficient because some extensions need more data for proper sorting - see: https://github.com/joomla/joomla-cms/issues/36346

Namespacing

Class usage like $msg = JText::_( 'Hello man!' ); can now use namespacing. That would turn into $msg = Text::_( 'Hello man!' );. To use namespacing, you need to add the proper namespace declaration. This should be added after the defined('_JEXEC') or die;.

To find out the proper namespace you can either follow the instructions here: SO confused about namespace & enquemessage... or use the generated file PDF reference file: namespace reference.pdf

Namespace Mapping and Manifest File Name

Automatic namespace mapping won't work with extension manifest files named manifest.xml. See: https://github.com/joomla/joomla-cms/issues/37750


Top