Skip to content

Add native return type to ListLookup::getTimestamp() #6584

Description

@alistair3149

Problem

ListLookup::getTimestamp() has no native return type. The interface phpdoc says @return int, but the actual implementations disagree:

  • 4 SQL implementations (PropertyUsageListLookup, UndeclaredPropertyListLookup, UnusedPropertyListLookup, UsageStatisticsListLookup) return wfTimestamp(TS_UNIX) which is string|false
  • CachedListLookup stores the result in a private int $timestamp property, so PHP silently casts the string to int on assignment, and returns int

The implementations' own phpdoc says @return string|false or @return false|string, contradicting the interface's @return int.

Callers

All callers pass the return value to Language::userTimeAndDate() or Language::timeanddate(), which internally call wfTimestamp() and accept any timestamp format — so both string and int work fine in practice.

Options

  1. int — Cast in each SQL implementation with (int)wfTimestamp(TS_UNIX). Matches what callers receive through CachedListLookup. Natural type for Unix timestamps.
  2. string|false — Match what wfTimestamp returns. Change CachedListLookup::$timestamp to string|false. But false can never actually occur (current-time timestamp never fails).

Context

The other three ListLookup methods (fetchList(): array, isFromCache(): bool, getHash(): string) were typed in #6583.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions