File tree Expand file tree Collapse file tree 4 files changed +50
-5
lines changed Expand file tree Collapse file tree 4 files changed +50
-5
lines changed Original file line number Diff line number Diff line change @@ -116,17 +116,17 @@ public function clean(array $conditions)
116116 return [];
117117 }
118118
119- $ stmt = $ this ->pdo ->prepare (implode (' UNION ' , $ unions ));
119+ $ unionSql = implode (' UNION ' , $ unions );
120+ $ stmt = $ this ->pdo ->prepare ($ unionSql );
120121 $ stmt ->execute ($ args );
121122 $ keys = $ stmt ->fetchAll (\PDO ::FETCH_COLUMN , 0 );
122123 if (empty ($ keys )) {
123124 return [];
124125 }
125126
126- $ in = '(? ' . str_repeat (', ? ' , count ($ keys ) - 1 ) . ') ' ;
127127 $ this ->pdo ->exec ('BEGIN ' );
128- $ this ->pdo ->prepare ("DELETE FROM tags WHERE key IN $ in " )->execute ($ keys );
129- $ this ->pdo ->prepare ("DELETE FROM priorities WHERE key IN $ in " )->execute ($ keys );
128+ $ this ->pdo ->prepare ("DELETE FROM tags WHERE key IN ( $ unionSql ) " )->execute ($ args );
129+ $ this ->pdo ->prepare ("DELETE FROM priorities WHERE key IN ( $ unionSql ) " )->execute ($ args );
130130 $ this ->pdo ->exec ('COMMIT ' );
131131
132132 return $ keys ;
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ class SQLiteJournalTest extends IJournalTestCase
2121
2222 public function createJournal ()
2323 {
24- return new SQLiteJournal ;
24+ static $ id = 0 ;
25+ return new SQLiteJournal (TEMP_DIR . '/sqlitejournal_ ' . ++$ id . '.sqlite ' );
2526 }
2627
2728}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * Test: Nette\Caching\Storages\SQLiteStorage tags dependency test.
5+ */
6+
7+ use Nette \Caching \Cache ;
8+ use Nette \Caching \Storages \SQLiteJournal ;
9+ use Tester \Assert ;
10+
11+
12+ require __DIR__ . '/../../bootstrap.php ' ;
13+
14+
15+ if (!extension_loaded ('pdo_sqlite ' )) {
16+ Tester \Environment::skip ('Requires PHP extension pdo_sqlite. ' );
17+ }
18+
19+
20+ $ journal = new SQLiteJournal ;
21+
22+ // Writing cache...
23+ $ keys = [];
24+ for ($ i = 0 ; $ i < 2000 ; $ i ++) {
25+ $ keys [] = 'key ' . $ i ;
26+ }
27+
28+ foreach ($ keys as $ key ) {
29+ $ journal ->write ($ key , [
30+ Cache::TAGS => ['one ' , 'two ' ],
31+ ]);
32+ }
33+
34+ $ journal ->write ('keyThree ' , [
35+ Cache::TAGS => ['three ' ],
36+ ]);
37+
38+ // Cleaning by tags...
39+ $ keys = $ journal ->clean ([
40+ Cache::TAGS => ['one ' , 'xx ' ],
41+ ]);
42+
43+ Assert::same ($ keys , $ keys );
Original file line number Diff line number Diff line change 11[PHP]
22extension_dir = " ./ext"
33extension =php_mbstring.dll
4+ extension =php_pdo_sqlite.dll
45; extension=php_memcache.dll
56
67[Zend]
You can’t perform that action at this time.
0 commit comments