mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
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:
parent
43bd76336c
commit
d5bf30bb48
7 changed files with 31 additions and 11 deletions
18
resources/sql/patches/115.prepareutf8.sql
Normal file
18
resources/sql/patches/115.prepareutf8.sql
Normal file
|
@ -0,0 +1,18 @@
|
|||
ALTER TABLE `phabricator_project`.`project`
|
||||
MODIFY `phrictionSlug` varchar(128) binary;
|
||||
|
||||
ALTER TABLE phabricator_repository.repository_path
|
||||
ADD COLUMN pathHash varchar(32) binary AFTER path;
|
||||
UPDATE phabricator_repository.repository_path SET pathHash = MD5(path);
|
||||
ALTER TABLE phabricator_repository.repository_path
|
||||
MODIFY pathHash varchar(32) binary not null,
|
||||
DROP KEY path,
|
||||
ADD UNIQUE KEY (pathHash);
|
||||
|
||||
ALTER TABLE phabricator_user.user_sshkey
|
||||
ADD COLUMN keyHash varchar(32) binary AFTER keyBody;
|
||||
UPDATE phabricator_user.user_sshkey SET keyHash = MD5(keyBody);
|
||||
ALTER TABLE phabricator_user.user_sshkey
|
||||
MODIFY keyHash varchar(32) binary not null,
|
||||
DROP KEY keyBody,
|
||||
ADD UNIQUE KEY (keyHash);
|
|
@ -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'];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue