Prepare database for UTF-8
Summary: D1830#8 Test Plan: `scripts/sql/upgrade_schema.php` Try adding duplicate SSH Public Key - failed. Try adding new SSH Public Key - succeeded. Reviewers: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1852
This commit is contained in:
@@ -128,9 +128,9 @@ abstract class DiffusionHistoryQuery {
|
||||
$path_normal = DiffusionPathIDQuery::normalizePath($path);
|
||||
$paths = queryfx_all(
|
||||
$conn_r,
|
||||
'SELECT id, path FROM %T WHERE path IN (%Ls)',
|
||||
'SELECT id, path FROM %T WHERE pathHash IN (%Ls)',
|
||||
PhabricatorRepository::TABLE_PATH,
|
||||
array($path_normal));
|
||||
array(md5($path_normal)));
|
||||
$paths = ipull($paths, 'id', 'path');
|
||||
$path_id = idx($paths, $path_normal);
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ final class DiffusionSvnHistoryQuery extends DiffusionHistoryQuery {
|
||||
|
||||
$paths = queryfx_all(
|
||||
$conn_r,
|
||||
'SELECT id, path FROM %T WHERE path IN (%Ls)',
|
||||
'SELECT id, path FROM %T WHERE pathHash IN (%Ls)',
|
||||
PhabricatorRepository::TABLE_PATH,
|
||||
array('/'.trim($path, '/')));
|
||||
array(md5('/'.trim($path, '/'))));
|
||||
$paths = ipull($paths, 'id', 'path');
|
||||
$path_id = $paths['/'.trim($path, '/')];
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ final class DiffusionPathIDQuery {
|
||||
|
||||
$paths = queryfx_all(
|
||||
$repository->establishConnection('r'),
|
||||
'SELECT * FROM %T WHERE path IN (%Ls)',
|
||||
'SELECT * FROM %T WHERE pathHash IN (%Ls)',
|
||||
PhabricatorRepository::TABLE_PATH,
|
||||
array_keys($path_normal_map));
|
||||
array_map('md5', array_keys($path_normal_map)));
|
||||
$paths = ipull($paths, 'id', 'path');
|
||||
|
||||
$result = array();
|
||||
|
||||
@@ -94,6 +94,7 @@ final class PhabricatorUserSSHKeysSettingsPanelController
|
||||
} else {
|
||||
$key->setKeyType($type);
|
||||
$key->setKeyBody($body);
|
||||
$key->setKeyHash(md5($body));
|
||||
$key->setKeyComment($comment);
|
||||
|
||||
$e_key = null;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ class PhabricatorUserSSHKey extends PhabricatorUserDAO {
|
||||
protected $name;
|
||||
protected $keyType;
|
||||
protected $keyBody;
|
||||
protected $keyHash;
|
||||
protected $keyComment;
|
||||
|
||||
public function getEntireKey() {
|
||||
|
||||
@@ -39,11 +39,11 @@ abstract class PhabricatorRepositoryCommitChangeParserWorker
|
||||
foreach (array_chunk($missing_paths, 128) as $path_chunk) {
|
||||
$sql = array();
|
||||
foreach ($path_chunk as $path) {
|
||||
$sql[] = qsprintf($conn_w, '(%s)', $path);
|
||||
$sql[] = qsprintf($conn_w, '(%s, %s)', $path, md5($path));
|
||||
}
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'INSERT IGNORE INTO %T (path) VALUES %Q',
|
||||
'INSERT IGNORE INTO %T (path, pathHash) VALUES %Q',
|
||||
PhabricatorRepository::TABLE_PATH,
|
||||
implode(', ', $sql));
|
||||
}
|
||||
@@ -61,9 +61,9 @@ abstract class PhabricatorRepositoryCommitChangeParserWorker
|
||||
foreach (array_chunk($paths, 128) as $path_chunk) {
|
||||
$chunk_map = queryfx_all(
|
||||
$conn_w,
|
||||
'SELECT path, id FROM %T WHERE path IN (%Ls)',
|
||||
'SELECT path, id FROM %T WHERE pathHash IN (%Ls)',
|
||||
PhabricatorRepository::TABLE_PATH,
|
||||
$path_chunk);
|
||||
array_map('md5', $path_chunk));
|
||||
foreach ($chunk_map as $row) {
|
||||
$result_map[$row['path']] = $row['id'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user