{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/25677","repository_url":"https://api.github.com/repos/joomla/joomla-cms","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/25677/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/25677/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/25677/events","html_url":"https://github.com/joomla/joomla-cms/issues/25677","id":470801860,"node_id":"MDU6SXNzdWU0NzA4MDE4NjA=","number":25677,"title":"[4.0] onWebAssetBeforeAttach. 0 - Cannot set the argument result of the immutable event onWebAssetBeforeAttach","user":{"login":"ReLater","id":20780646,"node_id":"MDQ6VXNlcjIwNzgwNjQ2","avatar_url":"https://avatars2.githubusercontent.com/u/20780646?v=4","gravatar_id":"","url":"https://api.github.com/users/ReLater","html_url":"https://github.com/ReLater","followers_url":"https://api.github.com/users/ReLater/followers","following_url":"https://api.github.com/users/ReLater/following{/other_user}","gists_url":"https://api.github.com/users/ReLater/gists{/gist_id}","starred_url":"https://api.github.com/users/ReLater/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReLater/subscriptions","organizations_url":"https://api.github.com/users/ReLater/orgs","repos_url":"https://api.github.com/users/ReLater/repos","events_url":"https://api.github.com/users/ReLater/events{/privacy}","received_events_url":"https://api.github.com/users/ReLater/received_events","type":"User","site_admin":false},"labels":[{"id":878880830,"node_id":"MDU6TGFiZWw4Nzg4ODA4MzA=","url":"https://api.github.com/repos/joomla/joomla-cms/labels/J4%20Issue","name":"J4 Issue","color":"8e3fd3","default":false},{"id":138443932,"node_id":"MDU6TGFiZWwxMzg0NDM5MzI=","url":"https://api.github.com/repos/joomla/joomla-cms/labels/No%20Code%20Attached%20Yet","name":"No Code Attached Yet","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2019-07-21T16:55:36Z","updated_at":"2019-07-22T07:38:55Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### Steps to reproduce the issue\r\n- In a discussion about the B\\C breaks as a result of implemented WebAssetManager thing in Joomla 4 and plugin events that can be used to get rid of assets that WebAsset thing imports in a B\\C breaking way even if related JHtml helpers are overriden like it was possible in Joomla 3 over years\r\n\r\nI found this comment of @Fedik\r\n\r\nhttps://github.com/joomla/joomla-cms/pull/24858#issuecomment-491502468\r\n\r\n> such event already exist, called `onWebAssetBeforeAttach` https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/WebAsset/WebAssetManager.php#L343\r\n\r\n- Thus I added \r\n```\r\npublic function onWebAssetBeforeAttach($a, $b)\r\n{\r\n}\r\n``` \r\nin a system plugin, e.g. the sef plugin, and tried several variations of that code\r\n\r\n### Expected result\r\n- At least: Nothing happens.\r\n\r\n### Actual result\r\n#### SEF plugin, Backend and frontend (ignores debug mode (no call stack)).\r\n\r\n> Error: Cannot set the argument result of the immutable event onWebAssetBeforeAttach.: Cannot set the argument result of the immutable event onWebAssetBeforeAttach.\r\n\r\n#### In a more complex custom plugin I get a call stack\r\n\r\n```\r\nCall stack\r\n--\r\n# | Function | Location\r\n1 | () | JROOT\\libraries\\src\\Event\\AbstractImmutableEvent.php:67\r\n2 | Joomla\\CMS\\Event\\AbstractImmutableEvent->offsetSet() | JROOT\\libraries\\src\\Plugin\\CMSPlugin.php:289\r\n3 | Joomla\\CMS\\Plugin\\CMSPlugin->Joomla\\CMS\\Plugin\\{closure}() | JROOT\\libraries\\vendor\\joomla\\event\\src\\Dispatcher.php:495\r\n4 | Joomla\\Event\\Dispatcher->dispatch() | JROOT\\libraries\\src\\WebAsset\\WebAssetManager.php:349\r\n5 | Joomla\\CMS\\WebAsset\\WebAssetManager->attachActiveAssetsToDocument() | JROOT\\libraries\\src\\Document\\Renderer\\Html\\MetasRenderer.php:54\r\n6 | Joomla\\CMS\\Document\\Renderer\\Html\\MetasRenderer->render() | JROOT\\libraries\\src\\Document\\Renderer\\Html\\HeadRenderer.php:36\r\n7 | Joomla\\CMS\\Document\\Renderer\\Html\\HeadRenderer->render() | JROOT\\libraries\\src\\Document\\HtmlDocument.php:499\r\n8 | Joomla\\CMS\\Document\\HtmlDocument->getBuffer() | JROOT\\libraries\\src\\Document\\HtmlDocument.php:798\r\n9 | Joomla\\CMS\\Document\\HtmlDocument->_renderTemplate() | JROOT\\libraries\\src\\Document\\HtmlDocument.php:570\r\n10 | Joomla\\CMS\\Document\\HtmlDocument->render() | JROOT\\libraries\\src\\Application\\CMSApplication.php:970\r\n11 | Joomla\\CMS\\Application\\CMSApplication->render() | JROOT\\libraries\\src\\Application\\SiteApplication.php:744\r\n12 | Joomla\\CMS\\Application\\SiteApplication->render() | JROOT\\libraries\\src\\Application\\CMSApplication.php:247\r\n13 | Joomla\\CMS\\Application\\CMSApplication->execute() | JROOT\\includes\\app.php:63\r\n14 | require_once() | JROOT\\index.php:36\r\n```\r\n\r\n### System information (as much as possible)\r\nJ!4 nightly of today,\r\nXAMPP PHP 7.2\r\nand PHP 7.3/Linux (at a host) \r\n\r\n### Additional comments\r\n- After several days of revision of J3 extensions to make them J4 ready I'm frustrated. From my point of view codes that are marked as \"deprecated\" should work as with Joomla 3 until they are removed from core completely in the end. The WebAssetManager is an example that ignores that completely and needs nasty/additional hacks."},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/513677487","html_url":"https://github.com/joomla/joomla-cms/issues/25677#issuecomment-513677487","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/25677","id":513677487,"node_id":"MDEyOklzc3VlQ29tbWVudDUxMzY3NzQ4Nw==","user":{"login":"Fedik","id":1568198,"node_id":"MDQ6VXNlcjE1NjgxOTg=","avatar_url":"https://avatars1.githubusercontent.com/u/1568198?v=4","gravatar_id":"","url":"https://api.github.com/users/Fedik","html_url":"https://github.com/Fedik","followers_url":"https://api.github.com/users/Fedik/followers","following_url":"https://api.github.com/users/Fedik/following{/other_user}","gists_url":"https://api.github.com/users/Fedik/gists{/gist_id}","starred_url":"https://api.github.com/users/Fedik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fedik/subscriptions","organizations_url":"https://api.github.com/users/Fedik/orgs","repos_url":"https://api.github.com/users/Fedik/repos","events_url":"https://api.github.com/users/Fedik/events{/privacy}","received_events_url":"https://api.github.com/users/Fedik/received_events","type":"User","site_admin":false},"created_at":"2019-07-22T07:38:55Z","updated_at":"2019-07-22T07:38:55Z","author_association":"CONTRIBUTOR","body":"> I use a plugin that \"overregisters\" HTMLHelpers (also) like 'jquery.framework' as early as possible e.g. to load jquery from CDN\r\n\r\nAdding asset with the same name will override previous asset, in the asset registry.\r\n```php\r\n$wa = $doc->getWebAssetManager();\r\n$wr = $wa->getRegistry();\r\n$wr->add(new WebAssetItem('jquery', ['js' => ['http://foobar.com/jquery.js']]));\r\n```\r\nthis will overridden jQuery, can be called at onWebAssetBeforeAttach, beforeRender, afterDispatch"}}
{"actor":{"display_login":"Fedik"}}