Skip to content

Commit a5fce77

Browse files
authored
Avoid php 8.2 warnings (#930)
* Avoid php warnings when run from command line * Avoid php warning when template does not exist * Avoid php 8 deprecation regarding string interpolation * Improve handling of unknown admin to avoid php warnings and deprecations * Avoid php 8.2 warning about dynamic properties
1 parent a638455 commit a5fce77

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

public_html/lists/admin/actions/processqueue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ function sendEmailTest($messageid, $email)
623623
} else {
624624
//# check for a future embargo, to be able to report when it expires.
625625
$future = Sql_Fetch_Assoc_Query('select unix_timestamp(embargo) - unix_timestamp(now()) as waittime '
626-
." from ${tables['message']}"
626+
." from {$tables['message']}"
627627
." where status not in ('draft', 'sent', 'prepared', 'suspended')"
628628
.' and embargo > now()'
629629
.' order by embargo asc limit 1');
@@ -1327,7 +1327,7 @@ function sendEmailTest($messageid, $email)
13271327
$msgperhour = (3600 / $totaltime) * $counters['sent'];
13281328
$secpermsg = $totaltime / $counters['sent'];
13291329
$timeleft = ($counters['total_users_for_message '.$messageid] - $counters['sent']) * $secpermsg;
1330-
$eta = date('D j M H:i', time() + $timeleft);
1330+
$eta = date('D j M H:i', time() + (int) $timeleft);
13311331
} else {
13321332
$msgperhour = 0;
13331333
$secpermsg = 0;

public_html/lists/admin/defaultplugin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class phplistPlugin
2020
public $documentationUrl = ''; //# link to documentation for this plugin (eg https://resources.phplist.com/plugin/pluginname
2121
public $enabled = 1; // use directly, can be privitsed later and calculated with __get and __set
2222
public $system_root = ''; //# root dir of the phpList admin directory
23+
public $dependencyFailure;
2324

2425
//@@Some ideas to implement this:
2526
// * Start each method with if (!$this->enabled) return parent :: parentMethod($args);

public_html/lists/admin/lib.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,11 @@ function getClientIP()
24532453
}
24542454
}
24552455

2456-
$the_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
2456+
if (isset($_SERVER['REMOTE_ADDR'])) {
2457+
$the_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);
2458+
} else {
2459+
$the_ip = '';
2460+
}
24572461
//logEvent("REMOTE_ADDR ip=".$the_ip);
24582462

24592463
return $the_ip;

public_html/lists/admin/phpListAdminAuthentication.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ class phpListAdminAuthentication
2323
*/
2424
public function validateLogin($login, $password)
2525
{
26+
if (empty($login) || ($password == '')) {
27+
return array(0, s('Please enter your credentials.'));
28+
}
2629
$query = sprintf('select password, disabled, id from %s where loginname = "%s"', $GLOBALS['tables']['admin'],
2730
sql_escape($login));
2831
$req = Sql_Query($query);
2932
$admindata = Sql_Fetch_Assoc($req);
33+
if (!$admindata) {
34+
return array(0, s('incorrect password'));
35+
}
3036
$encryptedPass = hash(HASH_ALGO, $password);
3137
$passwordDB = $admindata['password'];
3238
//Password encryption verification.
@@ -39,9 +45,6 @@ public function validateLogin($login, $password)
3945
$req = Sql_Query($query);
4046
}
4147

42-
if(empty($login)||($password=="")){
43-
return array(0, s('Please enter your credentials.'));
44-
}
4548
if ($admindata['disabled']) {
4649
return array(0, s('your account has been disabled'));
4750
}

public_html/lists/admin/sendemaillib.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,16 +1443,18 @@ function precacheMessage($messageid, $forwardContent = 0)
14431443

14441444
$cached[$messageid]['htmlformatted'] = strip_tags($cached[$messageid]['content']) != $cached[$messageid]['content'];
14451445
$cached[$messageid]['sendformat'] = $message['sendformat'];
1446+
1447+
$cached[$messageid]['template'] = '';
1448+
$cached[$messageid]['template_text'] = '';
1449+
$cached[$messageid]['templateid'] = 0;
14461450
if ($message['template']) {
14471451
$req = Sql_Fetch_Row_Query("select template, template_text from {$GLOBALS['tables']['template']} where id = {$message['template']}");
1448-
$cached[$messageid]['template'] = stripslashes($req[0]);
1449-
$cached[$messageid]['template_text'] = stripslashes($req[1]);
1450-
$cached[$messageid]['templateid'] = $message['template'];
1451-
// dbg("TEMPLATE: ".$req[0]);
1452-
} else {
1453-
$cached[$messageid]['template'] = '';
1454-
$cached[$messageid]['template_text'] = '';
1455-
$cached[$messageid]['templateid'] = 0;
1452+
if ($req) {
1453+
$cached[$messageid]['template'] = stripslashes($req[0]);
1454+
$cached[$messageid]['template_text'] = stripslashes($req[1]);
1455+
$cached[$messageid]['templateid'] = $message['template'];
1456+
// dbg("TEMPLATE: ".$req[0]);
1457+
}
14561458
}
14571459

14581460
//# @@ put this here, so it can become editable per email sent out at a later stage

0 commit comments

Comments
 (0)