Skip to content

Commit

Permalink
Absolute retardation
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Feb 6, 2024
1 parent da8b07d commit a2dcffb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
13 changes: 10 additions & 3 deletions src/conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 */
Expand Down
9 changes: 1 addition & 8 deletions src/options/o_checkboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down
2 changes: 1 addition & 1 deletion src/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 32 additions & 3 deletions src/updateschema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a2dcffb

Please sign in to comment.