I have a multilingual website where everything was running fine under J3. I migrated to J4 (and also switched to YOOtheme Pro. I mention it just in case).

And now the Edit button on the Association Tab (for Articles and for Menu Items) always give a 404.

After some tests, I realized that I could see in the Console that the called url was actually


I was puzzled by the %27%20272%20%27 at the end of the url. The Article ID in this case was 272 so I manually typed the following url (dropping the "%27%20" before and the "%20%27" after the item ID:


And there the page works (I open it on a separate Tab, even if it is supposed to be a Modal of course).

So what is wrong? Why these "%27%20" before and "%20%27" after the Article or Menu Item ID?

Txs for your suggestions! (I also tried different PHP versions just in case but that would not solve anything)

EDIT1: actually I discovered this bug in the context of Multilingual Association, but the same issue arises with the classical "Edit" article button that can be found when Editing a Menu Item

EDIT2: FYI here is the corresponding HTML in the page (which is exactly similar to the HTML on another J4 site where everything works fine)

<div id="ModalEditArticle_jform_associations_fr_FR" tabindex="-1" class="joomla-modal modal fade" data-bs-backdrop="static" data-bs-keyboard="false" data-url="index.php?option=com_content&amp;view=article&amp;layout=modal&amp;tmpl=component&amp;165fca538bd5a6f8ec413c37271fbfd8=1&amp;forcedLanguage=fr-FR&amp;task=article.edit&amp;id=' + document.getElementById(&quot;jform_associations_fr_FR_id&quot;).value + '" data-iframe="<iframe class=&quot;iframe&quot; src=&quot;index.php?option=com_content&amp;amp;view=article&amp;amp;layout=modal&amp;amp;tmpl=component&amp;amp;165fca538bd5a6f8ec413c37271fbfd8=1&amp;amp;forcedLanguage=fr-FR&amp;amp;task=article.edit&amp;amp;id=' + document.getElementById(&amp;quot;jform_associations_fr_FR_id&amp;quot;).value + '&quot; name=&quot;Edit Article&quot; title=&quot;Edit Article&quot; height=&quot;400px&quot; width=&quot;800px&quot;></iframe>" style="display: none;" aria-hidden="true">

  • I'd like to see what the rendered HTML source code says for @Marc. What is the value at document.getElementById("[the_article_id]_id").value? Is it space-padded and quoted? Jul 11, 2022 at 2:11
  • If I type document.getElementById("jform_associations_fr_FR_id").value in the Console, I get '267' (I get a similar result on another J4 site where the Edit button works fine) So it is as if "something" was adding that %27%20 before and %20%27 after the ID I also made another test: In the file ArticleField.php mentioned below if I replace $urlEdit = $linkArticle . '&amp;task=article.edit&amp;id=\' + document.getElementById(&quot;' . $this->id . '_id&quot;).value + \''; by $urlEdit = $linkArticle . '&amp;task=article.edit&amp;id=267'; then the Modal works fine (no 404) Jul 12, 2022 at 9:27
  • When invisible characters are involved, use var_dump($urlEdit); to see the byte count. It the count is different from the number of characters, something is afoul. Jul 12, 2022 at 10:02
  • Txs for the kind help. Here is what it gives (not sure to understand what I should do (since &quot; etc in PHP file are converted) string(253) "index.php?option=com_content&view=article&layout=modal&tmpl=component&165fca538bd5a6f8ec413c37271fbfd8=1&forcedLanguage=fr-FR&task=article.edit&id=' + document.getElementById("jform_associations_fr_FR_id").value + '" string(253) "index.php?option=com_content&view=article&layout=modal&tmpl=component&165fca538bd5a6f8ec413c37271fbfd8=1&forcedLanguage=en-GB&task=article.edit&id=' + document.getElementById("jform_associations_en_GB_id").value + '" Jul 12, 2022 at 10:36
  • 1
    txs a lot @mickmackusa for your kind help. I have edited ArticleField.php as such, just to avoid &quot; etc: document.getElementById("' . $this->id . '_id").value But even like that, I still get %27%20MYARTICLEID%20%27 where MYARTICLEID is the true wished Article ID This make me think of a server-side issue, configuration of PHP, something in htaccess for example. Because as such ArticleField.php is correct Jul 12, 2022 at 14:13

2 Answers 2


If I understand correctly, the URL is formed here. I don't know much about the router.


I would debug and compare the URL of your problem system with a working one.

  • Good find. This just shows how hideous code can get when you are concatenating server-side and client-side values together in a string. Yuck. Jul 11, 2022 at 2:03
  • See my comment above. You pointed to the right file. There if I type the article ID (being 267) in ArticleEdit.php on the line(s) $urlEdit instead of that whole little javascript, no issue any more. But the goal is not to have 267 for all articles of course. So somehow, something adds that %27%20 before and %20%27 after the ID Jul 12, 2022 at 9:29

Within /administrator/components/com_content/src/Field/Modal/ArticleField.php, resolve the problem by removing the offending, escaped single-quotes (apostrophes) around the id value of the dynamic query string.

$urlEdit   = $linkArticle . '&amp;task=article.edit&amp;id=\' + document.getElementById(&quot;' . $this->id . '_id&quot;).value + \'';

Replacement line:

$urlEdit   = $linkArticle . '&amp;task=article.edit&amp;id=+ document.getElementById(&quot;' . $this->id . '_id&quot;).value +';

I'm very, very grateful to Dimitris Grammatikogiannis for suggesting this fix.

But this still does not explain why I was only facing the issue on this particular (migrated) J4 website and not on other (migrated or native) J4 websites.

Maybe there is something with the server configuration?

EDIT: I now discovered that I face the same issue with the Edit button on the Associations tab when editing a Menu Item.

There, the file which has to be corrected is: /administrator/components/com_menus/src/Field/Modal/MenuField.php.

To resolve, remove the two occurrences of escaped single-quotes as done in the aforementioned line of code.

$urlEdit   = $linkItem . '&amp;task=item.edit&amp;id=\' + document.getElementById("' . $this->id . '_id").value + \'';

The new code needs to be:

$urlEdit   = $linkItem . '&amp;task=item.edit&amp;id=+ document.getElementById("' . $this->id . '_id").value +';

--- edit 2022.08.04 - the root cause ---

The strange thing about this issue is that I only had it on a couple of J4 sites, while all the other ones are OK.

Yesterday, txs to the following post on the Joomla Facebook Group, I discovered the root cause, namely some rule of ModSecurity:


So of course one could disable ModSecurity. But applying the fix above is a better solution since it allows to keep ModSecurity on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.