WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 3 months ago

#48393 accepted defect (bug)

Fix from #38903 prevents options autoload parameter update

Reported by: aboltro Owned by: SergeyBiryukov
Milestone: 5.8 Priority: normal
Severity: major Version:
Component: Options, Meta APIs Keywords: 2nd-opinion needs-patch
Focuses: administration Cc:

Description

This is a follow-up to #38903.

3 years ago fix for not * If the new and old values are the same, no need to update. * But this condition does not check if method call intention was to update autoload field of the option.

Currently the issue can be resolved by force update options when update_option method is called with autoload != null and check * If the new and old values are the same, no need to update. * should be skipped.

Change History (4)

#1 @desrosj
19 months ago

  • Keywords close 2nd-opinion added

Thanks for this ticket, @aboltro. And welcome to Trac!

This looks to be an intentional decision. #26394, and more specifically 26394#comment:13/[31640] shed more light. This behavior is also explicitly documented in the inline documentation.

I am going to recommend this be closed as a wontfix. But also marking for a second opinion.

Last edited 3 months ago by SergeyBiryukov (previous) (diff)

#2 follow-up: @herregroen
3 months ago

I'd disagree with the wontfix.

While it's there in the documentation it's most definitely counter-intuitive and, perhaps more importantly, there's no alternate direct function to change an options' autoload property.

This currently means that in order to change the autoload property of an option developers are forced to resort to direct $wpdb calls which shouldn't be necessary for something so simple.

I think changing update_option so that autoload is updated even if the value is unchanged would be by far the most intuitive and elegant way of doing things. Of course if neither the value nor the autoload property have been changed then nothing should happen.

#3 @joostdevalk
3 months ago

We just ran into this because @herregroen was fixing some of my code in which I was (wrongly) assuming that update_option would work to change an option's autoload value... So I disagree with the wontfix and would suggest making it so this is doable.

#4 in reply to: ↑ 2 @SergeyBiryukov
3 months ago

  • Keywords needs-patch added; close removed
  • Milestone changed from Awaiting Review to 5.8
  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

Replying to herregroen:

I think changing update_option so that autoload is updated even if the value is unchanged would be by far the most intuitive and elegant way of doing things. Of course if neither the value nor the autoload property have been changed then nothing should happen.

I tend to agree.

Note: See TracTickets for help on using tickets.