#56293 closed defect (bug) (fixed)
Use 'MINUTE_IN_SECONDS' for consistency in 'update.php' file
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.1 | Priority: | low |
| Severity: | normal | Version: | |
| Component: | Administration | Keywords: | has-patch dev-feedback |
| Focuses: | coding-standards | Cc: |
Description (last modified by )
In the 'wp-includes/update.php' file there are multiple instances where variable $timeout set to plain integer 30 like:
$timeout = 30;
I think It should be like this (MINUTE_IN_SECONDS also used multiple time in this file) as done here in this commit [53714]:
$timeout = MINUTE_IN_SECONDS / 2;
Attachments (2)
Change History (45)
#1
in reply to:
โย description
@
3 years ago
#3
@
3 years ago
- Milestone changed from Awaiting Review to 6.1
- Owner set to audrasjb
- Status changed from new to reviewing
Good point!
Moving for 6.1 consideration.
This ticket was mentioned in โPR #3029 on โWordPress/wordpress-develop by โaudrasjb.
3 years ago
#4
- Keywords has-patch added; needs-patch removed
#6
@
3 years ago
The 56293.diff patch seems unnecessarily complex. Just because we want to say 2 hours or 5 hours, doesn't mean we need to derive the 2 or the 5 from some division of the MINUTE_IN_SECONDS constant.
#7
follow-up:
โย 9
@
3 years ago
hey @krupalpanchal ,
I checked your 56293.diffโ and looks to me your changes aren't what I suggested.
To me,
2 * HOUR_IN_SECONDS makes more sense than ( MINUTE_IN_SECONDS / 30 ) * HOUR_IN_SECONDS
same goes for the other line's change.
Because, When I see 2 * HOUR_IN_SECONDS it clearly makes me understand that it's twice an hour in seconds but when there's something like ( MINUTE_IN_SECONDS / 30 ) * HOUR_IN_SECONDS it makes it more hard to read.
My point was these constants like (MINUTE_IN_SECONDS, HOUR_IN_SECONDS) can make the timing numbers more readable for a non programmer. But, I don't see how your changes make it more readable.
#9
in reply to:
โย 7
@
3 years ago
The 56293.diff patch seems unnecessarily complex. Just because we want to say 2 hours or 5 hours, doesn't mean we need to derive the 2 or the 5 from some division of the MINUTE_IN_SECONDS constant.
2 * HOUR_IN_SECONDSmakes more sense than( MINUTE_IN_SECONDS / 30 ) * HOUR_IN_SECONDS
same goes for the other line's change.
Agreed.
#10
@
3 years ago
@arrasel403 thanks for your patch but @audrasjb doing some extra care about this issue so I think the PR has a better solution than the patch. But you ( @arrasel403 ) are most welcome as a new contributor.
#11
@
3 years ago
- Description modified (diff)
- Keywords changes-requested added
Thanks everyone!
// Three seconds, plus one extra second for every 10 themes. $timeout = MINUTE_IN_SECONDS / 20 + (int) ( count( $themes ) / 10 )
I think MINUTE_IN_SECONDS / 20 is also too complicated :) Keeping that as is, especially with the "Three seconds" comment above, seems more readable to me:
// Three seconds, plus one extra second for every 10 themes. $timeout = 3 + (int) ( count( $themes ) / 10 );
Same goes for this:
'timeout' => $doing_cron ? MINUTE_IN_SECONDS / 2 : MINUTE_IN_SECONDS / 20,
This might be more readable:
// Half a minute when doing cron tasks, 3 seconds otherwise. 'timeout' => $doing_cron ? MINUTE_IN_SECONDS / 2 : 3,
#12
@
3 years ago
Thanks @SergeyBiryukov ,
I'm not sure if it's a coincident but I was just about to make the same comment in the PR. Agreed about MINUTE_IN_SECONDS / 20 being complicated.
#13
@
3 years ago
Thank you @SergeyBiryukov, it would be better if you suggest this change request in the PR.
โhz-tyfoon commented on โPR #3029:
3 years ago
#14
Hey @audrasjb,
I can see U've used MINUTE_IN_SECONDS / 20 in line number 190, 411 & 692.
In my humble opinion, looks to me using MINUTE_IN_SECONDS / 20 also makes it more complicated & less readable.
@SergeyBiryukov also suggesting the same.
So, I think may be those 3 changes may not be necessary.
โhz-tyfoon commented on โPR #3029:
3 years ago
#16
thanks @peterwilsoncc for reviewing.
0.5 * MINUTE_IN_SECONDSis possibly ok
This one also sounds solid, readable & performance firendly to me.
The reviews of this PR didn't show up in the trac.
Hopefully, this comment is going to show up in the trac ticket.
๐
#17
follow-up:
โย 18
@
3 years ago
- Keywords dev-feedback added; changes-requested removed
- Priority changed from normal to low
PR updated as per @SergeyBiryukov 's proposal.
@peterwilsoncc suggested to replace MINUTE_IN_SECONDS / 2 with 0.5 * MINUTE_IN_SECONDS.
I personally find the former more readable than the latter.
That's not super important, but let's collect some feedback from other committers before shipping this tiny enhancement ;)
โฌ๏ธ Sorry, I linked wrong ticket there. I meant this commit: [53714]