Page MenuHomePhabricator

Consolidate logic for parsing expiries
Open, Needs TriagePublic

Description

As a watchlist user, I want the logic for parsing expiries to be consolidated, so that the tool can run with efficiency and reliability in the back-end.

Background: We have basically the same logic for parsing "expiry" user inputs in WatchedItemStore::updateOrDeleteExpiries(), SpecialBlock::parseExpiryInput(), SpecialUserrights::expiryToTimestamp(), ProtectionForm::getExpiry(), ApiProtect::execute(), FlaggedRevs PageStabilityForm::getExpiry(), and possibly other extensions as well. With minor variations, that code is generally[1]

if ( wfIsInfinity( $expiry ) ) {
    return 'infinity';
}

$unix = strtotime( $expiry );
return $unix === false ? false : wfTimestamp( TS_MW, $unix );

We should probably consolidate that logic into one place, possibly with additional error checking to avoid accepting past expiries and such. Also, for the benefit of APIs[2] we might also add 'expiry' as a type to ParamValidator.

[1]: Well, most of them still have checks for PHP 5.0 returning -1 instead of false on invalid input. I left that out here.
[2]: In the Action API in core, we could use it in ApiBlock, ApiProtect, and ApiUserrights, and ApiWatch.

Acceptance Criteria:

  • Consolidate logic for parsing expiries

Event Timeline

Anomie created this task.Mar 20 2020, 7:13 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Anomie moved this task from Inbox to Feature Requests to Review on the Platform Engineering board.
DannyS712 updated the task description. (Show Details)Mar 24 2020, 6:38 PM
ifried updated the task description. (Show Details)Mar 26 2020, 4:35 PM