Skip to content

Commit

Permalink
Php8fixes 202401 (#1026)
Browse files Browse the repository at this point in the history
* remove deprecated ini_set call

* stop possible warning

* avoid warning

* avoid warning

* cast to int

* avoid warning on existing being null

* force template to be an integer

* suppress warnings

* check on valid var and cast to int

* give buttons an ID, so they can be targetted with testing

* avoid warning on empty array index
  • Loading branch information
michield authored Mar 30, 2024
1 parent 3cf5693 commit f0443c3
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 28 deletions.
1 change: 0 additions & 1 deletion public_html/lists/admin/CsvReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CsvReader
*/
public function __construct($filename, $delimiter)
{
ini_set('auto_detect_line_endings', true);
$this->fh = fopen($filename, 'r');
$this->delimiter = $delimiter;
$this->totalRows = 0;
Expand Down
11 changes: 6 additions & 5 deletions public_html/lists/admin/actions/import1.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
if (!is_email($email) && $omit_invalid) {
unset($email, $info);
$count_invalid_emails++;
} else {
//# actually looks like the "info" bit will get lost, but
//# in a way, that doesn't matter
$user_list[$email] = array(
'info' => $info,
);
}
//# actually looks like the "info" bit will get lost, but
//# in a way, that doesn't matter
$user_list[$email] = array(
'info' => $info,
);
}

$count_email_add = 0;
Expand Down
6 changes: 3 additions & 3 deletions public_html/lists/admin/actions/listmembercount.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ function listMemberCounts($listId)
.'<span class="unconfirmedCount text-warning" title="%s">%s</span>, '.' '
.'<span class="blacklistedCount text-danger" title="%s">%s</span>'.')',
s('Confirmed and not blacklisted members'),
number_format($counts['confirmed']),
number_format(!empty($counts['confirmed']) ? $counts['confirmed'] : 0),
s('Unconfirmed and not blacklisted members'),
number_format($counts['notconfirmed']),
number_format(!empty($counts['notconfirmed']) ? $counts['notconfirmed'] : 0),
s('Blacklisted members'),
number_format($counts['blacklisted'])
number_format(!empty($counts['blacklisted']) ? $counts['blacklisted'] : 0)
);

return $membersDisplay;
Expand Down
4 changes: 2 additions & 2 deletions public_html/lists/admin/import1.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
if (count($email_list) > 300 && !$test_import) {
// this is a possibly a time consuming process, so lets show a progress bar
flush();
// increase the memory to make sure we are not running out
ini_set('memory_limit', '16M');
// try to increase the memory to make sure we are not running out
@ini_set('memory_limit', '16M');
}

// View test output of emails
Expand Down
21 changes: 13 additions & 8 deletions public_html/lists/admin/import2.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,21 @@
//@@ Why is $attributes not used
$query = sprintf('select id from %s where name = "%s"', $tables['attribute'], sql_escape($column));
$existing = Sql_Fetch_Row_Query($query);
$_SESSION['import_attribute'][$column] = array(
'index' => $i,
'record' => $existing[0],
'column' => $column,
);
array_push($used_attributes, $existing[0]);
if ($existing[0]) {
if (!empty($existing[0])) {
// $dbg .= " =known attribute id=" . $existing[0];
} else {
$_SESSION['import_attribute'][$column] = array(
'index' => $i,
'record' => $existing[0],
'column' => $column,
);
array_push($used_attributes, $existing[0]);
} else {
// $dbg .= " =request mapping";
$_SESSION['import_attribute'][$column] = array(
'index' => $i,
'record' => "",
'column' => $column,
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions public_html/lists/admin/inc/userlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function addNewUser($email, $password = '')
// insert into user db
$exists = Sql_Fetch_Row_Query(sprintf('select id from %s where email = "%s"',
$GLOBALS['tables']['user'], $email));
if ($exists[0]) {
if (!empty($exists[0])) {
return $exists[0];
}

Expand Down Expand Up @@ -840,7 +840,7 @@ function addUserHistory($email, $msg, $detail)
}

$userid = Sql_Fetch_Row_Query("select id from $user_table where email = \"$email\"");
if ($userid[0]) {
if (!empty($userid[0])) {
Sql_Query(sprintf('insert into %s (ip,userid,date,summary,detail,systeminfo)
values("%s",%d,now(),"%s","%s","%s")', $user_his_table, getClientIP(), $userid[0], sql_escape($msg),
sql_escape(htmlspecialchars($detail)), sql_escape($sysinfo)));
Expand Down
4 changes: 2 additions & 2 deletions public_html/lists/admin/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ function getPageLock($force = 0)
// while ($running_res['age'] && $count >= $max) { # a process is already running
while ($count >= $max) { // don't check age, as it may be 0
// cl_output('running process: '.$running_res['age'].' '.$max);
if ($running_res['age'] > 600) {
if (!empty($running_res['age']) && (int)$running_res['age'] > 600) {
// some sql queries can take quite a while
//cl_output($running_res['id'].' is old '.$running_res['age']);
// process has been inactive for too long, kill it
Expand Down Expand Up @@ -1879,7 +1879,7 @@ function refreshTlds($force = 0)
$lastDone = getConfig('tld_last_sync');
$tlds = '';
//# let's not do this too often
if ($lastDone + TLD_REFETCH_TIMEOUT < time() || $force) {
if (((int)$lastDone + TLD_REFETCH_TIMEOUT < time()) || $force) {
//# even if it fails we mark it as done, so that we won't getting stuck in eternal updating.
SaveConfig('tld_last_sync', time(), 0);
if (defined('TLD_AUTH_LIST')) {
Expand Down
1 change: 1 addition & 0 deletions public_html/lists/admin/members.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$confirmedSelection = ' u.confirmed and !u.blacklisted';
}
$listAll = false;
$subselect = '';

switch ($access) {
case 'owner':
Expand Down
3 changes: 3 additions & 0 deletions public_html/lists/admin/mysqli.inc
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ function Sql_create_Table($table, $structure)

function sql_escape($text)
{
if (empty($text)) {
return '';
}
if (empty($GLOBALS['database_connection'])) {
$GLOBALS['database_connection'] = Sql_Connect(
$GLOBALS['database_host'],
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/phpListAdminAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function adminName($id)
{
$req = Sql_Fetch_Row_Query(sprintf('select loginname from %s where id = %d', $GLOBALS['tables']['admin'], $id));

return $req[0] ? $req[0] : s('Nobody');
return !empty($req[0]) ? $req[0] : s('Nobody');
}

/**
Expand Down
2 changes: 2 additions & 0 deletions public_html/lists/admin/pluginlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
$GLOBALS['plugins_disabled'][] = $pl;
}
}
} else {
$disabled_plugins = array();
}

//var_dump($GLOBALS['plugins_disabled']);exit;
Expand Down
4 changes: 2 additions & 2 deletions public_html/lists/admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@
if ($canEnable) {
$ls->addColumn($pluginname, s('enabled'), $plugin->enabled ? $GLOBALS['img_tick'] : $GLOBALS['img_cross']);
$ls->addColumn($pluginname, s('action'), $plugin->enabled ?
PageLinkAjax('plugins&disable='.$pluginname, '<button>Disable</button>') :
PageLinkAjax('plugins&enable='.$pluginname, '<button>Enable</button>'));
PageLinkAjax('plugins&disable='.$pluginname, '<button id="disable_plugin'.$pluginname.'">Disable</button>') :
PageLinkAjax('plugins&enable='.$pluginname, '<button id="enable_plugin'.$pluginname.'">Enable</button>'));
} else {
$ls->addColumn($pluginname, s('enabled'), $GLOBALS['img_cross']);
}
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/send_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
subject = "%s", fromfield = "%s", tofield = "%s",
replyto ="%s", embargo = "%s", repeatinterval = "%s", repeatuntil = "%s",
message = "%s", textmessage = "%s", footer = "%s", status = "%s",
htmlformatted = "%s", sendformat = "%s", template = "%s" where id = %d',
htmlformatted = "%s", sendformat = "%s", template = "%d" where id = %d',
$tables['message'],
sql_escape(strip_tags($messagedata['campaigntitle'])),
/* we store the title in the subject field. Better would be to rename the DB column, but this will do for now */
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class="confirm btn btn-default"
while ($row = Sql_fetch_array($res)) {
if (!empty($id)) {
$val_req = Sql_Fetch_Row_Query("select value from $tables[user_attribute] where userid = $id and attributeid = $row[id]");
$row['value'] = $val_req[0];
$row['value'] = !empty($val_req[0]) ? $val_req[0] : "";
} elseif (!empty($_POST['attribute'][$row['id']])) {
$row['value'] = $_POST['attribute'][$row['id']];
} else {
Expand Down

0 comments on commit f0443c3

Please sign in to comment.