8000 bug #42753 Cast ini_get to an integer to match expected type (natewie… · symfony/symfony@ecf55ab · GitHub
[go: up one dir, main page]

Skip to content

Commit ecf55ab

Browse files
committed
bug #42753 Cast ini_get to an integer to match expected type (natewiebe13)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- Cast ini_get to an integer to match expected type | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | n/a The lifetime value is expected to be an integer, but this is set as a string when using the ini value from `session.cookie_lifetime`. This makes `getLifetime()` return a string instead of an int as the ``@return`` states. Commits ------- c56470d Cast ini_get to an integer to match expected type
2 parents d1eda26 + c56470d commit ecf55ab

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,6 @@ private function stampCreated(int $lifetime = null): void
163163
{
164164
$timeStamp = time();
165165
$this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;
166-
$this->meta[self::LIFETIME] = $lifetime ?? ini_get('session.cookie_lifetime');
166+
$this->meta[self::LIFETIME] = $lifetime ?? (int) ini_get('session.cookie_lifetime');
167167
}
168168
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,14 @@ public function testDoesNotSkipLastUsedUpdate()
136136

137137
$this->assertEquals($timeStamp, $sessionMetadata[MetadataBag::UPDATED]);
138138
}
139+
140+
public function testLifetimeIsInt()
141+
{
142+
$sessionMetadata = [];
143+
144+
$bag = new MetadataBag();
145+
$bag->initialize($sessionMetadata);
146+
147+
$this->assertIsInt($bag->getLifetime());
148+
}
139149
}

0 commit comments

Comments
 (0)
0