diff --git a/accounts/addproofer.php b/accounts/addproofer.php index 4c999d2c9..0b0ea62c6 100644 --- a/accounts/addproofer.php +++ b/accounts/addproofer.php @@ -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 diff --git a/api/index.php b/api/index.php index fe9028f78..c8a2d384c 100644 --- a/api/index.php +++ b/api/index.php @@ -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); diff --git a/api/v1_projects.inc b/api/v1_projects.inc index 9e70d03ee..70e842b71 100644 --- a/api/v1_projects.inc +++ b/api/v1_projects.inc @@ -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); @@ -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, @@ -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) { @@ -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) { @@ -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, diff --git a/credits.php b/credits.php index fe460097b..b3171b53f 100644 --- a/credits.php +++ b/credits.php @@ -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, diff --git a/crontab/AutoModify.inc b/crontab/AutoModify.inc index 47ed6bd80..84870db82 100644 --- a/crontab/AutoModify.inc +++ b/crontab/AutoModify.inc @@ -22,7 +22,12 @@ 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(); @@ -30,12 +35,4 @@ class AutoModify extends BackgroundJob 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; - } } diff --git a/feeds/backend.php b/feeds/backend.php index a5c1aac56..7e1620ca2 100644 --- a/feeds/backend.php +++ b/feeds/backend.php @@ -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 .= " ".xmlencode($row['nameofwork'])." - ".xmlencode($row['authorsname'])." ".xmlencode("$code_url/project.php?id=".$row['projectid'])." diff --git a/locale/translators/index.php b/locale/translators/index.php index 793ecf7ba..3b20bbb90 100644 --- a/locale/translators/index.php +++ b/locale/translators/index.php @@ -332,7 +332,6 @@ function main_form(): void echo "
  • " . _("Last modified") . ": " . date("F d Y H:i:s", $pot_file->last_modified) . "
  • "; $total_strings = $pot_file->messages_count; - $translated_strings = $pot_file->messages_translated_count; echo "
  • " . sprintf(_("%d strings total"), $total_strings) . "
  • "; echo "

    "; } else { diff --git a/pinc/Activity.inc b/pinc/Activity.inc index 13975b34d..8071dcfd4 100644 --- a/pinc/Activity.inc +++ b/pinc/Activity.inc @@ -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; @@ -604,7 +601,7 @@ function show_user_access_chart(?string $username): void if (is_null($row)) { echo ""; } else { - [$criterion_str, $minimum, $user_score, $satisfied] = $row; + [$_criterion_str, $minimum, $_user_score, $satisfied] = $row; td_w_bgcolor($minimum, $satisfied); } } diff --git a/pinc/CharSuites.inc b/pinc/CharSuites.inc index eae5173c0..05e98d0b0 100644 --- a/pinc/CharSuites.inc +++ b/pinc/CharSuites.inc @@ -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( " diff --git a/pinc/DPage.inc b/pinc/DPage.inc index 0a53b65a1..0a63e0fd2 100644 --- a/pinc/DPage.inc +++ b/pinc/DPage.inc @@ -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'); @@ -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'); } diff --git a/pinc/MARCRecord.inc b/pinc/MARCRecord.inc index 0bc792006..874a23f64 100644 --- a/pinc/MARCRecord.inc +++ b/pinc/MARCRecord.inc @@ -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 @@ -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. @@ -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); } diff --git a/pinc/POFile.inc b/pinc/POFile.inc index 8db2c1a36..744cda911 100644 --- a/pinc/POFile.inc +++ b/pinc/POFile.inc @@ -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) { diff --git a/pinc/Project.inc b/pinc/Project.inc index 705d089ca..8415af491 100644 --- a/pinc/Project.inc +++ b/pinc/Project.inc @@ -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. @@ -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; @@ -1508,7 +1508,6 @@ class Project */ public function email_introduction(): string { - $projectid = $this->projectid; $title = $this->nameofwork; return implode("\n", [ @@ -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; diff --git a/pinc/ProjectSearchForm.inc b/pinc/ProjectSearchForm.inc index c2ed4ea47..de355cc68 100644 --- a/pinc/ProjectSearchForm.inc +++ b/pinc/ProjectSearchForm.inc @@ -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']; } diff --git a/pinc/ProjectSearchResults.inc b/pinc/ProjectSearchResults.inc index 814fbb286..8c7517f50 100644 --- a/pinc/ProjectSearchResults.inc +++ b/pinc/ProjectSearchResults.inc @@ -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(); } } diff --git a/pinc/ProjectTransition.inc b/pinc/ProjectTransition.inc index 6278221f4..c9b6c9571 100644 --- a/pinc/ProjectTransition.inc +++ b/pinc/ProjectTransition.inc @@ -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. diff --git a/pinc/RandomRule.inc b/pinc/RandomRule.inc index c1b617256..14cc837a4 100644 --- a/pinc/RandomRule.inc +++ b/pinc/RandomRule.inc @@ -213,7 +213,7 @@ class RandomRule if (preg_match('/^
    <\/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; @@ -223,7 +223,7 @@ class RandomRule if (preg_match('/

    (.*)<\/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]; diff --git a/pinc/TableDocumentation.inc b/pinc/TableDocumentation.inc index 747d4eb38..2aef6df53 100644 --- a/pinc/TableDocumentation.inc +++ b/pinc/TableDocumentation.inc @@ -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[] = ''; } @@ -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']; } @@ -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` @@ -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"; } @@ -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) { @@ -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) { diff --git a/pinc/autorelease.inc b/pinc/autorelease.inc index 1b2548a2e..5860a3c8b 100644 --- a/pinc/autorelease.inc +++ b/pinc/autorelease.inc @@ -215,7 +215,7 @@ function autorelease_for_round(Round $round): void echo " Released {$n_projects->released} {$qd->name} projects.\n"; } - AP_teardown($round); + AP_teardown(); echo "\n"; echo "Finished round {$round->id}\n"; @@ -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); diff --git a/pinc/bad_bytes.inc b/pinc/bad_bytes.inc index 771f2ad54..0e55aee3e 100644 --- a/pinc/bad_bytes.inc +++ b/pinc/bad_bytes.inc @@ -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;"; diff --git a/pinc/forum_interface_phpbb3.inc b/pinc/forum_interface_phpbb3.inc index e0c2b6f6b..9ce870973 100644 --- a/pinc/forum_interface_phpbb3.inc +++ b/pinc/forum_interface_phpbb3.inc @@ -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"); diff --git a/pinc/gettext_setup.inc b/pinc/gettext_setup.inc index 2007a3f1a..253509f48 100644 --- a/pinc/gettext_setup.inc +++ b/pinc/gettext_setup.inc @@ -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'; diff --git a/pinc/gradual.inc b/pinc/gradual.inc index 2e8d0ed61..6ebb4dfb1 100644 --- a/pinc/gradual.inc +++ b/pinc/gradual.inc @@ -73,8 +73,7 @@ function welcome_see_beginner_forum(int $pagesproofed, string $page_id, ?string echo "

    "; echo sprintf(_('Before you can begin proofreading, you must have:')); echo "

      "; - foreach ($uao->minima_table as $row) { - [$criterion_str, $minimum, $user_score, $satisfied] = $row; + foreach ($uao->minima_table as [$criterion_str, $_minimum, $_user_score, $_satisfied]) { echo "
    • $criterion_str
    • "; } echo "
    \n"; @@ -221,8 +220,7 @@ function maybe_output_new_proofer_project_message(Project $project): void echo "

    "; echo sprintf(_('Before you can begin proofreading, you must have:')); echo "

      "; - foreach ($uao->minima_table as $row) { - [$criterion_str, $minimum, $user_score, $satisfied] = $row; + foreach ($uao->minima_table as [$criterion_str, $_minimum, $_user_score, $_satisfied]) { echo "
    • $criterion_str
    • "; } echo "
    \n"; @@ -372,7 +370,7 @@ function encourage_highest_round(?string $username, ?string $round_id = null): v // except the quizzes (eg number of days and pages done), nudge them along. $ready_ignoring_quizzes = true; $quiz_requirements = []; - foreach ($uao->minima_table as $criterion_code => [$criterion_str, $minimum, $user_score, $satisfied]) { + foreach ($uao->minima_table as $criterion_code => [$_criterion_str, $_minimum, $_user_score, $satisfied]) { // skip checking any quiz criteria for pass if (str_starts_with($criterion_code, 'quiz/')) { $quiz_requirements[] = $criterion_code; diff --git a/pinc/graph_data.inc b/pinc/graph_data.inc index cccc3dc91..493a001fe 100644 --- a/pinc/graph_data.inc +++ b/pinc/graph_data.inc @@ -153,8 +153,6 @@ function user_logging_on(string $past, string $preceding): array */ function tallyboard_deltas(string $tally_name, string $holder_type, int $holder_id, string|int $days_back): array { - $valid_tally_names = array_keys(get_page_tally_names()); - $pages_per_day = get_pages_per_day_for_past_n_days($tally_name, $holder_type, $holder_id, $days_back); $datax = array_keys($pages_per_day); @@ -732,8 +730,6 @@ function _get_project_state_selector(string $which, array|string|null $desired_s $desired_states = [$desired_states]; } - $sql = ""; - // see if it's a round $round = get_Round_for_round_id($which); if ($round != null) { diff --git a/pinc/new_user_mails.inc b/pinc/new_user_mails.inc index efc707f27..6260216bb 100644 --- a/pinc/new_user_mails.inc +++ b/pinc/new_user_mails.inc @@ -53,14 +53,11 @@ function send_welcome_mail(string $email, string $real_name, string $username): $code_url = SiteConfig::get()->code_url; $site_name = SiteConfig::get()->site_name; - $site_abbreviation = SiteConfig::get()->site_abbreviation; $site_url = SiteConfig::get()->site_url; $general_help_email_addr = SiteConfig::get()->general_help_email_addr; $welcome = "Welcome to the $site_name Site!"; - $reset_password_url = get_reset_password_url(); - // SITE-SPECIFIC // Much of the contents of the email below is DP site-specific, however // not so much that it would be horrible for non-DP sites to use it without diff --git a/pinc/page_table.inc b/pinc/page_table.inc index 4f3a6cab6..3ae877bef 100644 --- a/pinc/page_table.inc +++ b/pinc/page_table.inc @@ -111,7 +111,7 @@ function fetch_page_table_data(Project $project, $page_selector = null, ?Round $ if ($round_ids_to_load_wordcheck_events) { $sql = sprintf( " - SELECT image, username, round_id, count(*) + SELECT image, username, round_id FROM wordcheck_events WHERE projectid = '%s' and round_id in (%s) GROUP BY image, username, round_id @@ -122,7 +122,7 @@ function fetch_page_table_data(Project $project, $page_selector = null, ?Round $ $res = DPDatabase::query($sql); $wordcheck_events = []; - while ([$image, $username, $round_id, $count] = mysqli_fetch_row($res)) { + while ([$image, $username, $round_id] = mysqli_fetch_row($res)) { $wordcheck_events["$image$username$round_id"] = 1; } } else { @@ -181,7 +181,6 @@ function fetch_page_table_data(Project $project, $page_selector = null, ?Round $ ON (users$rn.username = $round->user_column_name) $joined_with_user_page_tallies "; - $prev_text_column_name = $round->text_column_name; } if (is_null($page_selector)) { @@ -205,7 +204,6 @@ function fetch_page_table_data(Project $project, $page_selector = null, ?Round $ OR $work_round->user_column_name = '%s' ", DPDatabase::escape($username_for_selecting_pages)); } - $page_selector = null; } else { // $page_selector is an array whose keys are imagenames of the pages to select $imagenames_str = surround_and_join(array_keys($page_selector), "'", "'", ","); @@ -345,7 +343,7 @@ function echo_page_table( echo "{$td_start}"._("Page State")."{$td_end}"; - foreach ($rounds_to_display as $round) { + foreach ($rounds_to_display as $_) { echo "{$td_start}"._("Diff")."{$td_end}"; echo "{$td_start}"._("Date")."{$td_end}"; echo "{$td_start}"._("User")."{$td_end}"; diff --git a/pinc/page_tally.inc b/pinc/page_tally.inc index feb56edb3..346ef4730 100644 --- a/pinc/page_tally.inc +++ b/pinc/page_tally.inc @@ -519,7 +519,7 @@ function get_site_tally_cumulative_or_incremental( // if no data was returned from the SELECT, create an empty dataset if (empty($datax)) { // set arrays to empty before populating them - $datax = $datay1 = []; + $datay1 = []; $datay2 = null; // don't go past the current date diff --git a/pinc/post_files.inc b/pinc/post_files.inc index e9462942b..e9ccf4361 100644 --- a/pinc/post_files.inc +++ b/pinc/post_files.inc @@ -154,7 +154,7 @@ function get_page_texts(mysqli_result $pages_res): array { $page_texts = []; while (($row = page_info_fetch($pages_res)) !== false) { - [$page_text, $imagename, $proofer_names] = $row; + [$page_text, $_imagename, $_proofer_names] = $row; $page_texts[] = $page_text; } return $page_texts; @@ -169,7 +169,7 @@ function join_page_texts(mysqli_result $pages_res): string { $text = ""; while (($row = page_info_fetch($pages_res)) !== false) { - [$text_data, $filename, $proofer_names] = $row; + [$text_data, $_filename, $_proofer_names] = $row; $text .= $text_data . "\r\n"; } return $text; diff --git a/pinc/project_quick_check.inc b/pinc/project_quick_check.inc index 289cf2d0b..f3a789f03 100644 --- a/pinc/project_quick_check.inc +++ b/pinc/project_quick_check.inc @@ -19,7 +19,7 @@ function gate_on_pqc(string $projectid): void // loop thorugh results looking for errors $found_error = false; - foreach ($results as $function => $test_result) { + foreach ($results as $test_result) { if ($test_result->status == _("Error")) { $found_error = true; break; @@ -404,11 +404,6 @@ function _test_project_for_missing_pages(string $projectid): PQCResult { global $code_url; - $display_image_link = new_window_link( - "$code_url/tools/page_browser.php?project=$projectid&imagefile=001.png&showreturnlink=0&preload=next&percent=50", - _("Display Image") - ); - $test_name = _("Missing Pages"); $test_desc = sprintf( _("This manual test requires looking through each page of a project to see if there are missing pages. This is done by looking for missing page numbers, eg: image 100.png says it's page 80 and image 101.png says it's page 82. To perform this check, you can look at the pages online from the
    Page Details page or download the project files from the project page and check them offline. Please check to make sure all illustration images are also loaded."), diff --git a/pinc/send_mail.inc b/pinc/send_mail.inc index 5ef18c309..5e3a7b074 100644 --- a/pinc/send_mail.inc +++ b/pinc/send_mail.inc @@ -106,7 +106,6 @@ function send_mail(string $to, string $subject, string $message, ?string $from = function send_mail_project_manager(Project $project, string $info, string $prefix): bool { - $projectid = $project->projectid; $nameofwork = $project->nameofwork; $username = $project->username; configure_gettext_for_user($username); diff --git a/pinc/showavailablebooks.inc b/pinc/showavailablebooks.inc index a85c280ab..b0738dd95 100644 --- a/pinc/showavailablebooks.inc +++ b/pinc/showavailablebooks.inc @@ -501,8 +501,6 @@ function show_project_listing( // Show email addresses for site administrators $show_email = user_is_a_sitemanager(); - $rownum = 0; - while ($book = mysqli_fetch_assoc($result)) { echo ""; @@ -587,7 +585,6 @@ function show_project_listing( } echo "\n"; - $rownum++; } echo ""; @@ -708,8 +705,7 @@ function process_sorting_control( // Check column & convert to sql... // Find the entry in $columns whose $ext_sort_col matches $curr_ext_sort_col. - foreach ($columns as $col_id => $col_info) { - [$ext_sort_col, $label] = $col_info; + foreach ($columns as $col_id => [$ext_sort_col, $_label]) { if ($ext_sort_col == $curr_ext_sort_col) { $curr_sql_sort_col = $col_id; break; diff --git a/pinc/site_news.inc b/pinc/site_news.inc index 33b443767..d1c47a260 100644 --- a/pinc/site_news.inc +++ b/pinc/site_news.inc @@ -61,8 +61,6 @@ function show_news_for_page(string $news_page_id): void $user_locale = get_desired_language(); - $news_subject = get_news_subject($news_page_id); - // ------------------------------------------- // Get the set of 'current' news items defined for the given page. diff --git a/pinc/special_colors.inc b/pinc/special_colors.inc index a236ab16e..6b54fbe1a 100644 --- a/pinc/special_colors.inc +++ b/pinc/special_colors.inc @@ -176,7 +176,6 @@ function echo_special_legend(string $projects_where_clause): void // now append the hard-coded special day names $day_array = array_merge($day_array, array_values(load_common_special_days())); - $specs_count = count($day_array); echo "

    " . html_safe($legend_text) . "

    "; echo "

    " . _("View all Special Days") . "

    "; diff --git a/pinc/theme.inc b/pinc/theme.inc index 5d48358ef..c647dfbee 100644 --- a/pinc/theme.inc +++ b/pinc/theme.inc @@ -46,7 +46,7 @@ function output_header(string $nameofpage, bool $show_statsbar = false, array $e // * A 1% column with the rounded corner // * A 74% width column for the main page content, and return. echo "
    \n"; - html_statsbar($nameofpage); + html_statsbar(); echo "
    \n"; echo "
    \n"; echo "
    \n"; @@ -63,10 +63,10 @@ function output_header(string $nameofpage, bool $show_statsbar = false, array $e // Call output_footer when the main page content has been emitted so we can // close the table and emit the footer. - register_shutdown_function('output_footer', $nameofpage, $show_statsbar); + register_shutdown_function(output_footer(...), $show_statsbar); } -function output_footer(string $nameofpage, bool $show_statsbar = true): void +function output_footer(bool $show_statsbar = true): void { global $code_url, $PAGE_START_TIME; @@ -82,7 +82,7 @@ function output_footer(string $nameofpage, bool $show_statsbar = true): void // * A 25% width column with the stats bar in it echo "
    \n"; echo "
    \n"; - html_statsbar($nameofpage); + html_statsbar(); echo "
    \n"; } // Finally close the table, and emit the footer. @@ -531,7 +531,7 @@ function headerbar_text_array(array $entries): string return implode($divider, resolve_headerbar_entries($entries)); } -function html_statsbar(string $nameofpage): void +function html_statsbar(): void { global $code_url, $PG_home_url; maybe_show_language_selector(); diff --git a/pinc/unicode.inc b/pinc/unicode.inc index 42ede1ee0..cdc6a944b 100644 --- a/pinc/unicode.inc +++ b/pinc/unicode.inc @@ -492,7 +492,7 @@ function get_utf8_to_ascii_codepoints(): array function get_disallowed_codepoints(): array { $invalid_codepoints = []; - foreach (get_utf8_to_ascii_codepoints() as $ascii => $codepoints) { + foreach (get_utf8_to_ascii_codepoints() as $codepoints) { $invalid_codepoints = array_merge($invalid_codepoints, $codepoints); } return $invalid_codepoints; diff --git a/pinc/upload_file.inc b/pinc/upload_file.inc index 0a893e6e9..ad36137ae 100644 --- a/pinc/upload_file.inc +++ b/pinc/upload_file.inc @@ -109,7 +109,7 @@ function show_upload_form(string $form_content, string $submit_label): void

    ", get_big_upload_blurb(), "

    ", _("File to upload"), ": ", - "

    ", sprintf(_("After you click the '%s' button, the browser will appear to be slow getting to the next page. This is because it is uploading the file."), $submit_label), "

    ", + "

    ", $submit_blurb, "

    ", "
    "; // if resumable, these are shown instead diff --git a/pinc/user_project_info.inc b/pinc/user_project_info.inc index f5e46fed2..9ceda2b40 100644 --- a/pinc/user_project_info.inc +++ b/pinc/user_project_info.inc @@ -157,8 +157,7 @@ function set_user_project_event_subscription(string $username, string $projectid { assert($bit === 0 || $bit === 1); - $event_label = get_label_for_event($event); - // Just to ensure that $event is valid; we don't use $event_label. + get_label_for_event($event); // Just to ensure that $event is valid // Now that we're sure the row exists, we can update it. $sql = sprintf( @@ -176,13 +175,12 @@ function set_user_project_event_subscription(string $username, string $projectid $bit, $bit ); - $res = DPDatabase::query($sql); + DPDatabase::query($sql); } function user_is_subscribed_to_project_event(string $username, string $projectid, string $event): bool { - $event_label = get_label_for_event($event); - // Just to ensure that $event is valid; we don't use $event_label. + get_label_for_event($event); // Just to ensure that $event is valid $sql = sprintf( " @@ -315,7 +313,7 @@ function notify_project_event_subscribers(Project $project, string $event, array $n_subscribers, DPDatabase::escape($projectid) ); - $res4 = DPDatabase::query($sql4); + DPDatabase::query($sql4); } } diff --git a/pinc/wordcheck_engine.inc b/pinc/wordcheck_engine.inc index 40b1e029e..f74e193e3 100644 --- a/pinc/wordcheck_engine.inc +++ b/pinc/wordcheck_engine.inc @@ -394,7 +394,7 @@ function get_bad_words_via_external_checker($input_words_w_freq, $languages) // Now merge all misspellings by language script together $finalMisspellings = []; - foreach ($misspellings as $lang_script => $words) { + foreach ($misspellings as $words) { $finalMisspellings = array_merge($finalMisspellings, $words); } unset($misspellings); @@ -469,7 +469,7 @@ function get_bad_words_with_diacritical_markup($input_words_w_freq): array */ function get_bad_words_via_pattern($input_words_w_freq, $languages) { - [$langcode3s, $messages] = get_langcode3s_for_languages($languages); + [$langcode3s, $_messages] = get_langcode3s_for_languages($languages); $badWords = []; @@ -816,9 +816,7 @@ function load_project_good_word_suggestions(string $projectid, int $start_time = return $wordsArray; } - foreach ($eventArray as $event) { - [$time, $round, $page, $proofer, $words] = $event; - + foreach ($eventArray as [$_time, $round, $page, $_proofer, $words]) { if (count($words)) { if (!isset($wordsArray[$round][$page])) { $wordsArray[$round][$page] = []; @@ -836,7 +834,7 @@ function load_project_good_word_suggestions(string $projectid, int $start_time = function load_site_good_words_given_project(string $projectid): array { $languages = get_project_languages($projectid); - [$langcode3s, $messages] = get_langcode3s_for_languages($languages); + [$langcode3s, $_messages] = get_langcode3s_for_languages($languages); return load_site_good_words($langcode3s); } @@ -844,7 +842,7 @@ function load_site_good_words_given_project(string $projectid): array function load_site_bad_words_given_project(string $projectid): array { $languages = get_project_languages($projectid); - [$langcode3s, $messages] = get_langcode3s_for_languages($languages); + [$langcode3s, $_messages] = get_langcode3s_for_languages($languages); return load_site_bad_words($langcode3s); } @@ -852,7 +850,7 @@ function load_site_bad_words_given_project(string $projectid): array function load_site_possible_bad_words_given_project(string $projectid): array { $languages = get_project_languages($projectid); - [$langcode3s, $messages] = get_langcode3s_for_languages($languages); + [$langcode3s, $_messages] = get_langcode3s_for_languages($languages); return load_site_possible_bad_words($langcode3s); } @@ -1274,7 +1272,6 @@ function get_all_words_in_text(string $text, bool $with_offsets = false) if ($with_offsets) { $result = []; foreach ($matches[0] as [$word, $offset_bytes]) { - $search_offset = 0; // offsets from preg_match_all() are in bytes, but we need the // offset in characters $offset = UTF8::strlen(substr($text, 0, $offset_bytes)); diff --git a/project.php b/project.php index f8cc36cab..7863c0834 100644 --- a/project.php +++ b/project.php @@ -596,7 +596,6 @@ function do_project_info_table(): void if ($detail_level >= 4) { // We'll call do_page_table later, so we don't need the "Page Detail" link. } else { - $detail = ""; if ($project->pages_table_exists) { $url = "$code_url/tools/project_manager/page_detail.php?project=$projectid&show_image_size=0"; $blurb = html_safe(_("Images, Pages Proofread, & Differences")); @@ -670,8 +669,6 @@ function do_project_info_table(): void // -------- - $comments = $project->comments; - // insert e.g. templates and biographies $comments = parse_project_comments($project); @@ -1114,7 +1111,7 @@ function do_holds(): void echo "\n"; $disabled = $project->can_be_managed_by_current_user ? '' : 'disabled'; - foreach (array_chunk(Project::get_holdable_states(), 2) as $set => $states) { + foreach (array_chunk(Project::get_holdable_states(), 2) as $states) { [$round_id] = explode(".", $states[0]); echo "\n"; echo "", $round_id, "\n"; @@ -2020,15 +2017,10 @@ function do_change_state(): void // This can leave an extra &, but I suspect browsers can handle it. foreach ($valid_transitions as $transition) { - // Used for disabling the button - $optional_btn_attr = ""; - // By default say who is allowed to do this transition. $text_next_to_btn = " [$transition->who_restriction]"; if ($transition->is_disabled($project)) { - $optional_btn_attr = "disabled"; - // Gray out the original text and add an explanation why it is disabled $reason = $transition->why_disabled($project); $text_next_to_btn = "$text_next_to_btn [$reason]"; @@ -2055,7 +2047,6 @@ function do_change_state(): void function do_page_summary(): void { global $project; - $projectid = $project->projectid; if (!$project->pages_table_exists) { return; diff --git a/quiz/generic/wizard/output.php b/quiz/generic/wizard/output.php index b4e292239..7579dac10 100644 --- a/quiz/generic/wizard/output.php +++ b/quiz/generic/wizard/output.php @@ -128,7 +128,7 @@ function make_output(): string } $out .= "\n\n"; $out .= "// error checks\n\n"; - foreach ($_SESSION['quiz_data']['tests'] as $key => $test) { + foreach ($_SESSION['quiz_data']['tests'] as $test) { $out .= '$tests[] = array("type" => "' . $test['type'] .'"'; if ($test['type'] == 'multioccurrence') { $out .= ', "searchtext" => "' . ssqs(sdbsn($test['searchtext'])) .'", "case_sensitive" => '; diff --git a/stats/includes/member.inc b/stats/includes/member.inc index c752f91f5..5bc55c37e 100644 --- a/stats/includes/member.inc +++ b/stats/includes/member.inc @@ -506,7 +506,7 @@ function showMbrNeighbors(User $user, string $tally_name): void $user, max($user->u_neigh, 4) ); - foreach ($neighbors as $rel_posn => $neighbor) { + foreach ($neighbors as $neighbor) { $rank = $neighbor->current_page_tally_rank; $pagescompleted = number_format($neighbor->current_page_tally); diff --git a/stats/misc_stats1.php b/stats/misc_stats1.php index 6f481f627..2f20a07ac 100644 --- a/stats/misc_stats1.php +++ b/stats/misc_stats1.php @@ -96,7 +96,6 @@ function show_top_days(int $limit, string $when): void switch ($when) { case 'ever': - $where = ''; $sub_title = sprintf(_('Top %d Proofreading Days Ever'), $limit); break; diff --git a/tasks.php b/tasks.php index c044da2c2..250b73658 100644 --- a/tasks.php +++ b/tasks.php @@ -1643,7 +1643,7 @@ function insert_related_task(int $task1, int $task2): void $task_id_1, $task_id_2 ); - $result = DPDatabase::query($sql); + DPDatabase::query($sql); } function remove_related_task(int $task1, int $task2): void @@ -1661,7 +1661,7 @@ function remove_related_task(int $task1, int $task2): void $task_id_1, $task_id_2 ); - $result = DPDatabase::query($sql); + DPDatabase::query($sql); } function RelatedPostings(int $tid): void diff --git a/tools/project_manager/add_files.php b/tools/project_manager/add_files.php index f08890729..30226d828 100644 --- a/tools/project_manager/add_files.php +++ b/tools/project_manager/add_files.php @@ -274,7 +274,7 @@ public function analyze(): void } foreach (array_keys($db_entries) as $db_image_file) { - [$base, $ext] = split_filename($db_image_file); + [$base, $_ext] = split_filename($db_image_file); $page_related_bases[$base] = 1; } @@ -289,7 +289,7 @@ public function analyze(): void $page_files = []; $this->non_page_files = []; foreach ($loadable_files as $loadable_file) { - [$base, $ext] = split_filename($loadable_file); + [$base, $_ext] = split_filename($loadable_file); if (array_key_exists($base, $page_related_bases)) { $page_files[] = $loadable_file; } else { @@ -536,7 +536,7 @@ public function _check_file(string $filename): string $ALLOWED_EXTENSIONS = ['.txt', '.png', '.jpg']; - [$base, $ext] = split_filename($filename); + [$_base, $ext] = split_filename($filename); if (!in_array($ext, $ALLOWED_EXTENSIONS)) { return _('filename has unrecognized suffix'); } diff --git a/tools/project_manager/bad_bytes_explainer.php b/tools/project_manager/bad_bytes_explainer.php index b6193d502..7efa0d362 100644 --- a/tools/project_manager/bad_bytes_explainer.php +++ b/tools/project_manager/bad_bytes_explainer.php @@ -159,8 +159,7 @@ function show_a_table_of_bads(string $desired_badness): void "; global $_bad_byte_sequences; - foreach ($_bad_byte_sequences as $raw => $remarks) { - [$code_point, $why_bad] = $remarks; + foreach ($_bad_byte_sequences as $raw => [$_code_point, $why_bad]) { if (str_starts_with($desired_badness, '/')) { $matches = preg_match($desired_badness, $why_bad); } else { diff --git a/tools/project_manager/diff.php b/tools/project_manager/diff.php index db2c60216..59e50b9db 100644 --- a/tools/project_manager/diff.php +++ b/tools/project_manager/diff.php @@ -335,7 +335,6 @@ function can_see_names_for_page(string $projectid, string $image): bool function can_navigate_by_proofer(string $projectid, string $L_user): bool { global $pguser; - $answer = false; // If user isn't logged in, they definitely can't if ($pguser == '') { return false; diff --git a/tools/project_manager/editproject.php b/tools/project_manager/editproject.php index 4e6e8007c..6bb4283fd 100644 --- a/tools/project_manager/editproject.php +++ b/tools/project_manager/editproject.php @@ -480,7 +480,6 @@ public function show_visible_controls(): void $can_set_difficulty_tofrom_beginner = ($pguser == "BEGIN") || user_is_a_sitemanager(); $can_edit_PPer = true; - $is_checked_out = false; if (!empty($this->project->projectid)) { $this->row(_("Project ID"), html_safe($this->project->projectid)); @@ -490,12 +489,10 @@ public function show_visible_controls(): void } elseif ($this->project->state == PROJ_POST_FIRST_CHECKED_OUT) { // once the project is in PP, PPer can only be changed by an SA, PF, // or if it's checked out to the PM - $is_checked_out = true; $can_edit_PPer = (($this->project->username == $this->project->checkedoutby) || user_is_a_sitemanager() || user_is_proj_facilitator()); } elseif ($this->project->state == PROJ_POST_SECOND_CHECKED_OUT) { - $is_checked_out = true; $can_edit_PPer = user_is_a_sitemanager(); } } diff --git a/tools/project_manager/handle_bad_page.php b/tools/project_manager/handle_bad_page.php index 9f39146d5..ff935bf8a 100644 --- a/tools/project_manager/handle_bad_page.php +++ b/tools/project_manager/handle_bad_page.php @@ -305,7 +305,6 @@ function update_image(string $projectid, string $image): void global $projects_dir; $org_image_ext = substr($image, -4); - $org_image_basename = basename($image, $org_image_ext); $tmp_image_ext = substr($_FILES['image_upload']['name'], -4); if ($tmp_image_ext == ".png" || $tmp_image_ext == ".jpg") { diff --git a/tools/project_manager/show_current_flagged_words.php b/tools/project_manager/show_current_flagged_words.php index 4054498d2..2a692f1bf 100644 --- a/tools/project_manager/show_current_flagged_words.php +++ b/tools/project_manager/show_current_flagged_words.php @@ -139,14 +139,12 @@ /** @return list{array, string[]} */ function _get_current_flagged_word_list(string $projectid): array { - $messages = []; - // get the latest project text of all pages up to last possible round $pages_res = page_info_query($projectid, Rounds::get_last()->id, 'LE'); $page_texts = get_page_texts($pages_res); // now run it through WordCheck - [$bad_words_w_freq, $languages, $messages] = + [$bad_words_w_freq, $_languages, $messages] = get_bad_word_freqs_for_project_text($page_texts, $projectid, get_project_languages($projectid)); // multisort screws up all-numeric words so we need to preprocess first diff --git a/tools/project_manager/show_good_word_suggestions.php b/tools/project_manager/show_good_word_suggestions.php index 0acdead66..f9912f8d6 100644 --- a/tools/project_manager/show_good_word_suggestions.php +++ b/tools/project_manager/show_good_word_suggestions.php @@ -277,7 +277,7 @@ function _get_suggestions_word_list(string $projectid, int $timeCutoff): array // it is in the format: $suggestions[$round][$pagenum]=$wordsArray foreach ($suggestions as $round => $pageArray) { $round_suggestions = []; - foreach ($pageArray as $page => $words) { + foreach ($pageArray as $words) { // add the words to the per-round array $round_suggestions = array_merge($round_suggestions, $words); diff --git a/tools/project_manager/show_project_stealth_scannos.php b/tools/project_manager/show_project_stealth_scannos.php index 44b0e0dac..2061658ce 100644 --- a/tools/project_manager/show_project_stealth_scannos.php +++ b/tools/project_manager/show_project_stealth_scannos.php @@ -178,8 +178,6 @@ function _get_stealth_scanno_word_list(string $projectid): array $ocr_filename = "$temp_dir/{$projectid}_ocr.txt"; $latest_filename = "$temp_dir/{$projectid}_latest.txt"; - $messages = []; - // get the OCR text // Note: If the code is changed to allow selecting of arbitrary round text // instead of just the OCR round, edit_project_word_lists.php should @@ -308,7 +306,7 @@ function _get_stealth_scanno_word_list(string $projectid): array $text_to_check = implode(" ", $possible_scannos); // run the list through WordCheck to see which it would flag - [$possible_scannos_via_wordcheck, $languages, $messages] = + [$possible_scannos_via_wordcheck, $_languages, $messages] = get_bad_word_freqs_for_project_text($text_to_check, $projectid, get_project_languages($projectid)); // load site words diff --git a/tools/project_manager/word_freq_table.inc b/tools/project_manager/word_freq_table.inc index d0ebd44d9..65c70fcb2 100644 --- a/tools/project_manager/word_freq_table.inc +++ b/tools/project_manager/word_freq_table.inc @@ -296,7 +296,7 @@ function _get_word_context_from_text(string $page_text, string $contextWord): ar $lineNum = 1; foreach ($lines as $line) { $words = get_all_words_in_text($line, true); - foreach ($words as $offset => $word) { + foreach ($words as $word) { if ($word === $contextWord) { $contexts[$lineNum] = $line; } diff --git a/tools/proofers/my_suggestions.php b/tools/proofers/my_suggestions.php index 217462c3c..104e89e67 100644 --- a/tools/proofers/my_suggestions.php +++ b/tools/proofers/my_suggestions.php @@ -18,7 +18,7 @@ } } -$round_view_options = get_view_options($username); +$round_view_options = get_view_options(); // Get changes to the round views. If not set, we // pull the last selected option from UserSettings. @@ -84,7 +84,7 @@ echo "

    $explain_why

    "; } - output_suggestion_table($projects, $colspecs, $username); + output_suggestion_table($projects, $colspecs); } if ($verbose) { @@ -162,7 +162,7 @@ function get_table_column_specs(): array // to make sure that some projects are displayed, iterate over the view order /** @return array */ -function get_view_options(string $username): array +function get_view_options(): array { return [ "impact" => [ @@ -213,19 +213,15 @@ function show_page_menu(array $all_view_modes, string $round_view, string $usern } /** @param array $colspecs */ -function show_headings(array $colspecs, string $username): void +function show_headings(array $colspecs): void { echo "\n"; - foreach ($colspecs as $col_id => $colspec) { + foreach ($colspecs as $colspec) { $class = ''; if (isset($colspec['class'])) { $class = sprintf("class='%s'", $colspec['class']); } echo ""; - $qs_username = ""; - if ($username != User::current_username()) { - $qs_username = "username=" . urlencode($username) . '&'; - } echo $colspec['label']; echo ""; } @@ -236,13 +232,13 @@ function show_headings(array $colspecs, string $username): void * @param array[] $projects * @param array $colspecs */ -function output_suggestion_table(array $projects, array $colspecs, string $username): void +function output_suggestion_table(array $projects, array $colspecs): void { global $code_url; echo ""; - show_headings($colspecs, $username); + show_headings($colspecs); foreach ($projects as $row) { echo "\n"; diff --git a/tools/proofers/preview.inc b/tools/proofers/preview.inc index 9d31406f1..ace79cbba 100644 --- a/tools/proofers/preview.inc +++ b/tools/proofers/preview.inc @@ -7,13 +7,10 @@ function output_preview_div(): void $quit = attr_safe(_("Quit")); $configure = attr_safe(_("Configure")); - $add_font = attr_safe(_("Add Font")); - $remove_font = attr_safe(_("Remove Font")); $ok = attr_safe(_("OK")); $cancel = attr_safe(_("Cancel")); $some_suppressed = attr_safe(_('Some warnings are suppressed')); $color_markup = html_safe(_("Color markup")); - $image = html_safe(_("Image")); $text = html_safe(_("Text")); $font = html_safe(_("Font")); $tags = html_safe(_("Tags")); @@ -21,12 +18,10 @@ function output_preview_div(): void $re_wrap = html_safe(_("Re-wrap")); $issues = html_safe(_("Issues")); $poss_iss = html_safe(_("Poss. Issues")); - $other_tags = html_safe(_("Other tags")); $allow_underine = html_safe(_("Allow for underline")); $math_preview = html_safe(_("Preview Math")); $suppress_warnings = html_safe(_('Suppress warnings')); $choose_colors = html_safe(_("Choose Colors")); - $select = html_safe(_("Select")); $options = html_safe(_("Options")); $initial_mode = html_safe(_("Initial view mode")); $char_before_start = html_safe(_("Character or punctuation before inline start tag")); diff --git a/tools/proofers/proof_frame_enh.inc b/tools/proofers/proof_frame_enh.inc index 5f8e0f7fa..4f3f8a28d 100644 --- a/tools/proofers/proof_frame_enh.inc +++ b/tools/proofers/proof_frame_enh.inc @@ -89,7 +89,6 @@ function echo_proof_frame_enh(PPage $ppage): void function echo_button_menu(PPage $ppage): void { - $user = User::load_current(); $proofreading_font_faces = get_available_proofreading_font_faces(); $proofreading_font_sizes = get_available_proofreading_font_sizes(); $font_family_fallback = get_proofreading_font_family_fallback(); diff --git a/tools/proofers/spellcheck_text.inc b/tools/proofers/spellcheck_text.inc index 4fa1a7424..be272b770 100644 --- a/tools/proofers/spellcheck_text.inc +++ b/tools/proofers/spellcheck_text.inc @@ -20,8 +20,6 @@ use voku\helper\UTF8; * Original text to run through dictionary * @param string $projectid * Id of projected, needed for temp filename and to load the custom dictionaries - * @param string $imagefile - * Image filename, needed for temp filename * @param string[] $languages * Languages to check against * @param string[] $accepted_words @@ -29,7 +27,7 @@ use voku\helper\UTF8; * * @return list{string, string[], string[], array} */ -function spellcheck_text(string $orig_text, string $projectid, string $imagefile, array $languages, array $accepted_words): array +function spellcheck_text(string $orig_text, string $projectid, array $languages, array $accepted_words): array { global $puncCharacters; @@ -71,7 +69,7 @@ function spellcheck_text(string $orig_text, string $projectid, string $imagefile // Prepare the style block which requires some dynamic content from // the user's preferences and the page itself. - [$font_style, $font_size, $font_family] = get_user_proofreading_font(); + [$_font_style, $font_size, $font_family] = get_user_proofreading_font(); if ($font_size != '') { $font_size = "font-size: $font_size"; } else { @@ -114,7 +112,7 @@ function spellcheck_text(string $orig_text, string $projectid, string $imagefile $newLine = $origLine; - $lineIndex = $indexArray = []; + $indexArray = []; // find the index for each punctuation for ($lineIndex = 0; $lineIndex < UTF8::strlen($origLine); $lineIndex++) { @@ -333,7 +331,7 @@ function spellcheck_apply_corrections(): array continue; } // hidden values line|offset|word length - [$orig_line_i, $orig_word_offset, $orig_word_length] = + [$orig_line_i, $orig_word_offset, $_orig_word_length] = explode('|', $_POST['posit'.$i]); if (!isset($offsetList[$orig_line_i])) { @@ -430,7 +428,7 @@ function output_wordcheck_interface(User $user, PPage $ppage, string $text_data, // run the text through the spellcheck - returns the form contents and a list of languages the page was checked against [$page_contents, $languages, $messages, $highlights] = - spellcheck_text($text_data, $ppage->projectid(), $ppage->imagefile(), $languages, $accepted_words); + spellcheck_text($text_data, $ppage->projectid(), $languages, $accepted_words); if (!$languages) { $messages[] = _("No check against a dictionary has been made."); @@ -493,7 +491,7 @@ function output_wordcheck_interface(User $user, PPage $ppage, string $text_data, // get a list of languages with dictionaries installed on the system $dict_list = get_languages_with_dictionaries(); asort($dict_list); - foreach ($dict_list as $langcode => $language) { + foreach ($dict_list as $language) { // skip the languages that we just used. if (in_array($language, $languages)) { continue; diff --git a/tools/site_admin/copy_pages.php b/tools/site_admin/copy_pages.php index 4d00db0fd..13661ec02 100644 --- a/tools/site_admin/copy_pages.php +++ b/tools/site_admin/copy_pages.php @@ -49,7 +49,6 @@ case 'showform': display_copy_pages_form( $projectid_, - $from_image_, $transfer_notifications, $add_deletion_reason, $merge_wordcheck_data, @@ -62,7 +61,6 @@ case 'showagain': display_copy_pages_form( $projectid_, - $from_image_, $transfer_notifications, $add_deletion_reason, $merge_wordcheck_data, @@ -146,11 +144,9 @@ /** * @param array{from: string, to: string} $projectid_ - * @param array{lo: string, hi: string} $from_image_ */ function display_copy_pages_form( ?array $projectid_, - ?array $from_image_, bool $transfer_notifications, bool $add_deletion_reason, bool $merge_wordcheck_data, @@ -458,7 +454,6 @@ function ($a, $b) { // The c_ prefix means that it only pertains to *copied* pages. $c_src_image_ = []; - $c_src_fileid_ = []; $c_dst_image_ = []; $c_dst_fileid_ = []; @@ -469,7 +464,6 @@ function ($a, $b) { $c_dst_image = $c_src_image; $c_src_image_[] = $c_src_image; - $c_src_fileid_[] = $c_src_fileid; $c_dst_image_[] = $c_dst_image; $c_dst_fileid_[] = $c_dst_fileid; } @@ -585,7 +579,6 @@ function ($a, $b) { for ($j = 0; $j < $n_pages_to_copy; $j++) { $c_src_image = $c_src_image_[$j]; - $c_src_fileid = $c_src_fileid_[$j]; $c_dst_image = $c_dst_image_[$j]; $c_dst_fileid = $c_dst_fileid_[$j]; diff --git a/tools/site_admin/delete_pages.php b/tools/site_admin/delete_pages.php index c79b5796c..13c7d5263 100644 --- a/tools/site_admin/delete_pages.php +++ b/tools/site_admin/delete_pages.php @@ -129,7 +129,7 @@ function delete_pages(?string $projectid, ?array $from_image_, bool $just_checki validate_projectID($projectid); $res = DPDatabase::query(" - SELECT image, fileid + SELECT image FROM $projectid ORDER BY image "); @@ -143,7 +143,7 @@ function delete_pages(?string $projectid, ?array $from_image_, bool $just_checki } $all_image_values = []; - while ([$image, $fileid] = mysqli_fetch_row($res)) { + while ([$image] = mysqli_fetch_row($res)) { $all_image_values[] = $image; } diff --git a/tools/site_admin/manage_site_access_privileges.php b/tools/site_admin/manage_site_access_privileges.php index 76a8aa5c6..71a0d8aa2 100644 --- a/tools/site_admin/manage_site_access_privileges.php +++ b/tools/site_admin/manage_site_access_privileges.php @@ -156,8 +156,6 @@ function update_settings(User $user, Settings $user_settings): void { global $boolean_user_settings, $value_user_settings, $freeform_user_settings, $pguser; - $username = $user->username; - $disposition = [ 'turn on' => [], 'turn off' => [], diff --git a/tools/site_admin/manage_site_word_lists.php b/tools/site_admin/manage_site_word_lists.php index ffde14043..a1620bef7 100644 --- a/tools/site_admin/manage_site_word_lists.php +++ b/tools/site_admin/manage_site_word_lists.php @@ -216,7 +216,7 @@ function manage_site_word_lists_handle_action($action, $list_type, $language, $w // save the list if requested // if the $site_words_dir doesn't exist already, create it - [$site_words_dir, $site_words_url] = get_site_word_paths(); + [$site_words_dir, $_site_words_url] = get_site_word_paths(); if (!is_dir($site_words_dir) && !mkdir($site_words_dir)) { throw new RuntimeException(sprintf(_("Unable to create site word list dir %s"), $site_words_dir)); } diff --git a/tools/site_admin/rename_pages.php b/tools/site_admin/rename_pages.php index 9cfaa4dc7..9dd65ec02 100644 --- a/tools/site_admin/rename_pages.php +++ b/tools/site_admin/rename_pages.php @@ -517,9 +517,7 @@ function get_requested_name_mapping(): array die("nff_ param is empty"); } - foreach ($nff_ as $k => $part_new_fileid_for_) { - // (Ignore $k, it doesn't convey any useful information.) - + foreach ($nff_ as $part_new_fileid_for_) { foreach ($part_new_fileid_for_ as $old_fileid => $new_fileid) { assert(!isset($new_fileid_for_[$old_fileid])); $new_fileid_for_[$old_fileid] = $new_fileid; diff --git a/tools/site_admin/show_common_words_from_project_word_lists.php b/tools/site_admin/show_common_words_from_project_word_lists.php index e37b8c841..88c1d56e7 100644 --- a/tools/site_admin/show_common_words_from_project_word_lists.php +++ b/tools/site_admin/show_common_words_from_project_word_lists.php @@ -132,7 +132,6 @@ function _handle_action($action, $list_type, $language, $cutoff, $lang_match) $total_projects_with_words = 0; // figure out what kind of language matching we're going to use - $where_clause = ""; switch ($lang_match) { case "exact": $where_clause = "language = '$language'"; diff --git a/tools/site_search.php b/tools/site_search.php index 18b8bb4eb..b67359757 100644 --- a/tools/site_search.php +++ b/tools/site_search.php @@ -160,7 +160,7 @@ function get_prefix_searches(bool $flatten_aliases = false): array } if ($flatten_aliases) { - foreach ($prefix_searches as $key => &$data) { + foreach ($prefix_searches as &$data) { if (isset($data["alias"])) { $alias = $data["alias"]; unset($data["alias"]); @@ -262,7 +262,7 @@ function get_jump_words(bool $flatten_aliases = false): array } if ($flatten_aliases) { - foreach ($jump_words as $key => &$data) { + foreach ($jump_words as &$data) { if (isset($data["alias"])) { $alias = $data["alias"]; unset($data["alias"]); diff --git a/userprefs.php b/userprefs.php index 7d70a62b1..6ffba3d56 100644 --- a/userprefs.php +++ b/userprefs.php @@ -76,7 +76,7 @@ } elseif ($selected_tab == 1) { save_proofreading_tab($user); } elseif ($selected_tab == 2) { - save_pm_tab($user); + save_pm_tab(); } if (isset($_POST["saveAndQuit"]) || isset($_POST["mkProfileAndQuit"])) { @@ -201,7 +201,7 @@ function do_font_sample_update(font_index, size_index, layout) { if ($selected_tab == 1) { echo_proofreading_tab($user); } elseif ($selected_tab == 2 && user_is_PM()) { - echo_pm_tab($user); + echo_pm_tab(); } else { // $selected _tab == 0 OR someone tried to access e.g. the PM-tab without being a PM. echo_general_tab($user); } @@ -512,7 +512,6 @@ function echo_proofreading_tab(User $user): void ); echo "\n"; - $proofreading_font_faces = get_available_proofreading_font_faces(); echo "\n"; show_preference( _('Font Face'), @@ -727,7 +726,7 @@ function save_proofreading_tab(User $user): void } } -function echo_pm_tab(User $user): void +function echo_pm_tab(): void { global $userSettings; @@ -779,7 +778,7 @@ function echo_pm_tab(User $user): void echo_bottom_button_row(); } -function save_pm_tab(User $user): void +function save_pm_tab(): void { global $userSettings;