Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure blob columns are correctly converted as parameters #4071

Merged
merged 2 commits into from
Apr 4, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion core/Command/Db/ConvertType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -304,7 +308,7 @@ protected function copyTable(Connection $fromDB, Connection $toDB, $table, Input
}

foreach ($row as $key => $value) {
$insertQuery->setParameter($key, $value);
$insertQuery->setParameter($key, $value, $this->getColumnType($table, $key));
}
$insertQuery->execute();
}
Expand All @@ -313,6 +317,25 @@ protected function copyTable(Connection $fromDB, Connection $toDB, $table, Input
$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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting this makes no difference, isset will also return false if the value is null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I used a different value before...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

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 {
Expand Down