Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#31646 closed defect (bug) (fixed)

_get_cron_lock is missing PHPdoc

Reported by: mordauk's profile mordauk Owned by: drewapicture's profile DrewAPicture
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.2
Component: Cron API Keywords: has-patch
Focuses: docs Cc:

Description

The function definition for _get_cron_lock() is missing PHPDoc.

Attachments (4)

31646.patch (408 bytes) - added by mordauk 9 years ago.
31646.1.diff (1.7 KB) - added by valendesigns 9 years ago.
31646.2.diff (399 bytes) - added by valendesigns 9 years ago.
@ignore added to docblock
31646.3.diff (452 bytes) - added by valendesigns 9 years ago.

Download all attachments as: .zip

Change History (19)

@mordauk
9 years ago

#1 @SergeyBiryukov
9 years ago

  • Milestone changed from Awaiting Review to 4.2

#2 @valendesigns
9 years ago

Should we be completely changing the description here? I'm thinking the original text was a bit more descriptive then "Gets the cron lock". Granted the original text is not much better. Maybe something like...

/**
 * Returns the uncached `doing_cron` transient.
 *
 * @since  3.3
 * @return string|false
 */

#3 @DrewAPicture
9 years ago

  • Keywords has-patch added

I think either way, we need a DocBlock, so +1 for adding one.

Since this an underscore-prefixed function, that typically denotes a private or utility function, in which case we'd skip parsing. Unless somebody can make a convincing argument for why this should have a place in the code reference, I'd recommend adding the @ignore tag to the DocBlock.

@valendesigns
9 years ago

#4 follow-up: @valendesigns
9 years ago

I agree, this doesn't need to be included in the code reference. However, something to consider would be removing the function all together. The only place core uses it is in wp-cron.php. It could easily be turned into a variable. Patch 31646.1.diff should demonstrate what I mean. Obviously it's to late for 4.2, but still worth mentioning. The last patch will have to suffice for now.

#5 in reply to: ↑ 4 ; follow-up: @SergeyBiryukov
9 years ago

Replying to valendesigns:

The only place core uses it is in wp-cron.php. It could easily be turned into a variable.

I think it's a function and not a variable in order to make sure we get a fresh value for each check, see [18659].

#6 in reply to: ↑ 5 @valendesigns
9 years ago

Replying to SergeyBiryukov:

I think it's a function and not a variable in order to make sure we get a fresh value for each check, see [18659].

It looks like it was actually in the foreach statement, and then was moved into a function for ease of use. I don't think it becoming a function actually solved the issue of getting a fresh value, just it being moved out of that loop did.

#7 follow-up: @valendesigns
9 years ago

I could be wrong, it's just what I saw from first glance. Unless, it needs a fresh value in the loop every time it asks for the cron lock.

Last edited 9 years ago by valendesigns (previous) (diff)

#8 in reply to: ↑ 7 @SergeyBiryukov
9 years ago

Replying to valendesigns:

I could be wrong, it's just what I saw from first glance. Unless, it needs a fresh value in the loop every time it asks for the cron lock.

Yes, that's my understanding. Some actions may take a long time to run, so we need to check the fresh value on each iteration to see if the lock still belongs to the current process.

#9 follow-up: @SergeyBiryukov
9 years ago

So the refactoring is not needed here, let's just add missing docs.

#10 in reply to: ↑ 9 @valendesigns
9 years ago

Replying to SergeyBiryukov:

So the refactoring is not needed here, let's just add missing docs.

Thanks for the explanation, that makes perfect sense.

@valendesigns
9 years ago

@ignore added to docblock

#11 @SergeyBiryukov
9 years ago

Let's also add a sentence about the uncached doing_cron transient, as you suggested in comment:2.

@valendesigns
9 years ago

#12 @valendesigns
9 years ago

Patch added. Let me know if you want the text changed at all. Cheers!

#13 @mordauk
9 years ago

Looks good to me.

#14 @DrewAPicture
9 years ago

  • Owner set to DrewAPicture
  • Resolution set to fixed
  • Status changed from new to closed

In 31804:

Add a missing DocBlock for the core utility function _get_cron_lock().

Props mordauk, valendesigns.
Fixes #31646.

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


9 years ago

Note: See TracTickets for help on using tickets.