Skip to content

Commit

Permalink
Add null coalescing checks for typed calls
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Dec 19, 2024
1 parent 5bde0d9 commit 7287f8a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Templates/Comment/Delete.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require('./Includes/header.inc.phtml'); ?>

<h2 class="text-danger">Delete Comment</h2>
<p class="text-danger">Are you sure you wish to delete this comment?</p>
<form method="POST" action="?id=<?=rawurlencode($id)?>">
<form method="POST" action="?id=<?=rawurlencode($id ?? '')?>">
<table class="table table-striped text-white-50"><tbody>
<tr><td><a href="<?=$c_user_url?>"><img class="avatar" src="<?=$c_user_avatar?>"/> <?=filter_var($c_user_name, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></a><br/><time class="comment_timestamp" datetime="<?=$c->getCreatedDateTime()->format('c')?>"><?=$c->getCreatedDateTime()->format('D M j, Y g:ia T')?></time></td><td><?=$c->getContent(true)?></td></tr>
</tbody></table>
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/Comment/Section.inc.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $c_delete_visible_admin = ($active_user && $active_user->getOption(User::OPTION_
<? } else {
foreach ($comments as $c) {
$c_created_dt = $c->getCreatedDateTime();
$c_id = rawurlencode($c->getId());
$c_id = rawurlencode($c->getId() ?? '');
$c_parent_url = $c->getParentUrl();
$c_user = $c->getUser();
$c_user_id = $c->getUserId();
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/Document/Edit.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require('./Includes/header.inc.phtml'); ?>
<? if ($this->getContext()->acl_allowed) { ?>
<h1><?=$title?></h1>
<p><?=$description?></p>
<? if (is_null($error) || $error == 'NOT_FOUND') {
<? if (is_null($error) || $error == EditModel::ERROR_NOT_FOUND) {
require('./Document/Form.inc.phtml');
$comment_parent_type = Comment::PARENT_TYPE_DOCUMENT; $comment_parent_id = $document_id; require('./Comment/Section.inc.phtml');
} else if ($error !== false) { ?>
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/Document/View.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else
$description = 'The requested document does not exist or could not be found.';
}
$_header_meta_properties = ['og:type' => 'article'];
$url = UrlFormatter::format('/document/' . rawurlencode($object_id));
$url = UrlFormatter::format('/document/' . rawurlencode($object_id ?? ''));
if ($object)
{
$url = $object->getURI();
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/EventLog/View.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $description = 'The event log viewer on BNETDocs';
$object_id = $this->getContext()->id;
$object = $this->getContext()->event;

$url = ($object instanceof Event) ? $object->getURI() : '/eventlog/view?id=' . rawurlencode($object_id);
$url = ($object instanceof Event) ? $object->getURI() : '/eventlog/view?id=' . rawurlencode($object_id ?? '');

$object_ip_address = ($object instanceof Event ? $object->getIPAddress() : null);
$object_metadata = ($object instanceof Event ? $object->getMetaData() : null);
Expand Down
4 changes: 2 additions & 2 deletions src/Templates/Packet/View.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ if ($object)
}
}

$edit_url = UrlFormatter::format('/packet/edit?id=' . rawurlencode($object_id));
$delete_url = UrlFormatter::format('/packet/delete?id=' . rawurlencode($object_id));
$edit_url = UrlFormatter::format('/packet/edit?id=' . rawurlencode($object_id ?? ''));
$delete_url = UrlFormatter::format('/packet/delete?id=' . rawurlencode($object_id ?? ''));
$edit_visible = ($active_user && $active_user->getOption(User::OPTION_ACL_PACKET_MODIFY));
$delete_visible = ($active_user && $active_user->getOption(User::OPTION_ACL_PACKET_DELETE));

Expand Down
2 changes: 1 addition & 1 deletion src/Templates/User/View.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $user_profile = $this->getContext()->user_profile;
$user_verified = $user && $user->isVerified();
$title = ($user ? $user->getName() : 'User Not Found');
$description = ($user ? $user->getName() . '\'s user profile on BNETDocs' : 'The requested user does not exist or could not be found.');
$url = ($user ? $user->getURI() : UrlFormatter::format('/user/' . rawurlencode($user_id)));
$url = ($user ? $user->getURI() : UrlFormatter::format('/user/' . rawurlencode($user_id ?? '')));
$_header_meta_properties = ['og:type' => 'profile'];

if ($user)
Expand Down

0 comments on commit 7287f8a

Please sign in to comment.