Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Cache] Fix incorrect timestamps generated by FilesystemAdapter #19435

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

Merged
merged 1 commit into from
Jul 27, 2016

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 3.1
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #19431
License MIT
Doc PR -

@@ -126,7 +126,7 @@ protected function doDelete(array $ids)
protected function doSave(array $values, $lifetime)
{
$ok = true;
$expiresAt = $lifetime ? time() + $lifetime : PHP_INT_MAX;
$expiresAt = time() + ($lifetime ?: 31557600); // 31557600s = 1 year
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about defining a constant instead of adding the comment? Something like self::YEAR would be self explanatory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep the number. To be completely self-explanatory, the constant should be named self::ONE_YEAR_IN_SECONDS or something like that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a constant creates a public interface change. Even if we can tag it as internal, it looks overkill and the comment looks good enough to me. Also, whenever we want to change this default duration, we won't have to create a new const.

@dunglas
Copy link
Member

dunglas commented Jul 27, 2016

Status: reviewed

👍

@javiereguiluz
Copy link
Member

👍

@nicolas-grekas nicolas-grekas merged commit bd2e795 into symfony:3.1 Jul 27, 2016
nicolas-grekas added a commit that referenced this pull request Jul 27, 2016
…apter (nicolas-grekas)

This PR was merged into the 3.1 branch.

Discussion
----------

[Cache] Fix incorrect timestamps generated by FilesystemAdapter

| Q             | A
| ------------- | ---
| Branch?       | 3.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19431
| License       | MIT
| Doc PR        | -

Commits
-------

bd2e795 [Cache] Fix incorrect timestamps generated by FilesystemAdapter
@nicolas-grekas nicolas-grekas deleted the fix-19431-cache branch July 27, 2016 14:06
@fabpot fabpot mentioned this pull request Jul 30, 2016
@patrick-mcdougle
Copy link
Contributor

patrick-mcdougle commented Jul 31, 2016

This seems to be a issue in linux not in this component. In my opinion, this should be reverted, as PHP_INT_MAX is effectively cache forever whereas the new code defaults to one year.

vagrant@RMBP-015-vagrant:/tmp/foo$ php -a
Interactive mode enabled

php > touch('/tmp/foo/foo-test', pow(2, 55));
php > touch('/tmp/foo/foo-test2', pow(2, 56));
php > exit
vagrant@RMBP-015-vagrant:/tmp/foo$ ls -la
total 8
drwxrwxr-x 2 vagrant vagrant 4096 Jul 31 19:44 ./
drwxrwxrwt 6 root    root    4096 Jul 31 19:43 ../
-rw-rw-r-- 1 vagrant vagrant    0 Jun 13  1141709097 foo-test
-rw-rw-r-- 1 vagrant vagrant    0 72057594037927936 foo-test2

If I had to make any guesses, I'll bet this happens when the year's representation can no longer fit into a 32 bit integer.

EDIT: according to the article on the 2038 problem. I was close. It's 2^32 + 1900.

Most operating systems designed to run on 64-bit hardware already use signed 64-bit time_t integers. Using a signed 64-bit value introduces a new wraparound date that is over twenty times greater than the estimated age of the universe: approximately 292 billion years from now, at 15:30:08 on Sunday, 4 December 292,277,026,596. The ability to make computations on dates is limited by the fact that tm_year uses a signed 32 bit int value starting at 1900 for the year. This limits the year to a maximum of 2,147,485,547 (2,147,483,647 + 1900).

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.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.