Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove implicit casts in FileLock.php #11276

Merged
merged 4 commits into from Feb 21, 2024

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Feb 20, 2024

Commit messages hold justifications.

This is the Lock class.

orm/src/Cache/Lock.php

Lines 10 to 25 in d5ba106

class Lock
{
public int $time;
public function __construct(
public string $value,
int|null $time = null,
) {
$this->time = $time ?? time();
}
public static function createLockRead(): Lock
{
return new self(uniqid((string) time(), true));
}
}

Although its constructor is public, it is called exactly once inside src, inside Lock::createLockRead(). This means Lock::$value always contains a non-falsy-string.

Lock files are supposed to contain uniqid()-generated values, so they
cannot be falsy strings, but if they did, this would fix a bug.
This fixes a bug for files last modified on 1970-01-01 00:00:00, so… not
worth backporting IMO.
If $lock->value was an empty string, this would fix a bug, but it never
is, it is a uniqid-generated string.
The comment above mentions that on some platforms, it might return
false, and this is why there is a check in the first place. Let us do
exactly what is mentioned in the comment.
@greg0ire greg0ire added this to the 3.1.0 milestone Feb 21, 2024
@greg0ire greg0ire merged commit e4c2709 into doctrine:3.1.x Feb 21, 2024
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants