Skip to content

Conversation

Copy link

Copilot AI commented Nov 6, 2025

When updating WordPress core with non-English locales, Language_Pack_Upgrader::async_upgrade() outputs HTML markup intended for the admin interface, polluting CLI output with <p>, <div>, and <script> tags.

Changes

Added early-priority hook to remove the async translation upgrader before it executes:

// In Core_Command::update(), after requiring upgrade.php
add_action(
    'upgrader_process_complete',
    function () {
        remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
    },
    1
);

This matches the existing pattern used in plugin/theme updates per @swissspidy's recommendation.

Testing

Added Behat test scenario "No HTML output from async translation updates during core update" that verifies:

  • No <p> tags in output
  • No <div> tags in output
  • No <script> tags in output
  • No </div> closing tags in output

Fixes #191

Original prompt

This section details on the original issue you should resolve

<issue_title>Unexpected HTML output when updating WordPress</issue_title>
<issue_description>If I update WP using wp core update I get a lot of unexpected HTML output coming from WordPress itself:

$ wp core update
Updating to version 4.0 (pt_BR)...
Descompactando a atualização...
<p>Algumas traduções precisam de atualização. Descanse por mais alguns segundos, enquanto atualizamos elas também.</p>
<div class="update-messages lp-show-latest"><h4>Atualizando traduções de WordPress (pt_BR)&#8230;</h4><p>Fazendo download da tradução de <span class="code">(http://downloads.wordpress.org/translation/core/4.0/pt_BR.zip)</span>&#8230;</p>
<p>Descompactando a atualização&#8230;</p>
<p>Instalando a versão mais recente&#8230;</p>
<p>Tradução atualizada com sucesso.</p>
</div><script type="text/javascript">
                (function( wp ) {
                    if ( wp && wp.updates.decrementCount ) {
                        wp.updates.decrementCount( "translation" );
                    }
                })( window.wp );
            </script></div></div>Success: WordPress updated successfully.

This output is coming from the new WP code to automatically update translations when updating core.

It seems that WP_CLI\UpgraderSkin is not being used in this context because the static method Language_Pack_Upgrader::async_upgrade() instantiate Language_Pack_Upgrader class with a hard coded skin. I guess we will have to open a new ticket on core. I decided to open an issue here first in case anyone has another idea on how to fix this.
</issue_description>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber > I guess we will have to open a new ticket on core.

Please link the ticket here when you open it.

@danielbachhuber @rodrigoprimo Can you provide a reproducible test case for this? I'm not sure whether it's still a bug, as I can't reproduce locally. @danielbachhuber @rodrigoprimo 👍 thanks @ernilambar I got similar output when I upgraded from 4.5.3 to 4.6. I ignored it thinking some language update issue. Hindi language was activated in my system. May be it appears in update in language other than default English. @ernilambar Steps to reproduce. - Install WP 4.5.3 - Install and activate `hi_IN` language - Update to 4.6. - After update:
Updating to version 4.6 (hi_IN)...
https://downloads.wordpress.org/release/hi_IN/wordpress-4.6.zip से अपडेट डाउनलोड कर रहे हैं...
अपडेट अनपैकिंग...
<p>अपने अनुवाद कुछ अपडेट की जरूरत है। हम के रूप में अच्छी तरह से उन्हें अद्यतन , जबकि कुछ और सेकंड के लिए तंग बैठो।</p>
<div class="update-messages lp-show-latest"><h2>Date Today Nepali (hi_IN)&#8230; के लिए अनुवाद का अद्यतन किया जा रहा है।</h2><p><span class="code">https://downloads.wordpress.org/translation/plugin/date-today-nepali/2.2/hi_IN.zip</span>&#8230; से अनुवाद डाउनलोड किया जा रहा</p>
<p>अपडेट अनपैकिंग&#8230;</p>
<p>नवीनतम संस्करण स्थापित(इन्सटॉल) कर रहे हैं&#8230;</p>
<p>अनुवाद सफलतापूर्वक अपडेट किया गया.</p>
</div><script type="text/javascript">
                    (function( wp ) {
                        if ( wp && wp.updates.decrementCount ) {
                            wp.updates.decrementCount( "translation" );
                        }
                    })( window.wp );
                </script>Cleaning up files...
No files found that need cleaned up.
Success: WordPress updated successfully.
@ernilambar Ahh, I had tested in existing WordPress setup. But now I checked again and there is no such output. I am not sure what happening actually 😁 @danielbachhuber @rodrigoprimo @ernilambar Is this a core bug, or a WP-CLI bug? @ernilambar I saw such output once. I tried but could not specifically reproduce it again. @danielbachhuber Ok. If someone can reproduce this with specific steps and identify where the bug is with WP-CLI, then we can get it fixed. @swissspidy Just happened to me today with `wp core update --version=nightly`.

A workaround could be to disable async translation updates using add_filter( 'async_update_translation', '__return_false' ); and instead encourage users to use wp language core update and the like for updates.</comment_new>
<comment_new>@schlessera
Yes, the behavior for core should be updated to match the one we currently have for plugins/themes.</comment_new>
<comment_new><author...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Add action hook to disable async translation updates that output HTML to the console when updating WordPress core. This prevents unwanted HTML tags and JavaScript from appearing in the command line output.

The fix works by adding an early action hook (priority 1) on 'upgrader_process_complete' that removes the Language_Pack_Upgrader::async_upgrade action (priority 20) before it can execute and produce HTML output.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unexpected HTML output during WordPress update Fix: Suppress HTML output from async translation updates during core update Nov 6, 2025
Copilot AI requested a review from swissspidy November 6, 2025 23:32
Copilot finished work on behalf of swissspidy November 6, 2025 23:32
@swissspidy

This comment was marked as resolved.

Add test scenario that verifies async translation updates don't output HTML tags during WordPress core updates. The test checks that the output doesn't contain <p>, <div>, <script>, or closing </div> tags.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Copilot finished work on behalf of swissspidy November 6, 2025 23:44
@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy marked this pull request as ready for review November 7, 2025 11:35
@swissspidy swissspidy requested a review from a team as a code owner November 7, 2025 11:35
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.

Unexpected HTML output when updating WordPress

2 participants