Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,20 @@ function process_page($page)
true,
true
);
} elseif ($config->rewrite) {
$logger->info("Updating config on " . $page . " at " . $config_block->start_position);

$newPageData = substr($pagedata, 0, $config_block->start_position);
$newPageData .= $config->toWiki();
$newPageData .= substr($pagedata, $config_block->start_position + $config_block->end_position);

$wpapi->edit(
$page,
$newPageData,
'Updating config. (BOT)',
true,
true
);
}

$logger->info("Handling archive config on " . $page . ": " . $config->toWiki());
Expand Down
1 change: 1 addition & 0 deletions lib/config/ArchiveConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ArchiveConfig

// This is a flag which causes the config to be removed on the archiving run
public bool $once = false;
public bool $rewrite = false;

// Internal flag
public bool $is_valid = false;
Expand Down
2 changes: 2 additions & 0 deletions lib/config/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ function build_config_from_config_block(string $page, RawConfig $block)
// so set it to the implicit value up-front.
// Note: this has a side effect that toWiki will populate the value.
$config->archiveprefix = $page . '/Archives/';
$config->rewrite = true;
}

if (array_key_exists('format', $options) && !empty($options['format'])) {
Expand Down Expand Up @@ -312,6 +313,7 @@ function build_config_from_config_block(string $page, RawConfig $block)
$logger->error('Incorrect key for archive prefix; page=' . $page . ', prefix=' . $config->archiveprefix);
$config->archiveprefix = $page . '/Archives/';
$config->key = DefaultConfig::$key;
$config->rewrite = true;
}
}

Expand Down
Loading