From ea34f3bbbdd51c914dd79ab5cf00fd739b23418b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 26 Mar 2017 17:11:57 +0200 Subject: [PATCH 1/2] Make sure blob columns are correctly converted as parameters Signed-off-by: Joas Schilling --- core/Command/Db/ConvertType.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index a8969251ba..5bb43400d6 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -28,6 +28,7 @@ namespace OC\Core\Command\Db; +use OCP\DB\QueryBuilder\IQueryBuilder; use \OCP\IConfig; use OC\DB\Connection; use OC\DB\ConnectionFactory; @@ -54,6 +55,9 @@ class ConvertType extends Command implements CompletionAwareInterface { */ protected $connectionFactory; + /** @var array */ + protected $columnTypes; + /** * @param \OCP\IConfig $config * @param \OC\DB\ConnectionFactory $connectionFactory @@ -304,7 +308,7 @@ class ConvertType extends Command implements CompletionAwareInterface { } foreach ($row as $key => $value) { - $insertQuery->setParameter($key, $value); + $insertQuery->setParameter($key, $value, $this->getColumnType($table, $key)); } $insertQuery->execute(); } @@ -313,6 +317,25 @@ class ConvertType extends Command implements CompletionAwareInterface { $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] = null; + 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) { $this->config->setSystemValue('maintenance', true); try { From a7efdd6094c094230c148ccef3c22d4765201dda Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 26 Mar 2017 22:43:19 +0200 Subject: [PATCH 2/2] Use false because null crashes the cache Signed-off-by: Joas Schilling --- core/Command/Db/ConvertType.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index 5bb43400d6..4ca7899fec 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -308,7 +308,12 @@ class ConvertType extends Command implements CompletionAwareInterface { } foreach ($row as $key => $value) { - $insertQuery->setParameter($key, $value, $this->getColumnType($table, $key)); + $type = $this->getColumnType($table, $key); + if ($type !== false) { + $insertQuery->setParameter($key, $value, $type); + } else { + $insertQuery->setParameter($key, $value); + } } $insertQuery->execute(); } @@ -321,9 +326,10 @@ class ConvertType extends Command implements CompletionAwareInterface { if (isset($this->columnTypes[$table][$column])) { return $this->columnTypes[$table][$column]; } - $prefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); - $this->columnTypes[$table][$column] = null; + + $this->columnTypes[$table][$column] = false; + if ($table === $prefix . 'cards' && $column === 'carddata') { $this->columnTypes[$table][$column] = IQueryBuilder::PARAM_LOB; } else if ($column === 'calendardata') {