Make WordPress Core

Opened 4 months ago

Last modified 2 months ago

#59027 new defect (bug)

Weekly wp_get_archives has invalid link (link for month instead of year)

Reported by: filipac's profile filipac Owned by:
Milestone: 6.5 Priority: normal
Severity: normal Version: 0.71
Component: Posts, Post Types Keywords: has-patch needs-unit-tests 2nd-opinion early
Focuses: Cc:

Description

If you call wp_get_archives function with type set to weekly, the resulted link contains two parameters: m => year, w => week.

This results in unwanted behaviour, as you get a month like 2023 which is invalid.

The link should contain ?y={year}&w={week}.

Attachments (1)

fix_wp_get_archives_weekly.diff (488 bytes) - added by filipac 4 months ago.

Download all attachments as: .zip

Change History (11)

This ticket was mentioned in PR #4979 on WordPress/wordpress-develop by @filipac.


4 months ago
#1

If you call wp_get_archives function with type set to weekly, the resulted link contains two parameters: m => year, w => week.
This results in unwanted behaviour, as you get a month like 2023 which is invalid.
The link should contain ?y={year}&w={week}.

Trac ticket: https://core.trac.wordpress.org/ticket/59027

This ticket was mentioned in Slack in #core by nekojonez. View the logs.


4 months ago

#3 @swissspidy
4 months ago

  • Milestone changed from Awaiting Review to 6.4
  • Version changed from trunk to 4.6

#4 @SergeyBiryukov
4 months ago

  • Version changed from 4.6 to 0.71

Thanks for the ticket! Some history here:

  • [24] introduced the ?m=$arc_year line along with the get_archives() function itself.
  • [273] adjusted the formatting to use sprintf().
  • [3878] moved the logic to wp_get_archives() and deprecated get_archives().
  • [37530] replaced sprintf() with add_query_arg().

#5 @filipac
4 months ago

@SergeyBiryukov huh, 20 years and no other user noticed? so strange :D

#6 @NekoJonez
4 months ago

That is a really old bug indeed.
Since this isnt a regression introduced in 6.3, this will be for 6.4.

But well spotted. And yeah, sometimes small issues fly under the radar and especially when code is being enhanced, sometimes we don't check if the actual code we are enhancing contains a bug.
Besides, I think its a small thing thats quick to glance over.

Anyhow, it will be fixed in 6.4 :D
(Is this a record for longest standing bug ever in WP?)

This ticket was mentioned in Slack in #core by nicolefurlan. View the logs.


2 months ago

#8 @hellofromTonya
2 months ago

  • Keywords needs-unit-tests 2nd-opinion added

This ticket was discussed during today's 6.4 post-beta 1 scrub.

@costdev brought up a potential BC (backward-compatible) break of changing m to y. This is a valid concern when considering how to move this bugfix forward.

As @joemcgill pointed out:

Definitely needs some deep research and added unit tests, if possible to ensure this doesn't break again in the future.

If there is truly a BC concern, this one might benefit from being in the early early alpha phases of a major release.

I'm marking this one with 2nd-opinion to denote it needs

  • Thorough historical review.
  • Consideration of how to deal with a BC break.
  • If this one should be moved into early alpha phase.

This ticket was mentioned in Slack in #core by oglekler. View the logs.


2 months ago

#10 @oglekler
2 months ago

  • Keywords early added
  • Milestone changed from 6.4 to 6.5

This ticket was discussed during bug scrub.

Due to possible side effects that it may have, it should be an early ticket and I am rescheduling it to the next milestone.

Add props: @mukesh27

Note: See TracTickets for help on using tickets.