Skip to content
Merged
2 changes: 1 addition & 1 deletion accounts/addproofer.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function _validate_fields(

// Ensure we don't already have a registration with this name
try {
$na_user = new NonactivatedUser($username);
new NonactivatedUser($username);
return _("That username has already been requested. Please try another.");
} catch (NonexistentNonactivatedUserException$exception) {
// pass
Expand Down
4 changes: 2 additions & 2 deletions api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ function api_send_pagination_header(array $query_params, int $total_rows, int $p
}

if (is_array($value)) {
foreach ($value as $subkey => $value) {
$params[] = "{$key}[]=" . urlencode($value);
foreach ($value as $value_element) {
$params[] = "{$key}[]=" . urlencode($value_element);
}
} else {
$params[] = "$key=" . urlencode($value);
Expand Down
9 changes: 4 additions & 5 deletions api/v1_projects.inc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ function api_v1_projects(string $method, array $data, array $query_params): arra
throw new ServerError(DPDatabase::log_error());
}
[$total_rows] = mysqli_fetch_row($result_count);
$total_pages = round($total_rows / $per_page);

api_send_pagination_header($query_params, $total_rows, $per_page, $page);

Expand Down Expand Up @@ -420,7 +419,7 @@ function api_v1_project_artifacts(string $method, array $data): array

$response = [];
if ($stage->id == "PP") {
[$zipfile_path, $zipfile_url] = generate_project_images_zip($project->projectid);
[$_zipfile_path, $zipfile_url] = generate_project_images_zip($project->projectid);

$response[] = [
"stage" => $stage->id,
Expand Down Expand Up @@ -838,7 +837,7 @@ function api_v1_projects_specialdays(string $method, array $data, array $query_p

$special_days = load_special_days();
$enabled_filter = _get_enabled_filter($query_params);
foreach ($special_days as $spec_code => $special_day) {
foreach ($special_days as $special_day) {
$enabled = $special_day["enable"] == 1;
if ($enabled_filter !== null) {
if ($enabled_filter != $enabled) {
Expand Down Expand Up @@ -885,7 +884,7 @@ function api_v1_projects_imagesources(string $method, array $data, array $query_
$image_sources = load_image_sources();

$enabled_filter = _get_enabled_filter($query_params);
foreach ($image_sources as $id => $image_source) {
foreach ($image_sources as $image_source) {
$is_active = $image_source["is_active"] == 1;
if ($enabled_filter !== null) {
if ($enabled_filter != $is_active) {
Expand Down Expand Up @@ -989,7 +988,7 @@ function api_v1_project_wordcheck(string $method, array $data): array
}

$text = receive_project_text_from_request_body();
[$bad_words, $languages, $messages] = get_bad_word_levels_for_project_text($text, $project->projectid, $languages, $accepted_words);
[$bad_words, $_languages, $messages] = get_bad_word_levels_for_project_text($text, $project->projectid, $languages, $accepted_words);
return [
"bad_words" => $bad_words,
"messages" => $messages,
Expand Down
2 changes: 1 addition & 1 deletion credits.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function load_composer_credit_details()
}
$packages = json_decode($contents, flags: JSON_THROW_ON_ERROR);
$credit_details = [];
foreach ($packages->packages as $index => $package) {
foreach ($packages->packages as $package) {
$credit_details[$package->name] = new CreditDetails(
name: $package->name,
url: $package->homepage ?? null,
Expand Down
15 changes: 6 additions & 9 deletions crontab/AutoModify.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@ class AutoModify extends BackgroundJob
if (($this->filehandle = fopen($this->logfile, "wt")) === false) {
throw new RuntimeException(sprintf(_("Failed to open log file %s."), $this->logfile));
}
ob_start([$this, 'flush'], 1024);
ob_start(function (string $buffer) {
if (!is_null($this->filehandle)) {
fwrite($this->filehandle, $buffer);
}
return $buffer;
}, chunk_size: 1024);

automodify();
autorelease();

ob_end_flush();
fclose($this->filehandle);
}

private function flush(string $buffer, int $phase): string
{
if (!is_null($this->filehandle)) {
fwrite($this->filehandle, $buffer);
}
return $buffer;
}
}
1 change: 0 additions & 1 deletion feeds/backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ function generate_rss_feed(string $content, string $site_name, string $code_url,
$data = '';
$result = DPDatabase::query($query);
while ($row = mysqli_fetch_array($result)) {
$posteddate = date("r", ($row['modifieddate']));
$data .= "<item>
<title>".xmlencode($row['nameofwork'])." - ".xmlencode($row['authorsname'])."</title>
<link>".xmlencode("$code_url/project.php?id=".$row['projectid'])."</link>
Expand Down
1 change: 0 additions & 1 deletion locale/translators/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ function main_form(): void
echo "<li>" . _("Last modified") . ": "
. date("F d Y H:i:s", $pot_file->last_modified) . "</li>";
$total_strings = $pot_file->messages_count;
$translated_strings = $pot_file->messages_translated_count;
echo "<li>" . sprintf(_("%d strings total"), $total_strings) . "</li>";
echo "</ul></p>";
} else {
Expand Down
5 changes: 1 addition & 4 deletions pinc/Activity.inc
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,6 @@ class Activity
}
}

$can_access = false;
$request_status = null;

if ($recorded_access == 'denied') {
// they are not allowed to access this activity or to request access
$can_access = false;
Expand Down Expand Up @@ -604,7 +601,7 @@ function show_user_access_chart(?string $username): void
if (is_null($row)) {
echo "<td></td>";
} else {
[$criterion_str, $minimum, $user_score, $satisfied] = $row;
[$_criterion_str, $minimum, $_user_score, $satisfied] = $row;
td_w_bgcolor($minimum, $satisfied);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pinc/CharSuites.inc
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class CharSuites
public static function enable(string $name): void
{
// Validate we have a valid charsuite
$charsuite = CharSuites::get($name);
CharSuites::get($name);

$sql = sprintf(
"
Expand Down
4 changes: 2 additions & 2 deletions pinc/DPage.inc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function project_allow_pages(string $projectid): void
function project_drop_pages(string $projectid): void
{
validate_projectID($projectid);
$result = DPDatabase::query("DROP TABLE $projectid");
DPDatabase::query("DROP TABLE $projectid");

_project_adjust_n_pages($projectid, 'NONE');
_project_adjust_n_available_pages($projectid, 'NONE');
Expand Down Expand Up @@ -89,7 +89,7 @@ function Pages_prepForRound(string $projectid, int $round_number): void
SET
$setters
";
$result = DPDatabase::query($sql);
DPDatabase::query($sql);

_project_adjust_n_available_pages($projectid, 'ALL');
}
Expand Down
5 changes: 1 addition & 4 deletions pinc/MARCRecord.inc
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ class MARCRecord

public function get_author(): string
{
$author = "";

$author_fields = [
"100", // https://www.loc.gov/marc/bibliographic/concise/bd100.html Main Entry--Personal Name
"700", // https://www.loc.gov/marc/bibliographic/concise/bd700.html Added Entry--Personal Name
Expand Down Expand Up @@ -467,7 +465,6 @@ class MARCRecord

public function get_type_of_record(): string
{
$lang_name = "";
// https://www.loc.gov/marc/bibliographic/bdleader.html Leader
// Character 6 - Type of record
$leader = $this->record[0][1]; // The leader is always the first record.
Expand Down Expand Up @@ -612,7 +609,7 @@ class MARCRecord
$length = sprintf("%04d", $length + 1);
$directory .= $length.$start;

foreach ($this->record as $field => $field_value) {
foreach ($this->record as $field_value) {
if (preg_match("/^\(3,".substr($tag_value[0], 3, 3)."\)\(3,[012[:space:]]+\)$/", $field_value[0]) && !in_array(substr($tag_value[0], 3, 3), $stack)) {
$data .= "\x1E".substr($field_value[0], 10, 2);
}
Expand Down
2 changes: 1 addition & 1 deletion pinc/POFile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class POFile
*/
private function is_block_translated(string $block): bool
{
[$msgid, $msgstr] = @explode("msgstr", $block);
[$_msgid, $msgstr] = @explode("msgstr", $block);
$msgstr = "msgstr$msgstr";
if (strpos($msgstr, 'msgstr ""') === 0 &&
substr_count($msgstr, "\n") == 1) {
Expand Down
6 changes: 2 additions & 4 deletions pinc/Project.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ class Project
// $name ($project->scannercredit) could be
// a username or just a typed-in string
try {
$user = new User($name);
new User($name);
} catch (NonexistentUserException $exception) {
// $name is not a username.
// So use it as the credit.
Expand Down Expand Up @@ -1494,7 +1494,7 @@ class Project
$topic_id,
DPDatabase::escape($this->projectid)
);
$update_project = DPDatabase::query($sql);
DPDatabase::query($sql);
$this->topic_id = $topic_id;

return $topic_id;
Expand All @@ -1508,7 +1508,6 @@ class Project
*/
public function email_introduction(): string
{
$projectid = $this->projectid;
$title = $this->nameofwork;

return implode("\n", [
Expand Down Expand Up @@ -1915,7 +1914,6 @@ function project_get_auto_PPer(string $projectid): ?string
$project = new Project($projectid);
$checkedoutby = $project->checkedoutby;
$username = $project->username;
$possible_PPer = '';
if ($checkedoutby != '') {
// The project is reserved for a PPer, so it will be checked out to him/her.
$possible_PPer = $checkedoutby;
Expand Down
2 changes: 1 addition & 1 deletion pinc/ProjectSearchForm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class ProjectSearchForm
}

// then everything else
foreach (get_iso_language_list() as $k => $v) {
foreach (get_iso_language_list() as $v) {
if (!isset($lang_options[$v['lang_name']])) {
$lang_options[$v['lang_name']] = $v['lang_name'];
}
Expand Down
3 changes: 1 addition & 2 deletions pinc/ProjectSearchResults.inc
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,7 @@ class ProjectSearchResults
private function get_sort_sql(string $col_id): ?string
{
foreach ($this->active_columns as $column) {
if ($column->sortable && ($column->id == $col_id)) {
$valid = true;
if ($column->sortable && $column->id == $col_id) {
return $column->get_sort_sql();
}
}
Expand Down
2 changes: 1 addition & 1 deletion pinc/ProjectTransition.inc
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class ProjectTransition
SET $settings
WHERE projectid = '$escaped_projectid'
";
$res = DPDatabase::query($sql);
DPDatabase::query($sql);

// ---------------------------------------------------------------------
// Okay, so the update to the 'projects' table succeeded.
Expand Down
4 changes: 2 additions & 2 deletions pinc/RandomRule.inc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class RandomRule
if (preg_match('/^<div id="(.*)"><\/div>$/', $line, $matches)) {
if ($in_rule) {
RandomRule::_add_rule($document, $langcode, $url, $anchor, $subject, $rule);
$anchor = $subject = $rule = "";
$subject = $rule = "";
}
$anchor = $matches[1];
$in_rule = true;
Expand All @@ -223,7 +223,7 @@ class RandomRule
if (preg_match('/<h3><a name="(.*)">(.*)<\/a><\/h3>/', $line, $matches)) {
if ($in_rule) {
RandomRule::_add_rule($document, $langcode, $url, $anchor, $subject, $rule);
$anchor = $subject = $rule = "";
$rule = "";
}
$anchor = $matches[1];
$subject = $matches[2];
Expand Down
12 changes: 6 additions & 6 deletions pinc/TableDocumentation.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TableDocumentation
$lines = [];

// Add column definitions
foreach ($this->columns_information as $index => $column_information) {
foreach ($this->columns_information as $column_information) {
$lines[] = '## `' . $column_information['Field'] . '`';
$lines[] = '';
}
Expand All @@ -65,7 +65,7 @@ class TableDocumentation
{
$column_names = [];

foreach ($this->columns_information as $index => $column_information) {
foreach ($this->columns_information as $column_information) {
$column_names[] = $column_information['Field'];
}

Expand Down Expand Up @@ -140,7 +140,7 @@ class TableDocumentation
$encountered_columns = [];
$should_delete_this_part = false;

foreach ($lines as $index => $line) {
foreach ($lines as $line) {
if (str_starts_with($line, '## `')) {
// 01234 10
// ## `column_name`
Expand All @@ -160,7 +160,7 @@ class TableDocumentation

$missing_column_names = array_diff($column_names, $encountered_columns);

foreach ($missing_column_names as $index => $column_name) {
foreach ($missing_column_names as $column_name) {
$lines_with_updated_column_definitions[] = "## `$column_name`\n\n";
}

Expand All @@ -183,7 +183,7 @@ class TableDocumentation
$reached_table = false;
$finished_table = false;

foreach ($lines as $index => $line) {
foreach ($lines as $line) {
if (str_starts_with($line, '|') && !$finished_table) {
$reached_table = true;
} elseif ($reached_table && !$finished_table) {
Expand Down Expand Up @@ -211,7 +211,7 @@ class TableDocumentation
{
$first_table_lines = [];

foreach ($lines as $index => $line) {
foreach ($lines as $line) {
if (str_starts_with($line, '|')) {
$first_table_lines[] = $line;
} elseif (count($first_table_lines) > 0) {
Expand Down
4 changes: 2 additions & 2 deletions pinc/autorelease.inc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function autorelease_for_round(Round $round): void
echo " Released <b>{$n_projects->released}</b> {$qd->name} projects.\n";
}

AP_teardown($round);
AP_teardown();

echo "\n";
echo "Finished round {$round->id}\n";
Expand Down Expand Up @@ -593,7 +593,7 @@ function AP_setup(Round $round): void
}
}

function AP_teardown(Round $round): void
function AP_teardown(): void
{
$sql = "DROP TABLE active_page_counts";
DPDatabase::query($sql);
Expand Down
2 changes: 0 additions & 2 deletions pinc/bad_bytes.inc
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,6 @@ function define_bad_byte_sequences(): void
$_bad_byte_sequences = [];

foreach ($_character_data as $code_point => $info) {
$char_name = $info['name'];

@$entity_name = $info['e'];
if ($entity_name) {
$entity_ref = "&$entity_name;";
Expand Down
2 changes: 0 additions & 2 deletions pinc/forum_interface_phpbb3.inc
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,6 @@ function get_last_post_time_in_topic(int $topic_id): ?int
*/
function get_topic_details(int $topic_id): ?array
{
$forums_phpbb_dir = SiteConfig::get()->forums_phpbb_dir;

$phpbb_topics = phpbb_table("topics");
$phpbb_forums = phpbb_table("forums");
$phpbb_users = phpbb_table("users");
Expand Down
2 changes: 1 addition & 1 deletion pinc/gettext_setup.inc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function configure_gettext(string $locale): void
// ignore whatever is here, so unset it
putenv("LANGUAGE=");

$locale = setlocale(LC_ALL, $locale);
setlocale(LC_ALL, $locale);

// Specify location of translation tables and choose domain
$gettext_domain = 'messages';
Expand Down
Loading