diff options
author | Joas Schilling <coding@schilljs.com> | 2017-04-04 16:29:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-04 16:29:53 +0200 |
commit | 75657c1a6ee0a55de30f0e089d29c531a907b238 (patch) | |
tree | 02888ca9f160d753dcb595a938f6a3345480e2c3 | |
parent | e0227cb4588a343db9eadfefc2733660877fb60d (diff) | |
parent | 75eee315a31a4dc223cf47b82565fd5cb0b97742 (diff) | |
download | nextcloud-server-75657c1a6ee0a55de30f0e089d29c531a907b238.tar.gz nextcloud-server-75657c1a6ee0a55de30f0e089d29c531a907b238.zip |
Merge pull request #4071 from nextcloud/issue-173-database-conversion-failure
Make sure blob columns are correctly converted as parameters
-rw-r--r-- | core/Command/Db/ConvertType.php | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index a8969251bab..4ca7899fec6 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,12 @@ class ConvertType extends Command implements CompletionAwareInterface { } foreach ($row as $key => $value) { - $insertQuery->setParameter($key, $value); + $type = $this->getColumnType($table, $key); + if ($type !== false) { + $insertQuery->setParameter($key, $value, $type); + } else { + $insertQuery->setParameter($key, $value); + } } $insertQuery->execute(); } @@ -313,6 +322,26 @@ 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] = 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) { $this->config->setSystemValue('maintenance', true); try { |