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

refactor: cleanup DatabaseHandler::gc() for session #9230

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions system/Session/Handlers/DatabaseHandler.php
Original file line number Diff line number Diff line change
@@ -282,12 +282,9 @@ public function destroy($id): bool
#[ReturnTypeWillChange]
public function gc($max_lifetime)
{
$separator = ' ';
$interval = implode($separator, ['', "{$max_lifetime} second", '']);

return $this->db->table($this->table)->where(
'timestamp <',
"now() - INTERVAL {$interval}",
"now() - INTERVAL {$max_lifetime} second ",
michalsn marked this conversation as resolved.
Show resolved Hide resolved
false
)->delete() ? 1 : $this->fail();
}

Unchanged files with check annotations Beta

};
}
public function testNoFormatterJSON(): void

Check warning on line 137 in tests/system/API/ResponseTraitTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 1.0059s from 0.5000s limit to run CodeIgniter\\API\\ResponseTraitTest::testNoFormatterJSON
{
$this->formatter = null;
$controller = $this->makeController(
$this->assertSame(200, $this->handler->getHeight());
}
public function testImageCreation(): void

Check warning on line 356 in tests/system/Images/ImageMagickHandlerTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.7783s from 0.5000s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageCreation
{
foreach (['gif', 'jpeg', 'png', 'webp'] as $type) {
if ($type === 'webp' && ! in_array('WEBP', Imagick::queryFormats(), true)) {
$this->assertSame(exif_imagetype($this->root . 'ci-logo.png'), IMAGETYPE_PNG);
}
public function testImageReorientLandscape(): void

Check warning on line 453 in tests/system/Images/ImageMagickHandlerTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.6002s from 0.5000s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageReorientLandscape
{
for ($i = 0; $i <= 8; $i++) {
$source = $this->origin . 'EXIFsamples/landscape_' . $i . '.jpg';
}
}
public function testImageReorientPortrait(): void

Check warning on line 472 in tests/system/Images/ImageMagickHandlerTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.5479s from 0.5000s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageReorientPortrait
{
for ($i = 0; $i <= 8; $i++) {
$source = $this->origin . 'EXIFsamples/portrait_' . $i . '.jpg';
unset($_ENV['encryption.key'], $_SERVER['encryption.key']);
}
public function testGenerateKeyShowsEncodedKey(): void

Check warning on line 77 in tests/system/Commands/GenerateKeyTest.php

GitHub Actions / SeparateProcess (8.2) / tests

Took 1.0246s from 0.5000s limit to run CodeIgniter\\Commands\\GenerateKeyTest::testGenerateKeyShowsEncodedKey
{
command('key:generate --show');
$this->assertStringContainsString('hex2bin:', $this->getBuffer());
return $this->getStreamFilterBuffer();
}
public function testCreateDatabase(): void

Check warning on line 72 in tests/system/Commands/CreateDatabaseTest.php

GitHub Actions / DatabaseLive (8.2, MySQLi, 8.0) / tests

Took 1.2300s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase

Check warning on line 72 in tests/system/Commands/CreateDatabaseTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 1.1955s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase

Check warning on line 72 in tests/system/Commands/CreateDatabaseTest.php

GitHub Actions / DatabaseLive (8.2, Postgre, 8.0) / tests

Took 1.3248s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase

Check warning on line 72 in tests/system/Commands/CreateDatabaseTest.php

GitHub Actions / DatabaseLive (8.2, SQLite3, 8.0) / tests

Took 1.2063s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase

Check warning on line 72 in tests/system/Commands/CreateDatabaseTest.php

GitHub Actions / DatabaseLive (8.2, SQLSRV, 8.0) / tests

Took 1.3644s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase
{
if ($this->connection instanceof OCI8Connection) {
$this->markTestSkipped('Needs to run on non-OCI8 drivers.');
$this->assertNull($this->handler->getMetaData(self::$dummy));
}
public function testGetMetaData(): void

Check warning on line 35 in tests/system/Cache/Handlers/AbstractHandlerTestCase.php

GitHub Actions / CacheLive (8.2) / Cache Live Tests

Took 1.0049s from 0.5000s limit to run CodeIgniter\\Cache\\Handlers\\MemcachedHandlerTest::testGetMetaData
{
$time = Time::now()->getTimestamp();
$this->handler->save(self::$key1, 'value');
$this->forge->dropTable('', true);
}
public function testForeignKey(): void

Check warning on line 491 in tests/system/Database/Live/ForgeTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 2.8588s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ForgeTest::testForeignKey
{
$this->forge->dropTable('forge_test_invoices', true);
$this->forge->dropTable('forge_test_users', true);
$this->forge->dropTable('forge_test_1', true);
}
public function testSetKeyNames(): void

Check warning on line 1233 in tests/system/Database/Live/ForgeTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 1.0485s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ForgeTest::testSetKeyNames
{
$this->forge->dropTable('forge_test_1', true);
$this->forge->dropTable('forge_test_four', true);
}
public function testDropKey(): void

Check warning on line 1581 in tests/system/Database/Live/ForgeTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 0.8475s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ForgeTest::testDropKey
{
$this->forge->dropTable('key_test_users', true);
$keyName = 'key_test_users_id';
$this->forge->dropTable('forge_test_users', true);
}
public function testProcessIndexes(): void

Check warning on line 1668 in tests/system/Database/Live/ForgeTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 1.4206s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ForgeTest::testProcessIndexes
{
// make sure tables don't exist
$this->forge->dropTable('actions', true);
CLI::init();
}
public function testMigrateAllWithWithTwoNamespaces(): void

Check warning on line 77 in tests/system/Commands/Database/MigrateStatusTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 1.2348s from 0.5000s limit to run CodeIgniter\\Commands\\Database\\MigrateStatusTest::testMigrateAllWithWithTwoNamespaces

Check warning on line 77 in tests/system/Commands/Database/MigrateStatusTest.php

GitHub Actions / DatabaseLive (8.2, Postgre, 8.0) / tests

Took 0.5007s from 0.5000s limit to run CodeIgniter\\Commands\\Database\\MigrateStatusTest::testMigrateAllWithWithTwoNamespaces

Check warning on line 77 in tests/system/Commands/Database/MigrateStatusTest.php

GitHub Actions / DatabaseLive (8.2, SQLSRV, 8.0) / tests

Took 0.6464s from 0.5000s limit to run CodeIgniter\\Commands\\Database\\MigrateStatusTest::testMigrateAllWithWithTwoNamespaces
{
command('migrate --all');
$this->resetStreamFilterBuffer();
$this->assertSame('MySQLi', $this->getPrivateProperty($db1, 'DBDriver'));
}
public function testConnectWithFailover(): void

Check warning on line 97 in tests/system/Database/Live/ConnectTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 1.0973s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ConnectTest::testConnectWithFailover
{
$this->tests['failover'][] = $this->tests;
unset($this->tests['failover'][0]['failover']);
$this->assertStringContainsString('upsertone@test.com', $sql);
}
public function testUpsertBatchWithQuery(): void

Check warning on line 714 in tests/system/Database/Live/UpsertTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 0.9621s from 0.5000s limit to run CodeIgniter\\Database\\Live\\UpsertTest::testUpsertBatchWithQuery
{
$this->forge = Database::forge($this->DBGroup);
$this->seeInDatabase('job', ['name' => 'Grocery Sales']);
}
public function testInsertBatch(): void

Check warning on line 52 in tests/system/Database/Live/InsertTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 0.8592s from 0.5000s limit to run CodeIgniter\\Database\\Live\\InsertTest::testInsertBatch
{
$table = 'type_test';
#[Group('DatabaseLive')]
final class WhenWhenNotModelTest extends LiveModelTestCase
{
public function testWhenWithTrueCondition(): void

Check warning on line 25 in tests/system/Models/WhenWhenNotModelTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 0.8465s from 0.5000s limit to run CodeIgniter\\Models\\WhenWhenNotModelTest::testWhenWithTrueCondition
{
$secondaryData = [
[