Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft CMS 6

## Unreleased

- Fixed a bug where the legacy `yii\web\JqueryAsset` wasn’t resolving properly. ([#19264](https://github.com/craftcms/cms/pull/19264))

## 6.0.0-alpha.13 - 2026-07-16

- Updated logout routes to require CSRF-protected POST requests. ([#19252](https://github.com/craftcms/cms/pull/19252/changes/ff6f20717a48e7ede5fbbe47487e7bb8ef71da78))
Expand Down
10 changes: 10 additions & 0 deletions yii2-adapter/legacy/helpers/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
use yii\mutex\FileMutex;
use yii\mutex\MysqlMutex;
use yii\mutex\PgsqlMutex;
use yii\web\JqueryAsset as YiiJqueryAsset;
use yii\web\JsonParser;
use function CraftCms\Cms\backTraceAsString;
use function CraftCms\Cms\craftAsset;
use function CraftCms\Cms\maxPowerCaptain;
use function CraftCms\Cms\normalizeValue;
use function CraftCms\Cms\normalizeVersion;
Expand Down Expand Up @@ -604,6 +606,14 @@ public static function assetManagerConfig(): array
'fileMode' => $generalConfig->defaultFileMode,
'dirMode' => $generalConfig->defaultDirMode,
'appendTimestamp' => true,
'bundles' => [
YiiJqueryAsset::class => [
'sourcePath' => null,
'js' => [
craftAsset('legacy/jquery/dist/jquery.js'),
],
],
],
];
}

Expand Down
28 changes: 28 additions & 0 deletions yii2-adapter/tests-laravel/View/CpAssetOrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use CraftCms\Cms\View\Enums\Position;
use CraftCms\Cms\View\HtmlStack as HtmlStackService;
use yii\web\AssetBundle;
use yii\web\JqueryAsset as YiiJqueryAsset;

class CpAssetDependentAssetBundle extends AssetBundle
{
Expand All @@ -21,6 +22,19 @@ class CpAssetDependentAssetBundle extends AssetBundle
];
}

class YiiJqueryDependentAssetBundle extends AssetBundle
{
public $baseUrl = 'https://example.test/assets';

public $depends = [
YiiJqueryAsset::class,
];

public $js = [
'depends-on-yii-jquery.js',
];
}

beforeEach(function() {
HtmlStack::clear();

Expand All @@ -42,6 +56,20 @@ class CpAssetDependentAssetBundle extends AssetBundle
->and(strpos($html, 'legacy/jquery/dist/jquery.js'))->toBeLessThan(strpos($html, 'https://example.test/assets/dependent.js'));
});

it('resolves Yii jQuery asset bundles to the internal jQuery asset', function() {
$view = Craft::$app->getView();

$view->registerAssetBundle(YiiJqueryDependentAssetBundle::class);

$html = $view->placeholderHtml()['bodyEndHtml'];

expect($html)
->toContain('legacy/jquery/dist/jquery.js')
->and($html)->toContain('https://example.test/assets/depends-on-yii-jquery.js')
->and(strpos($html, 'legacy/jquery/dist/jquery.js'))->toBeLessThan(strpos($html, 'https://example.test/assets/depends-on-yii-jquery.js'))
->and($html)->not->toContain('cpresources');
});

it('uses the current scoped HtmlStack after scoped instances are flushed', function() {
$view = Craft::$app->getView();

Expand Down