Skip to content

Commit

Permalink
Merge branch 'release/1.10.41.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed May 11, 2023
2 parents 462a952 + 170d0a4 commit 0fa0ed5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v1.10.41.2
## 05/11/2023

1. [](#improved)
* Fixed an issue with `lastBackup()` that caused admin dashboard to fail with an error.

# v1.10.41.1
## 05/09/2023

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Admin Panel
slug: admin
type: plugin
version: 1.10.41.1
version: 1.10.41.2
description: Adds an advanced administration panel to manage your site
icon: empire
author:
Expand Down
14 changes: 8 additions & 6 deletions classes/plugin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1439,24 +1439,26 @@ public function logEntry()
public function lastBackup()
{
$backup_file = $this->grav['locator']->findResource('log://backup.log');
$content = null;

if (!file_exists($backup_file)) {
if ($backup_file) {
$file = JsonFile::instance((string) $backup_file);
$content = $file->content() ?? null;
}

if (!file_exists($backup_file) || is_null($content) || !isset($content['time'])) {
return [
'days' => '∞',
'chart_fill' => 100,
'chart_empty' => 0
];
}
$file = JsonFile::instance($backup_file);
$content = $file->content();

$backup = new \DateTime();
$backup->setTimestamp($content['time']);
$diff = $backup->diff(new \DateTime());

$days = $diff->days;
$days = $diff->days;
$chart_fill = $days > 30 ? 100 : round($days / 30 * 100);

return [
'days' => $days,
'chart_fill' => $chart_fill,
Expand Down

0 comments on commit 0fa0ed5

Please sign in to comment.