Skip to content

Commit

Permalink
[jan] Fix updating large files in Oracle backends.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Dec 14, 2015
1 parent 90a73b5 commit 0025def
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
4 changes: 3 additions & 1 deletion framework/SessionHandler/package.xml
Expand Up @@ -33,6 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [jan] Fix updating large files in Oracle backends.
* [jan] Fix writing big session data to Oracle (Bug #14175).
</notes>
<contents>
Expand Down Expand Up @@ -131,7 +132,7 @@
<package>
<name>Horde_Db</name>
<channel>pear.horde.org</channel>
<min>2.0.3</min>
<min>2.2.0</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
Expand Down Expand Up @@ -590,6 +591,7 @@ Initial release as a PEAR package
<date>2015-10-20</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [jan] Fix updating large files in Oracle backends.
* [jan] Fix writing big session data to Oracle (Bug #14175).
</notes>
</release>
Expand Down
26 changes: 10 additions & 16 deletions framework/Vfs/lib/Horde/Vfs/Sql.php
Expand Up @@ -753,32 +753,26 @@ protected function _insertBlob($table, $field, $data, $attributes)
*/
protected function _updateBlob($table, $field, $data, $where, $alsoupdate)
{
$updatestring = '';
$values = array();
foreach ($alsoupdate as $key => $value) {
$updatestring .= $key . ' = ?, ';
$values[] = $value;
}
$updatestring .= $field . ' = ?';
$values[] = new Horde_Db_Value_Binary($data);

$wherestring = '';
$wherevalues = array();
foreach ($where as $key => $value) {
if (!empty($wherestring)) {
$wherestring .= ' AND ';
}
$wherestring .= $key . ' = ?';
$values[] = $value;
$wherevalues[] = $value;
}

$query = sprintf('UPDATE %s SET %s WHERE %s',
$table,
$updatestring,
$wherestring);

/* Execute the query. */
try {
$this->_db->update($query, $values);
$this->_db->updateBlob(
$table,
array_merge(
$alsoupdate,
array($field => new Horde_Db_Value_Binary($data))
),
array($wherestring, $wherevalues)
);
} catch (Horde_Db_Exception $e) {
throw new Horde_Vfs_Exception($e);
}
Expand Down
2 changes: 1 addition & 1 deletion framework/Vfs/package.xml
Expand Up @@ -437,7 +437,7 @@ Reading, writing and listing of files are all supported.</description>
<package>
<name>Horde_Db</name>
<channel>pear.horde.org</channel>
<min>2.1.0</min>
<min>2.2.0</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
Expand Down
8 changes: 8 additions & 0 deletions framework/Vfs/test/Horde/Vfs/Sql/Oci8Test.php
Expand Up @@ -31,4 +31,12 @@ public static function setUpBeforeClass()
self::$reason = 'No oci8 configuration';
}
}

public function testWriteLargeData()
{
// Write twice to test both INSERT and UPDATE.
self::$vfs->writeData('', 'large', str_repeat('x', 4001));
self::$vfs->writeData('', 'large', str_repeat('x', 4001));
self::$vfs->deleteFile('', 'large');
}
}

0 comments on commit 0025def

Please sign in to comment.