Skip to content

Commit

Permalink
Fix for PHP 8 and if viewing comment that does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
eSilverStrike committed Jun 27, 2022
1 parent ca0a787 commit 0633c21
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions system/lib-comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2688,6 +2688,7 @@ function CMT_handleView($format, $order, $page, $view = true)
global $_CONF, $_TABLES, $_USER;

$cid = 0;
$display = '';
if ($view) {
if (isset($_REQUEST[CMT_CID])) {
$cid = (int) Geeklog\Input::fRequest(CMT_CID);
Expand All @@ -2702,21 +2703,29 @@ function CMT_handleView($format, $order, $page, $view = true)
}

$sql = "SELECT sid, title, type FROM {$_TABLES['comments']} WHERE cid = $cid";
$A = DB_fetchArray(DB_query($sql));
$sid = $A['sid'];
//$title = $A['title'];
$type = $A['type'];
$title = PLG_getItemInfo($type, $sid, 'title'); // Need title of item not comment title

$display = PLG_displayComment($type, $sid, $cid, $title,
$order, $format, $page, $view);
if (!$display) {
COM_handle404();
}
$result = DB_query($sql);
$nrows = DB_numRows($result);

if ($nrows == 1) {
$A = DB_fetchArray($result);

$sid = $A['sid'];
//$title = $A['title'];
$type = $A['type'];
$title = PLG_getItemInfo($type, $sid, 'title'); // Need title of item not comment title

$display = COM_showMessageFromParameter() . $display;
$display = COM_createHTMLDocument($display, array('pagetitle' => $title));
$display = PLG_displayComment($type, $sid, $cid, $title,
$order, $format, $page, $view);
if (!$display) {
COM_handle404();
}

$display = COM_showMessageFromParameter() . $display;
$display = COM_createHTMLDocument($display, array('pagetitle' => $title));
} else {
COM_handle404();
}

return $display;
}

Expand Down

0 comments on commit 0633c21

Please sign in to comment.