Merge pull request #4233 from nextcloud/backport-4071-database-conversion-failure
[stable11] Make sure blob columns are correctly converted as parameters
This commit is contained in:
commit
6532ce22c2
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
namespace OC\Core\Command\Db;
|
namespace OC\Core\Command\Db;
|
||||||
|
|
||||||
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||||
use \OCP\IConfig;
|
use \OCP\IConfig;
|
||||||
use OC\DB\Connection;
|
use OC\DB\Connection;
|
||||||
use OC\DB\ConnectionFactory;
|
use OC\DB\ConnectionFactory;
|
||||||
|
@ -54,6 +55,9 @@ class ConvertType extends Command implements CompletionAwareInterface {
|
||||||
*/
|
*/
|
||||||
protected $connectionFactory;
|
protected $connectionFactory;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $columnTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \OCP\IConfig $config
|
* @param \OCP\IConfig $config
|
||||||
* @param \OC\DB\ConnectionFactory $connectionFactory
|
* @param \OC\DB\ConnectionFactory $connectionFactory
|
||||||
|
@ -304,8 +308,13 @@ class ConvertType extends Command implements CompletionAwareInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($row as $key => $value) {
|
foreach ($row as $key => $value) {
|
||||||
|
$type = $this->getColumnType($table, $key);
|
||||||
|
if ($type !== false) {
|
||||||
|
$insertQuery->setParameter($key, $value, $type);
|
||||||
|
} else {
|
||||||
$insertQuery->setParameter($key, $value);
|
$insertQuery->setParameter($key, $value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$insertQuery->execute();
|
$insertQuery->execute();
|
||||||
}
|
}
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
|
@ -313,6 +322,26 @@ class ConvertType extends Command implements CompletionAwareInterface {
|
||||||
$progress->finish();
|
$progress->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getColumnType($table, $column) {
|
||||||
|
if (isset($this->columnTypes[$table][$column])) {
|
||||||
|
return $this->columnTypes[$table][$column];
|
||||||
|
}
|
||||||
|
$prefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
|
||||||
|
|
||||||
|
$this->columnTypes[$table][$column] = false;
|
||||||
|
|
||||||
|
if ($table === $prefix . 'cards' && $column === 'carddata') {
|
||||||
|
$this->columnTypes[$table][$column] = IQueryBuilder::PARAM_LOB;
|
||||||
|
} else if ($column === 'calendardata') {
|
||||||
|
if ($table === $prefix . 'calendarobjects' ||
|
||||||
|
$table === $prefix . 'schedulingobjects') {
|
||||||
|
$this->columnTypes[$table][$column] = IQueryBuilder::PARAM_LOB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->columnTypes[$table][$column];
|
||||||
|
}
|
||||||
|
|
||||||
protected function convertDB(Connection $fromDB, Connection $toDB, array $tables, InputInterface $input, OutputInterface $output) {
|
protected function convertDB(Connection $fromDB, Connection $toDB, array $tables, InputInterface $input, OutputInterface $output) {
|
||||||
$this->config->setSystemValue('maintenance', true);
|
$this->config->setSystemValue('maintenance', true);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue