Skip to content

Commit

Permalink
[jan] Fix retrieving files from root folder with SQL backends (Bug #1…
Browse files Browse the repository at this point in the history
…4545).
  • Loading branch information
yunosh committed Jan 13, 2017
1 parent d0ab6b4 commit cc9d6db
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 6 deletions.
13 changes: 9 additions & 4 deletions framework/Vfs/lib/Horde/Vfs/Sql.php
Expand Up @@ -692,18 +692,23 @@ protected function _readBlob($table, $field, $criteria)
}

$where = '';
$values = array();
foreach ($criteria as $key => $value) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $key . ' = ' . $this->_db->quote($value);
list($op, $val) = $this->_nullString($value);
$where .= $key . ' ' . $op;
$values = array_merge($values, $val);
}

$sql = sprintf('SELECT %s FROM %s WHERE %s',
$field, $table, $where);
$sql = sprintf(
'SELECT %s FROM %s WHERE %s',
$field, $table, $where
);

try {
$result = $this->_db->selectValue($sql);
$result = $this->_db->selectValue($sql, $values);
$columns = $this->_db->columns($table);
} catch (Horde_Db_Exception $e) {
throw new Horde_Vfs_Exception($e);
Expand Down
4 changes: 2 additions & 2 deletions framework/Vfs/package.xml
Expand Up @@ -38,7 +38,7 @@ Reading, writing and listing of files are all supported.</description>
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [jan] Fix retrieving files from root folder with SQL backends (Bug #14545).
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -1309,7 +1309,7 @@ Added a class for providing garbage collection; removed all Horde dependancies.
<date>2016-12-03</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [jan] Fix retrieving files from root folder with SQL backends (Bug #14545).
</notes>
</release>
</changelog>
Expand Down
5 changes: 5 additions & 0 deletions framework/Vfs/test/Horde/Vfs/FileTest.php
Expand Up @@ -189,6 +189,11 @@ public function testChmod()
$this->_chmod();
}

public function testNullRoot()
{
$this->_nullRoot();
}

public function testDeleteUnusalFileNames()
{
$file = '高&执&行&力&的&打&造.txt';
Expand Down
5 changes: 5 additions & 0 deletions framework/Vfs/test/Horde/Vfs/FtpTest.php
Expand Up @@ -165,6 +165,11 @@ public function testChmod()
$this->_chmod();
}

public function testNullRoot()
{
$this->_nullRoot();
}

public static function setUpBeforeClass()
{
if (!extension_loaded('ftp')) {
Expand Down
5 changes: 5 additions & 0 deletions framework/Vfs/test/Horde/Vfs/MongoTest.php
Expand Up @@ -181,6 +181,11 @@ public function testListFolder()
$this->_listFolder();
}

public function testNullRoot()
{
$this->_nullRoot();
}

public static function setUpBeforeClass()
{
if (($config = self::getConfig('VFS_MONGO_TEST_CONFIG', __DIR__)) &&
Expand Down
5 changes: 5 additions & 0 deletions framework/Vfs/test/Horde/Vfs/SmbTest.php
Expand Up @@ -202,6 +202,11 @@ public function testListFolder()
$this->_listFolder();
}

public function testNullRoot()
{
$this->_nullRoot();
}

public function testHostspecWithPath()
{
self::$vfs->createFolder('', 'hostspectest');
Expand Down
5 changes: 5 additions & 0 deletions framework/Vfs/test/Horde/Vfs/Sql/Base.php
Expand Up @@ -159,6 +159,11 @@ public function testListFolder()
$this->_listFolder();
}

public function testNullRoot()
{
$this->_nullRoot();
}

public static function setUpBeforeClass()
{
$logger = new Horde_Log_Logger(new Horde_Log_Handler_Cli());
Expand Down
5 changes: 5 additions & 0 deletions framework/Vfs/test/Horde/Vfs/SqlFile/Base.php
Expand Up @@ -159,6 +159,11 @@ public function testListFolder()
$this->_listFolder();
}

public function testNullRoot()
{
$this->_nullRoot();
}

public static function setUpBeforeClass()
{
// The SqlFile VFS driver needs to be refactored to a real composite
Expand Down
5 changes: 5 additions & 0 deletions framework/Vfs/test/Horde/Vfs/Ssh2Test.php
Expand Up @@ -165,6 +165,11 @@ public function testChmod()
$this->_chmod();
}

public function testNullRoot()
{
$this->_nullRoot();
}

public static function setUpBeforeClass()
{
if (!extension_loaded('ssh2')) {
Expand Down
8 changes: 8 additions & 0 deletions framework/Vfs/test/Horde/Vfs/TestBase.php
Expand Up @@ -29,6 +29,7 @@ protected function _listEmpty()
{
$this->assertEquals(array(), self::$vfs->listFolder(''));
$this->assertEquals(array(), self::$vfs->listFolder('/'));
$this->assertEquals(array(), self::$vfs->listFolder(null));
}

/**
Expand Down Expand Up @@ -419,6 +420,13 @@ protected function _chmod()
$this->assertEquals('-rw-r-----', $folder['chmod']['perms']);
}

protected function _nullRoot()
{
self::$vfs->writeData(null, 'nulltest', 'abc');
$this->assertEquals('abc', self::$vfs->read(null, 'nulltest'));
$this->assertEquals('abc', self::$vfs->read('', 'nulltest'));
}

protected function _sort($folders)
{
ksort($folders);
Expand Down

0 comments on commit cc9d6db

Please sign in to comment.