Skip to content

Commit

Permalink
PHP 8 compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alanaktion committed Mar 12, 2022
1 parent 38d1209 commit f40236c
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .vscode/extensions.json
@@ -1,7 +1,7 @@
{
"recommendations": [
"bmewburn.vscode-intelephense-client",
"felixfbecker.php-debug",
"xdebug.php-debug",
"shevaua.phpcs"
]
}
19 changes: 14 additions & 5 deletions app/controller/files.php
Expand Up @@ -142,11 +142,20 @@ public function thumb($f3, $params)
$c1 = imagecolorallocate($frame, 243, 243, 243);
imagefilledrectangle($frame, $ox - $fb, $oy - $fb, $size - $ox + $fb, $size - $oy + $fb, $c1);
$c2 = imagecolorallocate($frame, 230, 230, 230);
imagefilledpolygon($frame, array(
$size - $ox + $fb, $oy - $fb,
$size - $ox + $fb, $size - $oy + $fb,
$ox - $fb, $size - $oy + $fb,
), 3, $c2);
// This is an incredibly stupid way of deprecating a parameter, thanks PHP.
if (PHP_VERSION_ID >= 80000) {
imagefilledpolygon($frame, array(
$size - $ox + $fb, $oy - $fb,
$size - $ox + $fb, $size - $oy + $fb,
$ox - $fb, $size - $oy + $fb,
), $c2);
} else {
imagefilledpolygon($frame, array(
$size - $ox + $fb, $oy - $fb,
$size - $ox + $fb, $size - $oy + $fb,
$ox - $fb, $size - $oy + $fb,
), 3, $c2);
}
}

// Copy thumbnail onto frame
Expand Down
6 changes: 5 additions & 1 deletion app/helper/view.php
Expand Up @@ -22,6 +22,9 @@ public function __construct()
*/
public function parseText($str, $options = array(), $ttl = null)
{
if ($str === null || $str === '') {
return '';
}
if ($options === null) {
$options = array();
}
Expand Down Expand Up @@ -238,6 +241,7 @@ protected function _parseEmoticons($str)
*/
protected function _parseTextile($str, $escape = true)
{
error_reporting(E_ALL ^ E_DEPRECATED); // Temporarily ignore deprecations because this lib is incompatible
$tex = new \Netcarver\Textile\Parser('html5');
$tex->setDimensionlessImages(true);
$tex->setRestricted($escape);
Expand Down Expand Up @@ -286,7 +290,7 @@ public function gravatar($email, $size = 80)
$f3 = \Base::instance();
$rating = $f3->get("gravatar.rating") ? $f3->get("gravatar.rating") : "pg";
$default = $f3->get("gravatar.default") ? $f3->get("gravatar.default") : "mm";
return "//gravatar.com/avatar/" . md5(strtolower($email)) .
return "https://gravatar.com/avatar/" . md5(strtolower($email ?? '')) .
"?s=" . intval($size) .
"&d=" . urlencode($default) .
"&r=" . urlencode($rating);
Expand Down
30 changes: 17 additions & 13 deletions app/model/issue.php
Expand Up @@ -10,20 +10,20 @@
* @property int $type_id
* @property string $name
* @property string $description
* @property int $parent_id
* @property ?int $parent_id
* @property int $author_id
* @property int $owner_id
* @property ?int $owner_id
* @property int $priority
* @property float $hours_total
* @property float $hours_remaining
* @property float $hours_spent
* @property ?float $hours_total
* @property ?float $hours_remaining
* @property ?float $hours_spent
* @property string $created_date
* @property string $closed_date
* @property string $deleted_date
* @property string $start_date
* @property string $due_date
* @property string $repeat_cycle
* @property int $sprint_id
* @property ?string $closed_date
* @property ?string $deleted_date
* @property ?string $start_date
* @property ?string $due_date
* @property ?string $repeat_cycle
* @property ?int $sprint_id
*/
class Issue extends \Model
{
Expand Down Expand Up @@ -302,7 +302,7 @@ protected function _saveUpdate(bool $notify = true): Issue\Update
$importantChanges = 0;
$importantFields = array('status', 'name', 'description', 'owner_id', 'priority', 'due_date');
foreach ($this->fields as $key => $field) {
if ($field["changed"] && rtrim($field["value"]) != rtrim($this->_getPrev($key))) {
if ($field["changed"] && rtrim($field["value"] ?? '') != rtrim($this->_getPrev($key) ?? '')) {
$updateField = new \Model\Issue\Update\Field();
$updateField->issue_update_id = $update->id;
$updateField->field = $key;
Expand Down Expand Up @@ -537,7 +537,11 @@ public function hashState(): array
{
$result = $this->cast();
foreach ($result as &$value) {
$value = md5($value);
if ($value === null) {
$value = md5('');
} else {
$value = md5($value);
}
}
return $result;
}
Expand Down
2 changes: 1 addition & 1 deletion app/view/admin/config.html
Expand Up @@ -176,7 +176,7 @@
</div>
<div class="form-group">
<label class="control-label" for="imap-password">{{ @dict.password }}</label>
<input type="text" class="form-control input-sm" name="imap-password" value="{{ str_repeat('*', strlen(@@imap.password)) }}">
<input type="text" class="form-control input-sm" name="imap-password" value="{{ isset(@imap.password) ? str_repeat('*', strlen(@@imap.password)) : '' }}">
</div>
<div class="form-group">
<label class="control-label" for="mail-truncate_lines">{{ @dict.imap_truncate_lines }}</label>
Expand Down
2 changes: 1 addition & 1 deletion app/view/blocks/dashboard-issue-list.html
Expand Up @@ -18,7 +18,7 @@
<span class="label-{{ @item.priority < 0 ? 'default' : 'danger' }} priority" style="width: {{ !@item.priority ? 0 : 1 + 1 * abs(@item.priority) }}px;"></span>
</check>
</p>
<check if="{{ strtotime(@item.due_date) }}">
<check if="{{ !empty(@item.due_date) && strtotime(@item.due_date) }}">
<p class="list-group-item-text">Due {{ date("l, F j", strtotime(@item.due_date)) }}</p>
</check>
<check if="{{ @item.sprint_id }}">
Expand Down
2 changes: 1 addition & 1 deletion app/view/blocks/issue-list/issue.html
Expand Up @@ -25,7 +25,7 @@
</false>
</check>
<td>{{ !empty(@item.sprint_start_date) ? date("n/j/y", strtotime(@item.sprint_start_date)) : "" }}</td>
<td>{{ ucwords(@@dict[@item.repeat_cycle]) ?: @dict.not_repeating }}</td>
<td>{{ isset(@dict[@item.repeat_cycle]) ? ucwords(@dict[@item.repeat_cycle]) : @dict.not_repeating }}</td>
<td title="{{ date('Y-m-d H:i:s', @this->utc2local(@item.created_date)) }}">{{ date("n/j/y", @this->utc2local(@item.created_date)) }}</td>
<td>{{ !empty(@item.due_date) ? date("n/j/y", strtotime(@item.due_date)) : "" }}</td>
<check if="{{ !empty(@GET.status) && @GET.status != 'open' }}">
Expand Down
2 changes: 1 addition & 1 deletion app/view/install.html
Expand Up @@ -86,7 +86,7 @@ <h4>Site Configuration</h4>
<label for="parser" class="col-sm-3 control-label">Text Parser</label>
<div class="col-sm-9">
<select class="form-control" name="parser" id="parser">
<option value="markdown">Markdown (Recommended)</option>
<option value="markdown" selected>Markdown (Recommended)</option>
<option value="textile">Textile (Deprecated)</option>
<option value="both">Markdown + Textile (Deprecated)</option>
<option value="">None</option>
Expand Down
2 changes: 1 addition & 1 deletion app/view/issues/single.html
Expand Up @@ -177,7 +177,7 @@ <h3 class="pull-left issue-heading">
<dd>{{ @issue.hours_remaining ?: 0 }}</dd>
</check>

<check if="{{ strtotime(@issue.start_date) }}">
<check if="{{ @issue.start_date && strtotime(@issue.start_date) }}">
<dt>{{ @dict.cols.start_date }}</dt>
<dd>{{ date("D, M j, Y", strtotime(@issue.start_date)) }}</dd>
</check>
Expand Down
12 changes: 6 additions & 6 deletions app/view/issues/single/dependencies.html
@@ -1,7 +1,7 @@
<form id="dependency_form" class="form-horizontal">
<input type="hidden" name="issue_id" value="{{ @issue.id }}">
<div class="form-group">
<label class="col-md-4"><b>{{ @dict.task_depends }}</b></label>
<label class="col-md-5"><b>{{ @dict.task_depends }}</b></label>
<div class="col-md-3">
<input type="text" class="form-control input-sm" name="dependency_id" required>
</div>
Expand Down Expand Up @@ -42,8 +42,8 @@
<td>{{ @item.dependency_type }}</td>
<td><a href="{{ @BASE }}/user/{{ @item.author_username }}">{{ @item.author_name | esc }}</a></td>
<td><a href="{{ @BASE }}/user/{{ @item.owner_username }}">{{ @item.owner_name | esc }}</a></td>
<td data-sort-value="{{ strtotime(@item.start_date) }}" title="{{ date('M j, Y \\a\\t g:ia', strtotime(@item.start_date)) }}">{{ date("n/j/y", strtotime(@item.start_date)) }}</td>
<td data-sort-value="{{ strtotime(@item.due_date) ?: 0 }}">{{ !empty(@item.due_date) ? date("n/j", strtotime(@item.due_date)) : "" }}</td>
<td data-sort-value="{{ @item.start_date ? strtotime(@item.start_date) : 0 }}" title="{{ @item.start_date ? date('M j, Y \\a\\t g:ia', strtotime(@item.start_date)) : '' }}">{{ @item.start_date ? date("n/j/y", strtotime(@item.start_date)) : '' }}</td>
<td data-sort-value="{{ @item.due_date ? strtotime(@item.due_date) : 0 }}">{{ !empty(@item.due_date) ? date("n/j", strtotime(@item.due_date)) : "" }}</td>
<td data-sort-value="{{ @item.status }}">{{ @item.status_name }}</td>
<td><a href="#" class="delete"><span class="fa fa-remove"></span></a></td>
</tr>
Expand All @@ -56,7 +56,7 @@
<form id="dependent_form" class="form-horizontal">
<input type="hidden" name="dependency_id" value="{{ @issue.id }}">
<div class="form-group">
<label class="col-md-4"><strong>{{ @dict.task_dependency }}</strong></label>
<label class="col-md-5"><strong>{{ @dict.task_dependency }}</strong></label>
<div class="col-md-3">
<input type="text" class="form-control input-sm" name="issue_id" required>
</div>
Expand Down Expand Up @@ -97,8 +97,8 @@
<td>{{ @item.dependency_type }}</td>
<td><a href="{{ @BASE }}/user/{{ @item.author_username }}">{{ @item.author_name | esc }}</a></td>
<td><a href="{{ @BASE }}/user/{{ @item.owner_username }}">{{ @item.owner_name | esc }}</a></td>
<td data-sort-value="{{ strtotime(@item.start_date) }}" title="{{ date('M j, Y \\a\\t g:ia', strtotime(@item.start_date)) }}">{{ date("n/j/y", strtotime(@item.start_date)) }}</td>
<td data-sort-value="{{ strtotime(@item.due_date) ?: 0 }}">{{ !empty(@item.due_date) ? date("n/j", strtotime(@item.due_date)) : "" }}</td>
<td data-sort-value="{{ @item.start_date ? strtotime(@item.start_date) : 0 }}" title="{{ @item.start_date ? date('M j, Y \\a\\t g:ia', strtotime(@item.start_date)) : '' }}">{{ @item.start_date ? date("n/j/y", strtotime(@item.start_date)) : '' }}</td>
<td data-sort-value="{{ @item.due_date ? strtotime(@item.due_date) : 0 }}">{{ !empty(@item.due_date) ? date("n/j", strtotime(@item.due_date)) : "" }}</td>
<td data-sort-value="{{ @item.status }}">{{ @item.status_name }}</td>
<td><a href="#" class="delete"><span class="fa fa-remove"></span></a></td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion app/view/issues/single/related.html
Expand Up @@ -32,7 +32,7 @@
<td><a href="{{ @BASE }}/user/{{ @item.owner_username }}">{{ @item.owner_name | esc }}</a></td>
<td data-sort-value="{{ strtotime(@item.created_date) }}" title="{{ date('Y-m-d H:i:s', strtotime(@item.created_date)) }}">{{ date("n/j/y", strtotime(@item.created_date)) }}</td>
<td data-sort-value="{{ @item.priority }}">{{ @item.priority_name | esc }}</td>
<td data-sort-value="{{ strtotime(@item.due_date) ?: 0 }}">{{ !empty(@item.due_date) ? date("n/j", strtotime(@item.due_date)) : "" }}</td>
<td data-sort-value="{{ @item.due_date ? strtotime(@item.due_date) : 0 }}">{{ !empty(@item.due_date) ? date("n/j", strtotime(@item.due_date)) : "" }}</td>
<td data-sort-value="{{ @item.status }}">{{ @item.status_name | esc }}</td>
</tr>
</repeat>
Expand Down
12 changes: 8 additions & 4 deletions app/view/user/single.html
Expand Up @@ -42,7 +42,9 @@ <h3>
<li class="active"><a href="#user-created" data-toggle="tab">{{ @dict.created_issues }}&ensp;<span class="badge">{{ @created_issues.total }}</span></a></li>
<li><a href="#user-assigned" data-toggle="tab">{{ @dict.assigned_issues }}&ensp;<span class="badge">{{ @assigned_issues.total }}</span></a></li>
<li><a href="#user-overdue" data-toggle="tab">{{ @dict.overdue_issues }}&ensp;<span class="badge">{{ @overdue_issues.total }}</span></a></li>
<li><a href="#user-tree" data-toggle="tab">{{ @dict.issue_tree }}</a></li>
<check if="{{ @this_user.role != 'group' }}">
<li><a href="#user-tree" data-toggle="tab">{{ @dict.issue_tree }}</a></li>
</check>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="user-created">
Expand All @@ -53,13 +55,15 @@ <h3>
<set issues="{{ @assigned_issues }}" />
<include href="blocks/issue-list.html" />
</div>
<div class="tab-pane fade" id="user-tree">
<p>{{ @dict.loading }}</p>
</div>
<div class="tab-pane fade" id="user-overdue">
<set issues="{{ @overdue_issues }}" />
<include href="blocks/issue-list.html" />
</div>
<check if="{{ @this_user.role != 'group' }}">
<div class="tab-pane fade" id="user-tree">
<p>{{ @dict.loading }}</p>
</div>
</check>
</div>
</div>

Expand Down

0 comments on commit f40236c

Please sign in to comment.