From 2fcd1054949f748867f69c4e0f24f1efe171fafe Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 30 Nov 2025 19:13:30 +0000 Subject: [PATCH 1/3] Fix various PHP warnings This commit fixes several PHP warnings and deprecation notices that were cluttering the nginx error log. - Fixed "Undefined array key" and "Undefined variable" warnings by using `isset()` checks, the null coalescing operator (`??`), and initializing variables. - Addressed "Trying to access array offset on value of type null" warnings by adding checks for null values before accessing array offsets. - Resolved "Deprecated: preg_match(): Passing null to parameter # 2 ($subject) of type string is deprecated" and "Deprecated: pathinfo(): Passing null to parameter # 1 ($path) of type string is deprecated" notices by ensuring the variables are not null. --- include/class/PeerRequest.php | 4 ++-- web/apps/admin/index.php | 3 ++- web/apps/docs/index.php | 6 ++++++ web/apps/explorer/txs.php | 8 ++++---- web/mine.php | 5 ++++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/class/PeerRequest.php b/include/class/PeerRequest.php index 8c81e5bf..c27d3eb3 100644 --- a/include/class/PeerRequest.php +++ b/include/class/PeerRequest.php @@ -150,7 +150,7 @@ static function peer() { $res = Peer::getSingle($hostname, $ip); if ($res == 1) { _log("$hostname is already in peer db",3); - if ($data['repeer'] == 1) { + if (isset($data['repeer']) && $data['repeer'] == 1) { $res = peer_post($hostname."/peer.php?q=peer", ["hostname" => $_config['hostname']], 30, $err); if ($res !== false) { api_echo("re-peer-ok"); @@ -169,7 +169,7 @@ static function peer() { Peer::updatePeerInfo($ip, $_REQUEST['info']); } // re-peer to make sure the peer is valid - if ($data['repeer'] == 1) { + if (isset($data['repeer']) && $data['repeer'] == 1) { _log("Repeer to $hostname",3); $res = peer_post($hostname . "/peer.php?q=peer", ["hostname" => $_config['hostname']], 30, $err); _log("peer response " . print_r($res,1),4); diff --git a/web/apps/admin/index.php b/web/apps/admin/index.php index eaa25363..c97eb2ab 100755 --- a/web/apps/admin/index.php +++ b/web/apps/admin/index.php @@ -13,6 +13,7 @@ require_once __DIR__. '/../common/include/top.php'; +$msg = []; if(isset($_POST['action'])) { $action = $_POST['action']; if($action == "generate") { @@ -141,7 +142,7 @@ } $setAdminPass = !empty($_config['admin_password']); -$login = $_SESSION['login']; +$login = $_SESSION['login'] ?? false; if(isset($_GET['view'])) { $view = $_GET['view']; diff --git a/web/apps/docs/index.php b/web/apps/docs/index.php index a7d476b2..cbbc319f 100644 --- a/web/apps/docs/index.php +++ b/web/apps/docs/index.php @@ -8,7 +8,13 @@ class ParsedownExt extends Parsedown { function inlineLink($Excerpt) { + if (!isset($Excerpt['text'])) { + return null; + } $link = parent::inlineLink($Excerpt); + if (!isset($link['element']['attributes']['href'])) { + return $link; + } $link['element']['attributes']['href'] = "/apps/docs/index.php?link=".urlencode($link['element']['attributes']['href']); return $link; } diff --git a/web/apps/explorer/txs.php b/web/apps/explorer/txs.php index fa352d4c..11b2cc2f 100644 --- a/web/apps/explorer/txs.php +++ b/web/apps/explorer/txs.php @@ -68,17 +68,17 @@ function TransactiongetAll($dm) {