Skip to content

[7.0] Add a compatibility switch for deprecated functions#47911

Merged
HLeithner merged 16 commits into
joomla:7.0-devfrom
Digital-Peak:compatibility-switch
Jun 17, 2026
Merged

[7.0] Add a compatibility switch for deprecated functions#47911
HLeithner merged 16 commits into
joomla:7.0-devfrom
Digital-Peak:compatibility-switch

Conversation

@laoneo

@laoneo laoneo commented Jun 7, 2026

Copy link
Copy Markdown
Member
  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

Deprecated classes, assets and classnames can be moved to the compatibility plugin, but not single deprecated functions. In core we have a lot of deprecated functions which are widely used in the past in template overrides or other custom PHP code. Removing them would be a hard backwards compatibility break. This pr introduces a switch for deprecated functions, enabled in the compatibility plugin. This is a fallback for sites with old code or unmaintained extensions to give them an extra two years to update that code.

Testing Instructions

Add the following code to the file /components/com_content/src/Dispatcher/Dispatcher.php after line 36:
\Joomla\CMS\Factory::getConfig();

Load the site home page with the compatibility 7 plugin enabled and disabled.

Actual result BEFORE applying this Pull Request

It works with the plugin enabled and disabled.

Expected result AFTER applying this Pull Request

It shows an error when the plugin is disabled and loads fine when enabled.

Link to documentations

Please select:

@laoneo laoneo marked this pull request as draft June 7, 2026 07:45
Comment thread libraries/src/Mail/MailTemplate.php Outdated
Comment thread plugins/behaviour/compat6/src/Extension/Compat6.php Outdated
@joomdonation

joomdonation commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

From PHP manual:

Passing E_USER_ERROR as the error_level is now deprecated. Throw an Exception or call exit() instead.

Maybe throw BadMethodCallException could be a better choice here.

@laoneo

laoneo commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

I had exceptions first, but then you copy basically the same text as in trigger_error. Till we have a decision if this is an acceptable way to transition from widely used deprecated code I leave it as it is. But I was not aware that the constant was deprecated, definitely worth then to switch to exception.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@richard67

Copy link
Copy Markdown
Member

For now, I moved the switch to the compat6 plugin as the 7 one is not working.

@laoneo As this has been fixed meanwhile, please remove that sentence from the PR description.

@laoneo laoneo marked this pull request as ready for review June 17, 2026 08:05
@laoneo laoneo requested a review from rdeutz as a code owner June 17, 2026 08:05
@laoneo laoneo requested review from HLeithner and Hackwar June 17, 2026 08:14
@HLeithner HLeithner merged commit 7fa56ae into joomla:7.0-dev Jun 17, 2026
57 checks passed
@HLeithner

Copy link
Copy Markdown
Member

thanks

@HLeithner HLeithner deleted the compatibility-switch branch June 17, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants