php7.4 / psalm fixes

pull/325/head
David Goodwin 4 years ago
parent 882b6835ed
commit 1ad184641d

@ -27,7 +27,7 @@
"jakub-onderka/php-parallel-lint": "^1.0",
"php": ">7.2.0",
"php-coveralls/php-coveralls" : "*",
"phpunit/phpunit": "^6.0",
"phpunit/phpunit": "^6|^7",
"vimeo/psalm":"^3.0",
"zendframework/zendframework1": "^1.12.0"
},

@ -1721,6 +1721,7 @@ function db_query($sql, array $values = array(), $ignore_errors = false) {
$link = db_connect();
$error_text = '';
$stmt = null;
try {
$stmt = $link->prepare($sql);
$stmt->execute($values);

@ -12,6 +12,6 @@ if(function_exists('random_int')) {
return;
}
function random_int() { // someone might not be using php_crypt or ask for password generation, in which case random_int() won't be called
function random_int($a, $b) { // someone might not be using php_crypt or ask for password generation, in which case random_int() won't be called
die(__FILE__ . " Postfixadmin security: Please install https://github.com/paragonie/random_compat OR enable the 'Phar' extension.");
}

@ -139,7 +139,7 @@ class AliasHandler extends PFAHandler {
public function init($id) {
@list($local_part, $domain) = explode('@', $id); # supress error message if $id doesn't contain '@'
if ($local_part == '*') { # catchall - postfix expects '@domain', not '*@domain'
if ($local_part == '*' && !is_null($domain)) { # catchall - postfix expects '@domain', not '*@domain'
$id = '@' . $domain;
}

@ -46,7 +46,7 @@ class CliEdit extends Shell {
if (strtolower($val) == 'y') {
$val = 1;
} # convert y to 1
if (strtolower($val) == 'n') {
elseif (strtolower($val) == 'n') {
$val = 0;
} # convert n to 0
$values[$key] = $val; # don't modify any other value - *Handler will complain if it's invalid ;-)

@ -586,7 +586,7 @@ class MailboxHandler extends PFAHandler {
if ($quota <= 0) {
$quota = 0;
} # TODO: check if this is correct behaviour
$cmdarg4=escapeshellarg($quota);
$cmdarg4 = escapeshellarg("" . $quota);
$command= "$cmd $cmdarg1 $cmdarg2 $cmdarg3 $cmdarg4";
$retval=0;
$output=array();

@ -168,10 +168,10 @@ abstract class PFAHandler {
*/
public function __construct($new = 0, $username = "", $is_admin = 1) {
# set label_field if not explicitely set
if (!isset($this->id_field)) {
if (empty($this->id_field)) {
throw new \InvalidArgumentException("id_field must be defined");
}
if (!isset($this->db_table)) {
if (empty($this->db_table)) {
throw new \InvalidArgumentException("db_table must be defined");
}
if (empty($this->label_field)) {
@ -237,9 +237,6 @@ abstract class PFAHandler {
);
}
if (empty($this->db_table)) {
throw new Exception("db_table not defined");
}
$struct_hook = Config::read_string($this->db_table . '_struct_hook');
if (!empty($struct_hook) && is_string($struct_hook) && $struct_hook != 'NO' && function_exists($struct_hook)) {
$this->struct = $struct_hook($this->struct);

@ -97,6 +97,7 @@ class Shell {
*/
public $handler_to_use;
public $new;
/**
* Constructs this Shell instance.
*

@ -28,6 +28,9 @@ if (file_exists(dirname(__FILE__) . '/../config.inc.php')) {
require_once(dirname(__FILE__) . '/../config.inc.php');
}
/**
* @psalm-suppress TypeDoesNotContainType
*/
if ($CONF['configured']) {
header("Location: login.php");
exit;

Loading…
Cancel
Save