From 51a7440a0c9f825cb9169de2506405c8a62fc0ae Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Wed, 30 Aug 2023 16:06:45 -0400 Subject: [PATCH] Detard plus nits. --- batch/savepapers.php | 4 ++-- src/api/api_paper.php | 3 ++- src/papercolumns/pc_tag.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/batch/savepapers.php b/batch/savepapers.php index 24f133bfca..9019db3fab 100644 --- a/batch/savepapers.php +++ b/batch/savepapers.php @@ -58,10 +58,10 @@ function __construct(Conf $conf) { function set_args($arg) { $this->quiet = isset($arg["q"]); $this->ignore_errors = isset($arg["ignore-errors"]); - if (isset($args["ignore-pid"])) { + if (isset($arg["ignore-pid"])) { $this->pidflags |= Paper_API::PIDFLAG_IGNORE_PID; } - if (isset($args["match-title"])) { + if (isset($arg["match-title"])) { $this->pidflags |= Paper_API::PIDFLAG_MATCH_TITLE; } $this->disable_users = isset($arg["disable-users"]); diff --git a/src/api/api_paper.php b/src/api/api_paper.php index c1603f29b4..5d4e0eb0eb 100644 --- a/src/api/api_paper.php +++ b/src/api/api_paper.php @@ -179,7 +179,8 @@ static function analyze_json_pid(Conf $conf, $j, $pidflags = 0) { } unset($j->pid, $j->id); } - if (!isset($j->pid) && !isset($j->id) + if (!isset($j->pid) + && !isset($j->id) && ($pidflags & self::PIDFLAG_MATCH_TITLE) !== 0 && is_string($j->title ?? null)) { $pids = Dbl::fetch_first_columns($conf->dblink, "select paperId from Paper where title=?", simplify_whitespace($j->title)); diff --git a/src/papercolumns/pc_tag.php b/src/papercolumns/pc_tag.php index 4f30732bbe..0cde45b757 100644 --- a/src/papercolumns/pc_tag.php +++ b/src/papercolumns/pc_tag.php @@ -37,7 +37,7 @@ function add_decoration($decor) { if ($decor === "edit") { $this->editable = true; return $this->__add_decoration($decor); - } else if (preg_match('/\A%\d*(?:\.\d*)[bdeEfFgGoxX]\z/', $decor)) { + } else if (preg_match('/\A%?\d*(?:\.\d*)[bdeEfFgGoxX]\z/', $decor)) { $this->__add_decoration($decor, [$this->real_format]); $this->real_format = $decor; return true;