Skip to content

Commit

Permalink
Merge branch 'kohler:master' into hide-conflicted-papers
Browse files Browse the repository at this point in the history
  • Loading branch information
AGrillenberger authored Dec 2, 2024
2 parents 5f74172 + 5f6ede6 commit f9e9a6d
Show file tree
Hide file tree
Showing 114 changed files with 3,292 additions and 1,743 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/devel/d3/d3.js
/devel/d3/d3-hotcrp.min.js
/devel/d3/node_modules
/devel/d3/package-lock.json
/devel/hotcrp-daemonize
/docs
/filestore
Expand Down
2 changes: 1 addition & 1 deletion batch/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static function make_args($argv) {
$arg = (new Getopt)->long(
"name:,n: !",
"config: !",
"dry-run,d Do not perform assignment; output CSV instead.",
"dry-run,d Do not perform assignment; output CSV instead",
"help,h !"
)->description("Perform HotCRP bulk assignments specified in the input CSV file.
Usage: php batch/assign.php [--dry-run] [FILE]")
Expand Down
66 changes: 43 additions & 23 deletions batch/backupdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class BackupDB_Batch {
/** @var bool
* @readonly */
public $tablespaces;
/** @var bool
* @readonly */
public $single_transaction;
/** @var int
* @readonly */
public $count;
Expand Down Expand Up @@ -143,6 +146,7 @@ function __construct(Dbl_ConnectionParams $cp, $arg, $getopt = null) {
$this->compress = isset($arg["z"]);
$this->schema = isset($arg["schema"]);
$this->skip_ephemeral = isset($arg["no-ephemeral"]);
$this->single_transaction = true;
$this->tablespaces = isset($arg["tablespaces"]);
$this->pc_only = isset($arg["pc"]);
$this->count = $arg["count"] ?? 1;
Expand All @@ -152,6 +156,14 @@ function __construct(Dbl_ConnectionParams $cp, $arg, $getopt = null) {
$this->throw_error("Bad option `{$arg}`");
}
$this->my_opts[] = $arg;
if ($arg === "--skip-lock-tables"
|| $arg === "--lock-tables"
|| $arg === "-l"
|| $arg === "--lock-all-tables"
|| $arg === "-x"
|| $arg === "--single-transaction") {
$this->single_transaction = false;
}
}
if (isset($arg["skip-comments"])) {
$this->my_opts[] = "--skip-comments";
Expand Down Expand Up @@ -402,8 +414,10 @@ function sversion_lockstate() {
}
}

/** @return string */
/** @param list<string> $args
* @return list<string> */
function mysqlcmd($cmd, $args) {
$a = [$cmd];
if (($this->connp->password ?? "") !== "") {
if ($this->_pwfile === null) {
$this->_pwtmp = tmpfile();
Expand All @@ -420,28 +434,35 @@ function mysqlcmd($cmd, $args) {
$this->throw_error("Cannot create temporary file");
}
}
$cmd .= " --defaults-extra-file=" . escapeshellarg($this->_pwfile);
$a[] = "--defaults-extra-file={$this->_pwfile}";
}
if (($this->connp->host ?? "localhost") !== "localhost"
&& $this->connp->host !== "") {
$cmd .= " -h " . escapeshellarg($this->connp->host);
$a[] = "-h";
$a[] = $this->connp->host;
}
if (($this->connp->user ?? "") !== "") {
$cmd .= " -u " . escapeshellarg($this->connp->user);
$a[] = "-u";
$a[] = $this->connp->user;
}
if (($this->connp->socket ?? "") !== "") {
$cmd .= " -S " . escapeshellarg($this->connp->socket);
$a[] = "-S";
$a[] = $this->connp->socket;
}
if ($cmd === "mysqldump" && !$this->tablespaces) {
$a[] = "--no-tablespaces";
}
if (!$this->tablespaces && $cmd === "mysqldump") {
$cmd .= " --no-tablespaces";
if ($cmd === "mysqldump" && $this->single_transaction) {
$a[] = "--single-transaction";
}
foreach ($this->my_opts as $opt) {
$cmd .= " " . escapeshellarg($opt);
$a[] = $opt;
}
if ($args !== "") {
$cmd .= " " . $args;
foreach ($args as $opt) {
$a[] = $opt;
}
return $cmd . " " . escapeshellarg($this->connp->name);
$a[] = $this->connp->name;
return $a;
}

private function update_maybe_ephemeral() {
Expand Down Expand Up @@ -634,12 +655,12 @@ private function transfer() {
$this->process_line($s, "\n");
}

/** @param string $cmd
/** @param list<string> $args
* @param array<int,list<string>> $descriptors
* @param array<int,resource> &$pipes
* @return resource */
private function my_proc_open($cmd, $descriptors, &$pipes) {
$proc = proc_open($cmd, $descriptors, $pipes, SiteLoader::$root, [
private function my_proc_open($args, $descriptors, &$pipes) {
$proc = proc_open(Subprocess::args_to_command($args), $descriptors, $pipes, SiteLoader::$root, [
"PATH" => getenv("PATH"), "LC_ALL" => "C"
]);
if (!$proc) {
Expand All @@ -650,7 +671,7 @@ private function my_proc_open($cmd, $descriptors, &$pipes) {

/** @return int */
private function run_restore() {
$cmd = $this->mysqlcmd("mysql", "");
$cmd = $this->mysqlcmd("mysql", []);
$pipes = [];
$proc = $this->my_proc_open($cmd, [0 => ["pipe", "rb"], 1 => ["file", "/dev/null", "w"]], $pipes);
$this->out = $pipes[0];
Expand Down Expand Up @@ -687,10 +708,9 @@ private function s3_put() {
}
}

/** @param string $args
* @param string $tables */
private function run_mysqldump_transfer($args, $tables) {
$cmd = $this->mysqlcmd("mysqldump", $args) . ($tables ? " {$tables}" : "");
/** @param string ...$args */
private function run_mysqldump_transfer(...$args) {
$cmd = $this->mysqlcmd("mysqldump", $args);
$pipes = [];
$proc = $this->my_proc_open($cmd, [["file", "/dev/null", "r"], ["pipe", "wb"]], $pipes);
$this->in = $pipes[1];
Expand All @@ -704,9 +724,9 @@ private function run_pc_only_transfer() {
$pc[] = -1;
}
$where = "contactId in (" . join(",", $pc) . ")";
$this->run_mysqldump_transfer("--where='{$where}'", "ContactInfo");
$this->run_mysqldump_transfer("", "Settings TopicArea");
$this->run_mysqldump_transfer("--where='{$where}'", "TopicInterest");
$this->run_mysqldump_transfer("--where={$where}", "ContactInfo");
$this->run_mysqldump_transfer("Settings", "TopicArea");
$this->run_mysqldump_transfer("--where={$where}", "TopicInterest");
}

private function open_streams() {
Expand Down Expand Up @@ -797,7 +817,7 @@ private function run_streams() {
} else if ($this->pc_only) {
$this->run_pc_only_transfer();
} else {
$this->run_mysqldump_transfer("", "");
$this->run_mysqldump_transfer();
}

if (!empty($this->_checked_tables)) {
Expand Down
6 changes: 5 additions & 1 deletion batch/makedist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ lib/runsql.sh
lib/s3client.php
lib/s3result.php
lib/scoreinfo.php
lib/subprocess.php
lib/tagger.php
lib/text.php
lib/unicodehelper.php
Expand Down Expand Up @@ -338,6 +339,7 @@ src/logentryfilter.php
src/mailrecipients.php
src/mailsender.php
src/meetingtracker.php
src/mentionlister.php
src/mentionparser.php
src/mergecontacts.php
src/multiconference.php
Expand Down Expand Up @@ -484,7 +486,6 @@ src/searchoperatorset.php
src/searchparser.php
src/searchselection.php
src/searchterm.php
src/searchviewcommand.php
src/searchword.php
src/sessionlist.php
src/settinginfoset.php
Expand Down Expand Up @@ -537,6 +538,9 @@ src/useractions.php
src/userinfo/u_developer.php
src/userinfo/u_security.php
src/userstatus.php
src/viewcommand.php
src/viewoptionlist.php
src/viewoptionschema.php
src/xtparams.php
devel/hotcrp.vim
Expand Down
6 changes: 2 additions & 4 deletions batch/savepapers.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,8 @@ private function _run_main(&$jl) {
$this->prefetch_authors($jl);

if ($this->add_topics) {
foreach ($this->conf->options()->form_fields() as $opt) {
if ($opt instanceof Topics_PaperOption)
$opt->allow_new_topics(true);
}
$this->conf->topic_set()->set_auto_add(true);
$this->conf->options()->refresh_topics();
}
if ($this->silent) {
foreach ($this->conf->options()->form_fields() as $opt) {
Expand Down
4 changes: 2 additions & 2 deletions batch/saveusers.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ private function parse_csvp(CsvParser $csv) {
while (($line = $csv->next_row())) {
$this->ustatus->set_user(Contact::make($this->conf));
$this->ustatus->clear_messages();
$this->ustatus->start_update((object) ["id" => null]);
$this->ustatus->csvreq = $line;
$this->ustatus->jval = (object) ["id" => null];
$this->ustatus->parse_csv_group("");
if (($acct = $this->ustatus->save_user($this->ustatus->jval))) {
if (($acct = $this->ustatus->save_update())) {
if ($this->quiet) {
// print nothing
} else if (empty($this->ustatus->diffs)) {
Expand Down
Loading

0 comments on commit f9e9a6d

Please sign in to comment.