Skip to content
This repository was archived by the owner on Jun 25, 2024. It is now read-only.

Commit a08f3da

Browse files
author
Billy Clark
committed
null checks were cluttering the code for a improbable use case related to PHP_NOTICES
1 parent 80931ed commit a08f3da

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed

themes/material/common-announcement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
$announcement = htmlentities($this->data['announcement'] ?? null);
2+
$announcement = htmlentities($this->data['announcement']);
33

44
if (! empty($announcement)) {
55
?>

themes/material/core/loginuserpass.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<?php include __DIR__ . '/../common-head-elements.php' ?>
77

88
<?php
9-
$siteKey = htmlentities($this->data['recaptcha.siteKey'] ?? null);
9+
$siteKey = htmlentities($this->data['recaptcha.siteKey']);
1010
if (! empty($siteKey)) {
1111
?>
1212
<script src='https://www.google.com/recaptcha/api.js?onload=onRecaptchaLoad&render=explicit'
@@ -40,9 +40,9 @@ function onRecaptchaLoad() {
4040

4141
<form method="POST">
4242
<input type="hidden" name="AuthState"
43-
value="<?= htmlentities($this->data['stateparams']['AuthState'] ?? null) ?>" />
43+
value="<?= htmlentities($this->data['stateparams']['AuthState']) ?>" />
4444
<?php
45-
$csrfToken = htmlentities($this->data['csrfToken'] ?? null);
45+
$csrfToken = htmlentities($this->data['csrfToken']);
4646
?>
4747
<input type="hidden" name="csrf-token" value="<?= $csrfToken ?>" />
4848

@@ -67,7 +67,7 @@ function onRecaptchaLoad() {
6767
<?= $this->t('{material:login:label_username}') ?>
6868
</label>
6969
<?php
70-
$username = htmlentities($this->data['username'] ?? null);
70+
$username = htmlentities($this->data['username']);
7171
?>
7272
<input type="text" name="username" class="mdl-textfield__input"
7373
value="<?= $username ?>"
@@ -87,7 +87,7 @@ function onRecaptchaLoad() {
8787
$errorCode = htmlentities($this->data['errorcode']);
8888
if ($errorCode == 'WRONGUSERPASS') {
8989
$errorMessageKey = $this->data['errorparams'][1] ?? '{material:login:error_wronguserpass}';
90-
$errorMessageTokens = $this->data['errorparams'][2] ?? null;
90+
$errorMessageTokens = $this->data['errorparams'][2];
9191

9292
$message = htmlentities($this->t($errorMessageKey, $errorMessageTokens));
9393
?>
@@ -108,7 +108,7 @@ function onRecaptchaLoad() {
108108

109109
<div class="mdl-card__actions" layout-children="row">
110110
<?php
111-
$forgotPasswordUrl = htmlentities($this->data['forgotPasswordUrl'] ?? null);
111+
$forgotPasswordUrl = htmlentities($this->data['forgotPasswordUrl']);
112112
if (! empty($forgotPasswordUrl)) {
113113
?>
114114
<a href="<?= $forgotPasswordUrl ?>" target="_blank"

themes/material/default/error.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
if ($this->data['showerrors'] ?? false) {
2525
?>
2626
<p class="mdl-typography--body-2">
27-
<?= htmlentities($this->data['error']['exceptionMsg'] ?? null) ?>
27+
<?= htmlentities($this->data['error']['exceptionMsg']) ?>
2828
</p>
2929

3030
<pre class="mdl-typography--caption">
31-
<?= htmlentities($this->data['error']['exceptionTrace'] ?? null) ?>
31+
<?= htmlentities($this->data['error']['exceptionTrace']) ?>
3232
</pre>
3333
<?php
3434
}

themes/material/default/selectidp-links.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ function clickedAnyway(idpName) {
3636

3737
<main class="mdl-layout__content">
3838
<?php include __DIR__ . '/../common-announcement.php' ?>
39-
39+
<!--TODO: is this stuff in formdata by chance?-->
4040
<form layout-children="row" child-spacing="space-around">
4141
<input type="hidden" name="entityID"
42-
value="<?= htmlentities($this->data['entityID'] ?? null) ?>" />
42+
value="<?= htmlentities($this->data['entityID']) ?>" />
4343
<input type="hidden" name="return"
44-
value="<?= htmlentities($this->data['return'] ?? null) ?>" />
44+
value="<?= htmlentities($this->data['return']) ?>" />
4545
<input type="hidden" name="returnIDParam"
46-
value="<?= htmlentities($this->data['returnIDParam'] ?? null) ?>" />
46+
value="<?= htmlentities($this->data['returnIDParam']) ?>" />
4747

4848
<?php
4949
// in order to bypass some built-in simplesaml behavior, an extra idp
@@ -58,8 +58,8 @@ function clickedAnyway(idpName) {
5858
}
5959

6060
foreach ($enabledIdps as $idp) {
61-
$name = htmlentities($this->t($idp['name'] ?? null));
62-
$idpId = htmlentities($idp['entityid'] ?? null);
61+
$name = htmlentities($this->t($idp['name']));
62+
$idpId = htmlentities($idp['entityid']);
6363
$hoverText = $this->t('{material:selectidp:enabled}', ['{idpName}' => $name]);
6464
?>
6565
<div class="mdl-card mdl-shadow--8dp row-aware" title="<?= $hoverText ?>">
@@ -77,8 +77,8 @@ function clickedAnyway(idpName) {
7777

7878
<?php
7979
foreach ($disabledIdps as $idp) {
80-
$name = htmlentities($this->t($idp['name'] ?? null));
81-
$idpId = htmlentities($idp['entityid'] ?? null);
80+
$name = htmlentities($this->t($idp['name']));
81+
$idpId = htmlentities($idp['entityid']);
8282
$hoverText = $this->t('{material:selectidp:disabled}', ['{idpName}' => $name]);
8383
?>
8484
<div class="mdl-card mdl-shadow--2dp disabled row-aware" title="<?= $hoverText ?>"

themes/material/expirychecker/about2expire.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
</span>
1515
</div>
1616
</header>
17-
<!--TODO: do we need ?? null on these data[] retrievals as done in other pages? Test what happens when the key is altered to a nonexistent name -->
1817
<main class="mdl-layout__content" layout-children="column">
1918
<form layout-children="column">
2019
<?php

themes/material/expirychecker/expired.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
</span>
1515
</div>
1616
</header>
17-
<!--TODO: do we need ?? null on these data[] retrievals as done in other pages? Test what happens when the key is altered to a nonexistent name -->
1817
<main class="mdl-layout__content" layout-children="column">
1918
<form layout-children="column">
2019
<?php

0 commit comments

Comments
 (0)