Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.

Commit ad0cbe6

Browse files
committed
DBA inifile is not supported for caching
We recently noticed failures occuring for the DbaInifile cache storage tests. The errors reported indicated an inability to perform `dba_replace()` operations, with no indication of why this was. On digging through the various DBA documentation on php.net, I discovered that the `dba_replace` and `dba_insert()` functions are only reliable on GDBM and QDBM handlers; any other handler may result in unexpected or unintended behavior. I have tested against flatfile, GDBM, DB4, and GDBM, and none of these show any issues; however, inifile reliably has issues at this point. As such, we can no longer support that version. This patch raises an exception if the inifile handler is provided as a DBA option, and the tests have been modified to ensure that the exception is raised.
1 parent 70d098c commit ad0cbe6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

library/Zend/Cache/Storage/Adapter/DbaOptions.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ public function setHandler($handler)
117117
throw new Exception\ExtensionNotLoadedException("DBA-Handler '{$handler}' not supported");
118118
}
119119

120+
if ($handler === 'inifile') {
121+
throw new Exception\ExtensionNotLoadedException(
122+
"DBA-Handler 'inifile' does not reliably support write operations"
123+
);
124+
}
125+
120126
$this->triggerOptionEvent('handler', $handler);
121127
$this->handler = $handler;
122128
return $this;

tests/ZendTest/Cache/Storage/Adapter/DbaInifileTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@
99

1010
namespace ZendTest\Cache\Storage\Adapter;
1111

12+
use PHPUnit_Framework_TestCase as TestCase;
13+
use Zend\Cache\Storage\Adapter\Dba;
1214

1315
/**
1416
* @group Zend_Cache
1517
*/
16-
class DbaInifileTest extends AbstractDbaTest
18+
class DbaInifileTest extends TestCase
1719
{
18-
protected $handler = 'inifile';
20+
public function testSpecifyingInifileHandlerRaisesException()
21+
{
22+
$this->setExpectedException('Zend\Cache\Exception\ExtensionNotLoadedException', 'inifile');
23+
$cache = new Dba(array(
24+
'pathname' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('zfcache_dba_') . '.inifile',
25+
'handler' => 'inifile',
26+
));
27+
}
1928
}

0 commit comments

Comments
 (0)