forked from extern/egroupware
fix migrate_db2fs to only fetch 5 files per query, as we dont want to require enough memory to hold all file in memory
This commit is contained in:
parent
5c82ac5465
commit
d1bea8ca1d
@ -664,7 +664,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
|
|||||||
/**
|
/**
|
||||||
* due to problems with recursive directory creation, we have our own here
|
* due to problems with recursive directory creation, we have our own here
|
||||||
*/
|
*/
|
||||||
private static function mkdir_recursive($pathname, $mode, $depth=0)
|
protected static function mkdir_recursive($pathname, $mode, $depth=0)
|
||||||
{
|
{
|
||||||
$maxdepth=10;
|
$maxdepth=10;
|
||||||
$depth2propagate = (int)$depth + 1;
|
$depth2propagate = (int)$depth + 1;
|
||||||
|
@ -31,18 +31,20 @@ class sqlfs_utils extends sqlfs_stream_wrapper
|
|||||||
self::_pdo();
|
self::_pdo();
|
||||||
}
|
}
|
||||||
$query = 'SELECT fs_id,fs_name,fs_size,fs_content'.
|
$query = 'SELECT fs_id,fs_name,fs_size,fs_content'.
|
||||||
' FROM '.self::TABLE.' WHERE fs_content IS NOT NULL';
|
' FROM '.self::TABLE.' WHERE fs_content IS NOT NULL'.
|
||||||
|
' ORDER BY fs_id LIMIT 5 OFFSET :offset';
|
||||||
|
|
||||||
$fs_id = $fs_name = $fs_size = $fs_content = null;
|
$fs_id = $fs_name = $fs_size = $fs_content = null;
|
||||||
|
$n = 0;
|
||||||
$stmt = self::$pdo->prepare($query);
|
$stmt = self::$pdo->prepare($query);
|
||||||
$stmt->bindColumn(1,$fs_id);
|
$stmt->bindColumn(1,$fs_id);
|
||||||
$stmt->bindColumn(2,$fs_name);
|
$stmt->bindColumn(2,$fs_name);
|
||||||
$stmt->bindColumn(3,$fs_size);
|
$stmt->bindColumn(3,$fs_size);
|
||||||
$stmt->bindColumn(4,$fs_content,PDO::PARAM_LOB);
|
$stmt->bindColumn(4,$fs_content,PDO::PARAM_LOB);
|
||||||
|
$stmt->bindValue(':offset', $n, PDO::PARAM_INT);
|
||||||
|
|
||||||
if ($stmt->execute())
|
while ($stmt->execute())
|
||||||
{
|
{
|
||||||
$n = 0;
|
|
||||||
foreach($stmt as $row)
|
foreach($stmt as $row)
|
||||||
{
|
{
|
||||||
// hack to work around a current php bug (http://bugs.php.net/bug.php?id=40913)
|
// hack to work around a current php bug (http://bugs.php.net/bug.php?id=40913)
|
||||||
@ -82,16 +84,17 @@ class sqlfs_utils extends sqlfs_stream_wrapper
|
|||||||
fclose($content); unset($content);
|
fclose($content); unset($content);
|
||||||
|
|
||||||
++$n;
|
++$n;
|
||||||
unset($row); // not used, as we access bound variables
|
|
||||||
}
|
}
|
||||||
unset($stmt);
|
if (!$n) break; // just in case nothing is found, statement will execute just fine
|
||||||
|
}
|
||||||
|
unset($row); // not used, as we access bound variables
|
||||||
|
unset($stmt);
|
||||||
|
|
||||||
if ($n) // delete all content in DB, if there was some AND no error (exception thrown!)
|
if ($n) // delete all content in DB, if there was some AND no error (exception thrown!)
|
||||||
{
|
{
|
||||||
$query = 'UPDATE '.self::TABLE.' SET fs_content=NULL WHERE fs_content IS NOT NULL';
|
$query = 'UPDATE '.self::TABLE.' SET fs_content=NULL WHERE fs_content IS NOT NULL';
|
||||||
$stmt = self::$pdo->prepare($query);
|
$stmt = self::$pdo->prepare($query);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $n;
|
return $n;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user