diff --git a/src/conference.php b/src/conference.php index 0d5c68d014..42e4545036 100644 --- a/src/conference.php +++ b/src/conference.php @@ -356,7 +356,7 @@ function __load_settings() { function load_settings() { $this->__load_settings(); - if ($this->sversion < 290) { + if ($this->sversion < 291) { $old_nerrors = Dbl::$nerrors; while ((new UpdateSchema($this))->run()) { usleep(50000); @@ -374,13 +374,20 @@ function load_settings() { unset($this->settings["frombackup"]); } + $this->refresh_settings(); + $this->refresh_options(); + // GC old capabilities if (($this->settings["__capability_gc"] ?? 0) < Conf::$now - 86400) { $this->clean_tokens(); } - $this->refresh_settings(); - $this->refresh_options(); + // might need to redo automatic tags + if ($this->settings["__recompute_automatic_tags"] ?? 0) { + $this->qe("delete from Settings where name='__recompute_automatic_tags' and value=?", $this->settings["__recompute_automatic_tags"]); + unset($this->settings["__recompute_automatic_tags"], $this->settingTexts["__recompute_automatic_tags"]); + $this->update_automatic_tags(); + } } /** @suppress PhanAccessReadOnlyProperty */ diff --git a/src/options/o_checkboxes.php b/src/options/o_checkboxes.php index 94b0e0692e..d5e79fbf21 100644 --- a/src/options/o_checkboxes.php +++ b/src/options/o_checkboxes.php @@ -37,14 +37,7 @@ function export_setting() { /** @return TopicSet */ function topic_set() { - if ($this->topics === null) { - $this->topics = new TopicSet($this->conf); - foreach ($this->values() as $i => $s) { - if ($s !== null) - $this->topics->__add($i, $s); - } - } - return $this->topics; + return $this->values_topic_set(); } diff --git a/src/schema.sql b/src/schema.sql index 360736a4da..027bb03c34 100644 --- a/src/schema.sql +++ b/src/schema.sql @@ -624,7 +624,7 @@ CREATE TABLE `TopicInterest` ( -- Initial settings -- (each setting must be on its own line for createdb.sh) insert into Settings (name, value, data) values - ('allowPaperOption', 290, null), -- schema version + ('allowPaperOption', 291, null), -- schema version ('setupPhase', 1, null), -- initial user is chair ('no_papersub', 1, null), -- no submissions yet ('sub_pcconf', 1, null), -- collect PC conflicts, not collaborators diff --git a/src/updateschema.php b/src/updateschema.php index bd4db29afa..72770a5555 100644 --- a/src/updateschema.php +++ b/src/updateschema.php @@ -1156,6 +1156,19 @@ private function v283_ensure_rev_roundtag() { } } + private function v291_unfuck_checkboxes($options_data) { + $any = false; + foreach ($options_data as $v) { + if (is_object($v) && $v->type === "checkboxes") { + $this->conf->qe("update PaperOption set value=value+1 where optionId=? order by paperId asc, value desc", $v->id); + $any = true; + } + } + if ($any) { + $this->conf->save_setting("__recompute_automatic_tags", mt_rand(1, 2000000000)); + } + } + /** @return bool */ function run() { $conf = $this->conf; @@ -1185,16 +1198,28 @@ function run() { if (is_object($options_data)) { $options_data = $this->v1_options_setting($options_data); } - if (is_array($options_data) && $conf->sversion <= 247) { + if ($conf->sversion <= 247 + && is_array($options_data)) { $options_data = $this->v248_options_setting($options_data); } - if (is_array($options_data) && $conf->sversion <= 277) { + if ($conf->sversion <= 277 + && is_array($options_data)) { $options_data = $this->v278_options_setting($options_data); } - if (is_array($options_data) && $conf->sversion <= 278) { + if ($conf->sversion <= 278 + && is_array($options_data)) { $options_data = $this->v279_options_setting($options_data); } + // unfuck checkboxes options + if ($conf->sversion <= 290 + && !$conf->setting("__unfucked_checkboxes_v291")) { + $conf->save_setting("__unfucked_checkboxes_v291", 1); + if (is_array($options_data)) { + $this->v291_unfuck_checkboxes($options_data); + } + } + // update `review_form` if ($conf->sversion <= 257 && !$conf->setting("__review_form_v258") @@ -2960,6 +2985,10 @@ function run() { && $conf->ql_ok("alter table PaperReview change `reviewAuthorSeen` `reviewAuthorSeen` bigint(1) NOT NULL DEFAULT 0")) { $conf->update_schema_version(290); } + If ($conf->sversion === 290) { + $conf->ql_ok("delete from Settings where name='__unfucked_checkboxes_v291'"); + $conf->update_schema_version(291); + } $conf->ql_ok("delete from Settings where name='__schema_lock'"); Conf::$main = $old_conf_g;