Skip to content

Conversation

@shishir-21
Copy link

This PR adds a guard condition to prevent PHP notices when accessing an undefined weekday index. The change is minimal and does not affect existing behavior.

@github-actions
Copy link

Hi @shishir-21! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

@github-actions
Copy link

github-actions bot commented Jan 12, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props shishir1, westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@shishir-21
Copy link
Author

I’ve rebased the branch onto the latest trunk.

The failing PHPUnit tests appear to be unrelated to this change and are failing across multiple environments (PHP 7.4 / MariaDB), including tests that do not touch WP_Locale.

Please let me know if you’d like me to address anything specific, or if these are known CI issues.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a unit test failure: https://github.com/WordPress/wordpress-develop/actions/runs/20962698456/job/60244115884?pr=10722#step:15:928

You can see it is specifically testing for the error case:

/**
* @covers WP_Locale::get_weekday
*/
public function test_get_weekday_undefined_index() {
if ( PHP_VERSION_ID >= 80000 ) {
$this->expectWarning();
} else {
$this->expectNotice();
}
$this->locale->get_weekday( 7 );
}

This was introduced way back in b8b68a6 to fix Core-34688.

👉🏻 If this is to be changed, then a Trac ticket should be opened first to discuss.

It would be better likely to have _doing_it_wrong() be used instead of silently returning an empty string, for example.

@shishir-21
Copy link
Author

Thanks for the clarification and for pointing out the existing test coverage and history.

I understand now that the current behavior is intentional and that changing it would require prior discussion.

I will open a Trac ticket to discuss the expected behavior for invalid weekday values (e.g. using _doing_it_wrong()), and will follow up with a new PR if there’s consensus.

Thanks again for the guidance.

@shishir-21 shishir-21 closed this Jan 16, 2026
@shishir-21 shishir-21 deleted the fix-first-issue branch January 16, 2026 14:59
@shishir-21
Copy link
Author

Following up with Trac ticket: https://core.trac.wordpress.org/ticket/64522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants