Opened 4 weeks ago
Closed 9 days ago
#66300 closed defect (bug) (fixed)
Improve usability and consistency of the network admin email change notices.
| Reported by: | afercia | Owned by: | lancewillett |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Networks and Sites | Version: | |
| Severity: | normal | Keywords: | has-patch has-screenshots has-unit-tests |
| Cc: | Focuses: |
Description
Follow up to #66173.
For consistency with the changes in #66173 for the single site user and administration notices, also the network admin change notices should be improved in terms of clarity of the admin notices and usability.
Basically:
- Add an info notice at the top.
- Change the type of the notice in the middle of the page to 'info'.
- Change the cancel link text to 'Cancel request'.
- Provide the link in both notices.
- After clicking the activation link in the confirmation email, add a success notice
Network admin email updated.. Settings saved.should be bold, for consistency with single site settings.
Attachments (2)
Change History (14)
This ticket was mentioned in PR #14247 on WordPress/wordpress-develop by @afercia.
4 weeks ago
#1
- Keywords has-patch added
#2
@
4 weeks ago
In PR 14247:
- Adds an 'info' admin notice in the Network Settings page when changing the network admin email.
- The notice is similar to the one already rendered on single site.
- The notice at the top is rendered after the 'Settings saved.' one.
- The notice in the middle of the page is now of type 'info'.
- The 'Cancel' link text is now a more meaningful 'Cancel request'.
- The 'Cancel request' link is now rendered in both the admin notices.
- After clicking the activation link in the confirmation email, a success notice
Network admin email updated.is rendered at the top of the page. - Improves the redirect links by using
add_query_arg(). - The standard
Settings saved.notice text is now bold, for consistency with the single site settings.
This ticket was mentioned in PR #14466 on WordPress/wordpress-develop by @therssoftware.
4 weeks ago
#4
- Keywords has-unit-tests added
Follow-up to: https://github.com/WordPress/wordpress-develop/pull/14247
Description
This PR addresses review feedback from @JJJ and @lloc on #14247 and introduces a dedicated unit test suite:
- Fix false-positive "Settings saved." notice on failed confirmation:
When an invalid or expired confirmation link is clicked, the flow redirects to
settings.php?updated=false. Because the check previously evaluatedisset( $_GET['updated'] ), WordPress falsely rendered the green "Settings saved." notice even though no setting was changed. The check now requiresisset( $_GET['updated'] ) && 'true' === $_GET['updated']. - Fix "Cancel request" notice behavior:
Clicking "Cancel request" no longer redirects with
?updated=true. It redirects cleanly tosettings.phpwithout triggering the "Settings saved." notice. - Reuse existing translation context:
Reused
_x( 'Cancel request', 'admin email change' )to align withwp-admin/options-general.phpand avoid adding a duplicate translatable string for polyglots. - Translator comment formatting:
Fixed the translator comment indentation to match the
sprintf()parameter indent level. - Add dedicated PHPUnit tests:
Created
tests/phpunit/tests/multisite/networkAdminEmailChange.phpcovering email change initiation, valid/invalid hash confirmation, option cleanup, notice display conditions, and removable query args.
Testing Instructions
- In a Multisite install, go to Network Admin -> Settings -> Network Settings (
/wp-admin/network/settings.php). - Change the Network Admin Email to a new address and save settings.
- Verify the pending info notice appears with the new email and a "Cancel request" link.
- Visit
/wp-admin/network/settings.php?network_admin_hash=invalidhash:- Verify it redirects to
settings.php?updated=false. - Verify "Settings saved." is NOT displayed.
- Verify it redirects to
- Click "Cancel request":
- Verify the pending notice is dismissed and "Settings saved." is NOT displayed.
- Run PHPUnit and PHPCS:
vendor/bin/phpunit -c tests/phpunit/multisite.xml tests/phpunit/tests/multisite/networkAdminEmailChange.php vendor/bin/phpcs src/wp-admin/network/settings.php tests/phpunit/tests/multisite/networkAdminEmailChange.php
--- == 2. GitHub PR #14247 Comment (Review Response) == }}}markdown I have investigated the review feedback from @JJJ and @lloc and prepared the fixes and dedicated unit tests: 1. **Failed confirmation notice mismatch:** Changed `isset( $_GET['updated'] )` to `isset( $_GET['updated'] ) && 'true' === $_GET['updated'] && ! isset( $_GET['network_admin_email_updated'] )` in `wp-admin/network/settings.php`. When an invalid or expired hash redirects with `updated=false`, the "Settings saved." notice is no longer rendered, matching single-site behavior. 2. **Cancel request redirect:** Changed the dismiss action to redirect to `network_admin_url( 'settings.php' )` without `updated=true` so that cancelling a pending request does not display "Settings saved.". 3. **Reused context:** Updated `_x( 'Cancel request', 'network admin email change' )` to reuse `_x( 'Cancel request', 'admin email change' )` from `options-general.php`. 4. **Indentation:** Fixed the translator comment indentation in `wp-admin/network/settings.php`. 5. **Unit tests:** Added `tests/phpunit/tests/multisite/networkAdminEmailChange.php` with 10 test cases (27 assertions) covering email change initiation, confirmation hash validation, cancellation cleanup, notice display logic, and removable query args. Branch with the patch: `robelsust:fix/66300-network-admin-email-usability`
@therssoftware commented on PR #14247:
4 weeks ago
#5
I have investigated the review feedback from @JJJ and @lloc and prepared the fixes and dedicated unit tests:
- Failed confirmation notice mismatch:
Changed
isset( $_GET['updated'] )toisset( $_GET['updated'] ) && 'true' === $_GET['updated'] && ! isset( $_GET['network_admin_email_updated'] )inwp-admin/network/settings.php. When an invalid or expired hash redirects withupdated=false, the "Settings saved." notice is no longer rendered, matching single-site behavior. - Cancel request redirect:
Changed the dismiss action to redirect to
network_admin_url( 'settings.php' )withoutupdated=trueso that cancelling a pending request does not display "Settings saved.". - Reused context:
Updated
_x( 'Cancel request', 'network admin email change' )to reuse_x( 'Cancel request', 'admin email change' )fromoptions-general.php. - Indentation:
Fixed the translator comment indentation in
wp-admin/network/settings.php. - Unit tests:
Added
tests/phpunit/tests/multisite/networkAdminEmailChange.phpwith 10 test cases (27 assertions) covering email change initiation, confirmation hash validation, cancellation cleanup, notice display logic, and removable query args.
Branch with the patch: robelsust:fix/66300-network-admin-email-usability
#6
@
4 weeks ago
Follow-up to the review on PR 14247:
- Fixed the
updated=falsefalse-positive success notice when an invalid or expired confirmation link is accessed.wp-admin/network/settings.phpnow requiresisset( $_GET['updated'] ) && 'true' === $_GET['updated']before rendering the "Settings saved." notice. - Updated the dismiss/cancel request redirect to point to
settings.phpwithoutupdated=true, preventing the false "Settings saved." notice upon cancelling. - Reused the existing
'admin email change'gettext context for "Cancel request" to maintain consistency with single-site (options-general.php) and avoid adding duplicate strings for polyglots. - Fixed the translator comment indentation in
settings.php. - Added dedicated unit tests in
tests/phpunit/tests/multisite/networkAdminEmailChange.php(10 tests, 27 assertions, all passing).
@therssoftware commented on PR #14466:
11 days ago
#7
Thank you for the review @lancewillett
I have updated the branch with the following changes:
Removed the confirmation, cancellation, and notice predicate tests from networkAdminEmailChange.php that duplicated settings.php logic rather than exercising production code directly.
Retained the 3 email-initiation tests covering update_network_option_new_admin_email() with mock_sent mailer inspection and resets in set_up() and tear_down().
Added dedicated #66300 test coverage for network_admin_email_updated in tests/phpunit/tests/functions/wpRemovableQueryArgs.php.
Cleaned up redundant DB option deletes in tear_down() to rely on test runner transaction management.
@lancewillett commented on PR #14466:
11 days ago
#8
@JJJ, could you take a fresh look at the network-admin notice behavior here, following your review of #14247? The revised patch removes the copied-handler tests and addresses the misleading success-notice paths, but it still changes production confirmation, cancellation, and pending-email notices.
I'm holding this for that review and browser validation of those flows. The remaining PHPUnit tests cover email initiation; they do not establish that the rendered notices are correct. Please also trim the PR description's coverage claims to match the tests now present.
<sub>AI review · <code>gpt-6</code></sub>
@therssoftware commented on PR #14466:
10 days ago
#9
Thanks @lancewillett and @Copilot.
I have updated the PR description to trim the PHPUnit test coverage claims to match the tests present in tests/phpunit/tests/multisite/networkAdminEmailChange.php.
The automated PHPUnit suite specifically covers the programmatic core functions:
- Network admin email change initiation via
update_network_option_new_admin_email()(handling identical emails, invalid formats, hash generation, and email dispatch). - Removable query args via
wp_removable_query_args().
The UI-level confirmation (?network_admin_hash=...), cancellation link (?dismiss=new_network_admin_email), and notice rendering in wp-admin/network/settings.php are legacy procedural screen flows that redirect/exit, which are verified through the manual browser testing steps detailed above.
@lancewillett commented on PR #14466:
10 days ago
#10
Browser verification passed on e843250bbc85ab3f8e6a58cd6c14cfe6c1fa3a69 in an isolated PHP 8.3 multisite install: both pending notices and cancellation links, invalid/stale confirmations, successful email confirmation, and an ordinary settings save behaved as expected. Confirmation emails were captured locally.
This checks the current patch, not a before/after comparison. The requested independent review remains pending before landing.
<sub>AI review · <code>gpt-6</code></sub>
@therssoftware commented on PR #14466:
9 days ago
#11
Hi @JJJ,
Good catch! I've removed the duplicate assertion from networkAdminEmailChange.php so the dedicated test in wpRemovableQueryArgs.php covers network_admin_email_updated exclusively. All tests and PHPCS checks pass cleanly.
Thank you so much for the thorough review and testing!
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Use of AI Tools
NONE