Rückwärtskompatibilität: Mögliche Probleme in Joomla 4
From Joomla! Documentation
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
- 1 Aktualisierte Systemanforderungen
- 2 CMS Libraries
- 2.1 Installer
- 2.2 Menü
- 2.3 Pathway
- 2.4 Router
- 2.5 JVersion
- 2.6 JHtml
- 3 Platform
- 3.1 Application
- 3.2 Archive
- 3.3 Crypt
- 3.4 Cache
- 3.5 Component
- 3.6 Document
- 3.7 Database
- 3.8 Factory
- 3.9 Environment
- 3.10 Filesystem
- 3.11 Form
- 3.12 HTTP
- 3.13 Image
- 3.14 Menu
- 3.15 Keychain
- 3.16 Pathway
- 3.17 Table
- 3.18 Mail
- 3.19 Language
- 3.20 Legacy MVC Layer
- 3.21 Session
- 3.22 String
- 3.23 Social Media Libraries
- 3.24 Classes Removed Without Replacement
- 4 External Libraries
- 5 Templates
- 6 Other
In diesem Dokument werden mögliche Probleme mit der Abwärtskompatibilität für Joomla! 4 behandelt. Es werden Probleme aufgelistet, die möglicherweise zu Problemen mit Erweiterungen führen.
Die Vergleichsbasis ist Joomla! 3.9.
Die Systemanforderungen wurden wie folgt aktualisiert:
- PHP 7.2
- MySQL 5.6
- PostgreSQL 11.0
- SQL-Server Support wurde eingestellt.
PHP MySQL Erweiterung
- Joomla unterstützt die Verwendung des PHP-Treibers ext/mysql (der in PHP 7.0 entfernt wurde) nicht mehr. Joomla wird automatisch versuchen, die mysqli-Erweiterung (verfügbar seit PHP 5.3) oder den mysql-PDO-Treiber (verfügbar seit PHP 5.3) zu verwenden. Andernfalls wird keine Datenbankverbindung hergestellt.
- Der Strict-Modus wurde aktiviert. Die folgenden Flags sind jetzt standardmäßig in Joomla 4 aktiv und möglicherweise müssen die Datenbankabfragen entsprechend aktualisiert werden. Das wird uns bei zukünftigen Upgrades der MySQL-Version helfen und wird auch enger an Postgres ausgerichtet, um eine einfachere Kompatibilität mit Abfragen in beiden Sprachen zu ermöglichen.
'STRICT_TRANS_TABLES', 'ERROR_FOR_DIVISION_BY_ZERO', 'NO_AUTO_CREATE_USER', 'NO_ENGINE_SUBSTITUTION',
PHP Postgres Erweiterung
- Joomla unterstützt die Verwendung des PHP-Treibers ext/pgsql nicht mehr. Joomla wird automatisch versuchen, den PostgreSQL PDO-Treiber (verfügbar seit PHP 5.3 und Joomla 3.9) zu verwenden, andernfalls wird keine Datenbankverbindung hergestellt.
Die folgenden Änderungen wurden in den Joomla! CMS-Bibliotheken gemacht, das ist hauptsächlich der Code, der in Joomla! 3.7 und früheren Versionen im Verzeichnis „libraries/cms“ gefunden wurde.
- Plugin Discover-Installationen suchen nicht mehr nach Xml-Dateien in den Joomla! 1.5 Plugin-Ordner-Layouts.
- In 3.x haben nur Plugin-Skripte die Preflight-Methode aufgerufen und keine macht Postflight während des Deinstallationsprozesses verfügbar. Bei allen Erweiterungstypen werden diese Hooks (Programm-Schnittstellen) in 4.0 verfügbar sein, wenn sie deinstalliert werden. Wenn Sie derzeit ein Preflight und ein Postflight durchführen und davon ausgehen, dass sie nur in einem Installations-/Aktualisierungskontext angewendet werden, ist diese Logik jetzt falsch und Sie sollten die Installationsroute verwenden (die als einer der Methodenparameter angegeben wird).
- Bei der Deinstallation eines Plugins wird jetzt die Deinstallationsfunktion im Erweiterungs-Skript ausgelöst, bevor SQL-Abfragen ausgelöst werden (dies ist jetzt mit allen anderen Erweiterungstypen konsistent).
aus Joomla! entfernte Klassen
Die folgenden Klassen wurden in Joomla! 4.0 entfernt:
- JInstallerComponent (ersatzweise JInstallerAdapterComponent benutzen)
- JInstallerFile (ersatzweise JInstallerAdapterFile benutzen)
- JInstallerLanguage (ersatzweise JInstallerAdapterLanguage benutzen)
- JInstallerLibrary (ersatzweise JInstallerAdapterLibrary benutzen)
- JInstallerModule (ersatzweise JInstallerAdapterModule benutzen)
- JInstallerPackage (ersatzweise JInstallerAdapterPackage benutzen)
- JInstallerPlugin (ersatzweise JInstallerAdapterPlugin benutzen)
- JInstallerTemplate (ersatzweise JInstallerAdapterTemplate benutzen)
- JSubMenuHelper (ersatzweise JHtmlSidebar benutzen. Bitte beachten: im Gegensatz zu JSubMenuHelper muss jetzt ein Platzhalter in der Ansichtsvorlage hinzugefügt werden)
JInstallerAdapter no longer extends from JAdapterInstance and inherently JObject.
Benutzerdefinierte Installer-Adapter müssen jetzt automatisch geladen werden.
JMenu ist jetzt eine abstrakte Klasse
JMenu ist jetzt eine abstrakte Klasse. Unterklassen von JMenu müssen jetzt auch eine Lademethode implementieren.
Manuelles Include-Verhalten entfernt
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.
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.
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.
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:
- The register function in JHtml is now typehinted to require a callable. Subclasses of JHtml will now need to match this signature (note this was already required at the function code level already).
- JHtml::_ no longer allows you to call non-public methods in JHtml
- JHtml::_ is now a final method (you can no longer override it if you subclass JHtml) and it's signature has changed to take advantage of modern PHP features (scalar and variadic typehints)
- JHtmlBootstrap::modal has been removed. Use JHtmlBootstrap::renderModal
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).
The following classes have been removed in Joomla! 4.0:
- JApplicationWebRouter (use the `joomla/router` package instead)
- JApplicationWebRouterBase (use the `joomla/router` package instead)
- JApplicationWebRouterRest (use the `joomla/router` package instead)
The following classes have been deprecated and scheduled for removal in Joomla! 5.0:
- JApplicationBase (use Joomla\Application\AbstractApplication instead)
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.
- Old: JApplicationCli → JApplicationBase → Joomla\Application\AbstractApplication
- New: JApplicationCli → Joomla\Application\AbstractCliApplication → Joomla\Application\AbstractApplication
- Old: JApplicationWeb → JApplicationBase → Joomla\Application\AbstractApplication
- New: JApplicationWeb → Joomla\Application\AbstractWebApplication → Joomla\Application\AbstractApplication
- The legacy ways of calling JApplicationWeb::redirect have been removed
- With a message and messageType parameters (call enqueueMessage separately)
- Passing in a true/false value as the 2nd/3rd params instead of a redirect code will give an InvalidArgumentException instead of defaulting to a 303
- JApplicationWeb::$singleValueResponseHeaders has been removed because the Framework Application will be internally using PSR-7 Response objects as of its 2.0 release. This changes how the headers data is stored so it is always a multi-dimensional array with each top level key being the header names and the value being an array holding all of the values for that header.
- The $_clientId, $_messageQueue and $_name class properties have all been renamed to remove their underscore prefix.
- Now implements CMSApplicationInterface
- If there is an error retrieving a Pathway, Router or Menu object using the respective methods the exception will now bubble up rather than the method silently catching the exception and returning null
- CMSApplication::getInstance will now additionally try and load the user object (using the loadIdentity function)
- CMSApplication::isSite and CMSApplication::isAdmin have been removed as with the addition of the ConsoleApplication and ApiApplication can give misleading results. Please use CMSApplication::isClient (available from ). For more information please see Discover on which client your extension code is running
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 it's alias JApplicationSite::getParams
JApplicationHelper::parseXMLLangMetaFile has been removed without replacement.
- The archive package has been removed in favour of the frameworks archive package. Note the API should remain unchanged.
- Errors handing now uses Exceptions rather than JError
The following ciphers have been removed in Joomla! 4.0:
These have been removed without replacement. Use JCryptCipherCrypto
- JCrypt::hasStrongPasswordSupport has been removed without replacement (this attempted to detect bcrypt polyfills on linux hosting but has always returned true since we required PHP 5.3.10 in Joomla 3.3)
- JCacheController::get now requires a callable. As a result JCacheControllerCallback::call has been removed.
- JCacheStorage::test has been removed. Use JCacheStorage::isSupported instead
- The default storage engines are no longer manually loaded as they are now autoloaded
- JCacheControllerOutput::start and JCacheControllerOutput::end have been removed without replacement
- Removed CacheLite storage as it not compatible with PHP7 (which is our minimum version)
- Error handling now uses Exceptions instead of JError
- \Joomla\CMS\Component\ComponentRecord no longer extends JObject
The following classes have had their inheritance changed:
- JDocumentError (now extends from \Joomla\Cms\Document\HtmlDocument instead of \Joomla\Cms\Document\Document)
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.
- In order to comply with the RSS feed specification, JDocumentRendererFeedRss now allows the lastBuildDate element to be configured using the JDocumentFeed::$lastBuildDate class property when a feed is rendered. This value defaults to the current time, as is the case with Joomla! 3.x and earlier, however the time can be correctly set by changing this class property to a JDate object representing the desired timestamp.
- There is now a RendererInterface that all Renderers should implement
- JDocumentRenderer is now an abstract class and implements RendererInterface
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.
- This package has been replaced by the Joomla Framework Database Package
- Debug mode has been reworked (see the framework docs for more information )
- Factory::getApplication no longer takes arguments. These were misleading as it always returned the active application after the first call in the bootstrap, whatever arguments were passed into the function.
- Factory::getXml has been removed along with JXMLElement. Use SimpleXMLElement directly instead.
- Factory:: getEditor has been removed use JEditor::getInstance instead.
- JBrowser::isSSLConnection has been removed. Use JApplicationCms::isSSLConnection (available since Joomla 3.2)
- The filesystem wrapper classes have been removed. Continue using the original static methods.
- The libraries/joomla/form/fields and libraries/joomla/form/rules directories are no longer registered to find form classes, all form classes should be autoloaded instead
- Two new properties added addfieldprefix which registers a namespace prefix for extensions (intended to be used as a replacement for addfieldpath). For example usage please see this Github PR
- JForm::getControlGroup has been removed use the alias JForm::renderField (available since Joomla 3.2.3)
- JForm::getControlGroups has been removed use the alias JForm::renderFieldset (available since Joomla 3.2.3)
- JFormFieldUsergroup has been removed. Use Joomla\CMS\Form\Field\UsergrouplistField instead (available since Joomla 3.2)
- JFormFieldFilelist and JFormFieldFolderList have had their filter properties renamed to
folderFilterrespectively (in order to allow the use of the regular Joomla filter attribute on returned values)
Deprecated Classes and Interfaces
The following classes and interfaces have been deprecated and scheduled for removal in Joomla! 5.0:
- JHttpResponse (use Joomla\Http\Response instead)
- JHttpTransport (implement Joomla\Http\TransportInterface instead)
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.
The JHttp class constructor has been loosened with the following changes:
- The options parameter is no longer typehinted as a Joomla\Registry\Registry object, an array or any object implementing the ArrayAccess interface can be used instead
- The transport parameter now allows any Joomla\Http\TransportInterface object.
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.
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).
Deprecated Classes and Interfaces
The following classes and interfaces have been deprecated and scheduled for removal in Joomla! 5.0:
- JImageFilter (use Joomla\Image\ImageFilter instead)
- JImageFilterBackgroundfill (use Joomla\Image\Filter\Backgroundfill instead)
- JImageFilterBrightness (use Joomla\Image\Filter\Brightness instead)
- JImageFilterContrast (use Joomla\Image\Filter\Contrast instead)
- JImageFilterEdgedetect (use Joomla\Image\Filter\Edgedetect instead)
- JImageFilterEmboss (use Joomla\Image\Filter\Emboss instead)
- JImageFilterGrayscale (use Joomla\Image\Filter\Grayscale instead)
- JImageFilterNegate (use Joomla\Image\Filter\Negate instead)
- JImageFilterSketchy (use Joomla\Image\Filter\Sketchy instead)
- JImageFilterSmooth (use Joomla\Image\Filter\Smooth instead)
The Framework's Image package is now included in Joomla! 4.0 and JImage and the JImageFilter subclasses have been refactored to use the upstream package.
- JMenu::$_items, JMenu::$_default and JMenu::$_active have been had their underscore prefix's removed (note these properties were protected so this only affects custom subclasses of JMenu)
Removing the keychain with 4.0 has resulted in the removal of the following class:
- JPathway::$_pathway and JPathway::$_count have been had their underscore prefix's removed (note these properties were protected so this only affects custom subclasses of JPathway)
- JPathway::_makeItem has been removed in favour of JPathway::makeItem (note this method was protected so this only affects custom subclasses of JPathway)
- JTable::__construct database object is now typehinted to be a JDatabaseDriver.
- Subclasses of JTable will need to ensure they are passing a JDatabaseDriver object to the parent constructor
- Subclasses of JTable will need to change the method signature of setDbo() if they have an extended version of that method to include the typehint
- There is a new method JTable::hasField - all instances of property_exists on JTable instances will now use this proxy method instead to allow better interoperability of Table instances
- The JTableObserver pattern (and corresponding classes) has been removed from JTable. JTable now triggers events and Tags, Content History (and any other custom uses of this pattern) should move to standard plugins.
The following methods have been removed in Joomla! 4.0:
- JMail::sendAdminMail has been removed
- The functions setTransliterator, setPluralSuffixesCallback, setIgnoredSearchWordsCallback, setLowerLimitSearchWordCallback, setUpperLimitSearchWordCallback and setSearchDisplayedCharactersNumberCallback are now typehinted to require a callable.
- The "_QQ_" placeholder for double quotes has been removed (this only existed to work around an old PHP Bug that has been fixed). Escape double quotes if required (i.e. \")
Legacy MVC Layer
- JControllerLegacy has been removed from the legacy layer, and we no longer intend to remove it or it's subclasses in the near future.
- JControllerLegacy no longer extends JObject. Controllers should not call any of the methods contained in the JObject class.
- JControllerLegacy implements an interface for multiple task controllers
- JControllerLegacy::_construct now takes additional arguments. If you were previously getting a Controller object through JControllerLegacy::getInstance you do not need to change your code.
- Parameter 2: An optional MVCFactoryInterface instance
- Parameter 3: An optional CMSApplicationInterface instance
- Parameter 4: An optional Input instance
- Parameter 5: An optional FormFactoryInterface instance
- JControllerForm now using the StringInflector package to determine the list view. This should improve it's ability to guess determine the list view of more view names. If extension developers find that their list view is no longer being found they should manually set the `view_list` class property in their controller.
- JViewLegacy has been removed from the legacy layer, and we no longer intend to remove it or it's subclasses in the near future.
- JViewHtml has been split into two classes - AbstractView and HtmlView. Abstract view contains the logic for accessing models and getting the name of the view and is intended to be a base class for non-Html views. Html view contains the same logic as before.
- There are now two subclasses of JViewHtml - \Joomla\CMS\MVC\View\ListView and \Joomla\CMS\MVC\View\FormView designed to speed up the development of list and form views and reduce code duplication.
The session package has undergone a major refactoring to use the Framework's Session package. This change primarily effects the internals of the package; changes to the primary public API through the JSession class are minimal.
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! 5.0:
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.
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.
The singleton getInstance() method has been deprecated. The session object should be retrieved from the active application or the dependency injection container instead.
Social Media Libraries
The facebook, github, google, linkedin, openstreetmap, mediawiki and twitter packages have all been removed from the CMS.
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.
Classes Removed Without Replacement
- JError (use native exceptions when error handling is required)
Removed Classes and Interfaces
The following classes and interfaces have been removed in Joomla! 4.0:
use Joomla\Utilities\ArrayHelper; instead.
The following changes have been made to the external libraries that Joomla! packages and ships.
Joomla! 4.0 ships with PHPMailer 6.0. Please review the upgrading guide for relevant changes.
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.
The SimplePie library is no longer included with Joomla! 4.0.
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.
Joomla! 4.0 ships with Bootstrap 4. 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 2.x has been removed.
All the Joomla! 3 templates - ISIS and Hathor in the backend, and protostar and Beeze in the frontend are no longer supported. The new 4.0 backend template is called Atum and the frontend template is called Cassiopeia.
As a consequence, all extensions must migrate to the new Bootstrap 4 style, away from the current Bootstrap 2.3.2 implementation. For more information about Bootstrap 4: . For more information about Bootstrap 2.3.2: 
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 as per best practices. Direct access is blocked with a .htaccess and web.config file in the root of the libraries directory.
Removing the keychain with 4.0 has resulted in the removal of the entire Bin directory as it only contained keychain.
- All components have been namespaced and directories reworked accordingly. For more information about this read the tutorial on building a component in Joomla 4
- com_admin profile view has been removed (this appears to have been created historically due to issues accessing com_users. This is no longer the case so all user edits go through com_users edit user view in the backend)
- com_actionlogs php 5.5 backfill code has been removed and accordingly
ActionlogsHelper::getCsvData()is now type hinted to return a
- Core components have had URL Routing 'Legacy' mode removed from Joomla 3.7. You should either use your .htaccess file or the redirect component to fix any internal URLs that change. You can try the 'Modern' mode in Joomla 3 by following the instructions here
- The gmail authentication plugin has been removed. For more information please read this blog post
- Recaptcha v1 support has been fully removed from the captcha plugin - this has no longer worked since Q2 2018 due to google dropping support for it.
- The Recaptcha plugin now uses google's official php library for captcha under the hood
- For plugins using the 3.x compatibility layer the name result is a protected property for both input parameters and return values. For information on the new recommended approach to plugins please read S:MyLanguage/J4.x:Creating_a_Plugin_for_Joomla
- For plugins using the 3.x compatibility layer any type hints for events that require a class - the class *must* be autoloaded before the plugin is instantiated
- The onContentBeforeSave event now requires the data parameter (this has been passed in \Joomla\CMS\MVC\Model\LegacyModel since 3.7 but is now passed in consistently by core extensions and used by the core Joomla content plugin)
- JAdministratorHelper has been removed without replacement (it's been merged into JApplicationAdministrator)
- JSubMenuHelper has been removed without replacement (use JHtmlSidebar instead - available since 3.0)
- JToolbarHelper has been moved to the main libraries directory
- The administrator module "submenu" has been removed
- Joomla will now handle PHP's E_USER_DEPRECATED errors and pipes it into JLog - this is useful for handling deprecations in many 3rd party PHP Libraries (note it will block the page load if debug mode is enabled)
- Joomla\CMS\Exception\ExceptionHandler now only operates on Exceptions thrown in JApplication::execute. We now use Symfony's ErrorHandler when this fails or exceptions are thrown outside of this. We expect this to have minimal effect on most users and should give a more helpful message in many cases than the traditional "Error displaying the error page" error for users when things go very wrong.
- Joomla\CMS\Exception\ExceptionHandler is now format aware and will render errors in html, json, xml, feed or cli aware formats
- The Joomla\CMS\Exception\ExceptionHandler::render() signature is changed to include the Throwable typehint. Before 3.5 when PHP 7 support was added this was typehinted as Exception, and since 3.5 has been typechecked in the code itself.