User tests: Successful: Unsuccessful:
This PR removes getRouter() from CMSWebApplicationInterface and restricts the concrete application methods to compatibility mode.
The method has been deprecated since Joomla 4.3, but core still uses it. To allow Joomla 7 to run without the backward compatibility plugin, this PR:
CMSApplication and ConsoleApplication with COMPAT_JOOMLA_7, following the existing compatibility pattern.SiteRouter service.Route::link() only when compatibility mode is enabled.The retained compatibility methods are documented for removal in Joomla 8. The separate BeforeApiRouteEvent::getRouter() API is unaffected.
Apply the PR to 7.0-dev.
With Composer dependencies installed, run:
php libraries/vendor/bin/phpunit \
--filter 'ApplicationRouterCompatibilityTest|RouteTest|ComponentRouterTaintTest|ConsoleApplicationTest'Expected result: 25 tests and 94 assertions pass.
getRouter() calls without compatibility mode.getRouter() compatibility exception.Local validation completed successfully: the tests above, PHP syntax checks, project code-style checks, and PHPStan analysis of the changed production files.
Please select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | Front End com_contact com_content com_newsfeeds Libraries Unit Tests |
| Labels |
Added:
Unit/System Tests
PR-7.0-dev
|
||
I have tested this item successfully at runtime, but it needs changes: the new tests don't run under PHPUnit 12, so the unit test jobs fail in CI.
7.0-dev uses PHPUnit 12.5, which no longer reads @dataProvider, @runTestsInSeparateProcesses or @preserveGlobalState. Running the PR's own command:
Tests: 8, Assertions: 5, Errors: 5.
ArgumentCountError: Too few arguments to function ...::testRouterAccessRequiresCompatibility(), 0 passed ... exactly 1 expected
This is not the expected 25 tests, 94 assertions. Without process isolation, define('COMPAT_JOOMLA_7', true) would also leak into later tests. Fix: use attributes, as the other tests in tests/Unit do:
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
#[RunTestsInSeparateProcesses]
#[PreserveGlobalState(false)]
class RouteTest extends UnitTestCase
{
#[DataProvider('compatibilityModes')]
public function testLinkUsesTheContainerRouterWithoutALegacyApplication(bool $compatibility): voidWith that change: 25 tests, 112 assertions, all pass, and the full Unit suite is green. One small cleanup: ComponentRouterTaintTest triggers 3 PHPUnit notices (No expectations were configured for the mock object for QueryInterface), so use createStub() for $query.
Neither manual.joomla.org checkbox is ticked. Removing getRouter() from CMSWebApplicationInterface and having it throw without the compat plugin needs an entry in the 6.x → 7.0 Removed and Backward Incompatibility page. The compat plugin is disabled on a fresh 7.0 install.
| Check | compat7 off | compat7 on |
|---|---|---|
| Home, administrator login page | ✅ | ✅ |
| Administrator dashboard, API (401 without token), CLI | ✅ | not tested |
| article / contact / newsfeed, correct URL | 200 | 200 |
old id-alias URL (IDs removed) or wrong alias (IDs in URL) → tainted → 301 to the correct URL |
✅ all 3 | ✅ all 3 |
Factory::getApplication()->getRouter() in a template |
BadMethodCallException |
SiteRouter |
One more thing: in the description, the content under Actual result BEFORE and Expected result AFTER is swapped.
I have tested this item successfully at runtime, but it needs changes: the new tests don't run under PHPUnit 12, so the unit test jobs fail in CI.
1. New tests fail: docblock annotations are ignored by PHPUnit 12
7.0-dev uses PHPUnit 12.5, which no longer reads
@dataProvider,@runTestsInSeparateProcessesor@preserveGlobalState. Running the PR's own command:This is not the expected 25 tests, 94 assertions. Without process isolation,
define('COMPAT_JOOMLA_7', true)would also leak into later tests. Fix: use attributes, as the other tests intests/Unitdo:With that change: 25 tests, 112 assertions, all pass, and the full Unit suite is green. One small cleanup:
ComponentRouterTaintTesttriggers 3 PHPUnit notices (No expectations were configured for the mock object for QueryInterface), so usecreateStub()for$query.2. Manual entry missing
Neither manual.joomla.org checkbox is ticked. Removing
getRouter()fromCMSWebApplicationInterfaceand having it throw without the compat plugin needs an entry in the 6.x → 7.0 Removed and Backward Incompatibility page. The compat plugin is disabled on a fresh 7.0 install.Tested (7.0-dev + PR, PHP 8.3, SEF on)
id-aliasURL (IDs removed) or wrong alias (IDs in URL) → tainted → 301 to the correct URLFactory::getApplication()->getRouter()in a templateBadMethodCallExceptionSiteRouterOne more thing: in the description, the content under Actual result BEFORE and Expected result AFTER is swapped.