Skip to content

Commit

Permalink
[2/n] Remove array_get
Browse files Browse the repository at this point in the history
The function cannot be properly typed as it
is and fixing this would take a while, removing
it is shorter and better.

The change updates quiz/* and stats/*.

TESTS=Opened and submitted a quiz, tried some stats pages.
  • Loading branch information
jchaffraix authored and cpeel committed Nov 29, 2024
1 parent 0ba5dc0 commit d7bb899
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion quiz/generic/returnfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require_login();

$quiz_page_id = get_quiz_page_id_param($_REQUEST, 'quiz_page_id');
$text = array_get($_POST, 'text_data', '');
$text = $_POST['text_data'] ?? '';

include "./quiz_page.inc"; // qp_*

Expand Down
2 changes: 1 addition & 1 deletion quiz/start.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

$username = $pguser;
if (user_is_a_sitemanager() || user_is_proj_facilitator()) {
$username = array_get($_GET, 'username', $pguser);
$username = $_GET['username'] ?? $pguser;
if (!User::is_valid_user($username)) {
die("Invalid username.");
}
Expand Down
4 changes: 2 additions & 2 deletions stats/members/mbr_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
['asc', 'desc']
);
$mstart = get_integer_param($_GET, 'mstart', 0, 0, null);
$uname = normalize_whitespace(array_get($_GET, 'uname', array_get($_GET, 'username', '')));
$uexact = array_get($_GET, 'uexact', '') == 'yes';
$uname = normalize_whitespace($_GET['uname'] ?? ($_GET['username'] ?? ''));
$uexact = ($_GET['uexact'] ?? '') == 'yes';

if ($uname) {
if ($uexact) {
Expand Down
10 changes: 5 additions & 5 deletions stats/teams/new_team.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

$theme_extra_args = ["js_data" => get_newHelpWin_javascript("$code_url/pophelp.php?category=teams&name=edit_")];

$teamname = trim(array_get($_POST, "teamname", ""));
$text_data = stripAllString(array_get($_POST, "text_data", ""));
$teamwebpage = array_get($_POST, "teamwebpage", "");
$tavatar = array_get($_POST, "tavatar", "");
$ticon = array_get($_POST, "ticon", "");
$teamname = trim($_POST["teamname"] ?? "");
$text_data = stripAllString($_POST["text_data"] ?? "");
$teamwebpage = $_POST["teamwebpage"] ?? "";
$tavatar = $_POST["tavatar"] ?? "";
$ticon = $_POST["ticon"] ?? "";


if (isset($_POST['mkPreview'])) {
Expand Down
10 changes: 5 additions & 5 deletions stats/teams/tedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
if (!isset($tid)) {
$tid = get_integer_param($_GET, 'tid', null, 1, null);
}
$teamname = stripAllString(trim(array_get($_POST, "teamname", "")));
$text_data = stripAllString(array_get($_POST, "text_data", ""));
$teamwebpage = stripAllString(array_get($_POST, "teamwebpage", ""));
$tavatar = array_get($_POST, "tavatar", "");
$ticon = array_get($_POST, "ticon", "");
$teamname = stripAllString(trim($_POST["teamname"] ?? ""));
$text_data = stripAllString($_POST["text_data"] ?? "");
$teamwebpage = stripAllString($_POST["teamwebpage"] ?? "");
$tavatar = $_POST["tavatar"] ?? "";
$ticon = $_POST["ticon"] ?? "";

$result = select_from_teams("id = $tid");
$curTeam = mysqli_fetch_assoc($result);
Expand Down
4 changes: 2 additions & 2 deletions stats/teams/tlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
['asc', 'desc']
);
$tstart = get_integer_param($_GET, 'tstart', 0, 0, null);
$tname = normalize_whitespace(array_get($_GET, 'tname', ''));
$texact = array_get($_GET, 'texact', '') == 'yes';
$tname = normalize_whitespace($_GET['tname'] ?? '');
$texact = ($_GET['texact'] ?? '') == 'yes';

if ($tname) {
if ($texact) {
Expand Down

0 comments on commit d7bb899

Please sign in to comment.