From f424dc053e59e1a726bfebc9e35ba549e187b3e1 Mon Sep 17 00:00:00 2001 From: Bob Olde Hampsink Date: Mon, 31 Oct 2016 09:02:06 +0100 Subject: [PATCH 1/4] Fix comparing of non-existing attribute before, closing issue #15 --- AuditLogPlugin.php | 2 +- README.md | 3 +++ services/AuditLogService.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/AuditLogPlugin.php b/AuditLogPlugin.php index e93a067..0ece6cd 100644 --- a/AuditLogPlugin.php +++ b/AuditLogPlugin.php @@ -32,7 +32,7 @@ public function getName() */ public function getVersion() { - return '0.7.0'; + return '0.7.1'; } /** diff --git a/README.md b/README.md index 7668690..ad442d7 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ phpunit --bootstrap craft/app/tests/bootstrap.php --configuration craft/plugins/ Changelog ================= +###0.7.1### + - Fix comparing of non-existing attribute before, closing issue #15 + ###0.7.0### - Added Craft 2.5 compatibility - Refactored plugin for better readability, quality and testability diff --git a/services/AuditLogService.php b/services/AuditLogService.php index 278dc66..153b0bb 100644 --- a/services/AuditLogService.php +++ b/services/AuditLogService.php @@ -162,7 +162,7 @@ public function elementHasChanged($elementType, $id, $before, $after) // Add labels once again $diff = array(); foreach ($expanded as $key => $value) { - $diff[$key]['label'] = $before[$key]['label']; + $diff[$key]['label'] = isset($before[$key]) ? $before[$key]['label'] : ''; $diff[$key]['value'] = $value['value']; } From 86b33e74913ec3653808f7de0b94e547627fb6be Mon Sep 17 00:00:00 2001 From: Bob Olde Hampsink Date: Mon, 31 Oct 2016 09:11:45 +0100 Subject: [PATCH 2/4] Fix the viewer, too --- services/AuditLogService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/AuditLogService.php b/services/AuditLogService.php index 153b0bb..6c9dcd9 100644 --- a/services/AuditLogService.php +++ b/services/AuditLogService.php @@ -54,7 +54,7 @@ public function view($id) // Set parsed values $diff[$handle] = array( 'label' => $item['label'], - 'changed' => ($item['value'] != $log['before'][$handle]['value']), + 'changed' => !isset($log['before'][$handle]) || ($item['value'] != $log['before'][$handle]['value']), 'after' => $item['value'], 'before' => $log['before'][$handle]['value'], ); From f7bab9f150026dcf5967247212787ed35b5e7c57 Mon Sep 17 00:00:00 2001 From: Bob Olde Hampsink Date: Mon, 31 Oct 2016 09:12:48 +0100 Subject: [PATCH 3/4] More viewer fixes --- services/AuditLogService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/AuditLogService.php b/services/AuditLogService.php index 6c9dcd9..771344f 100644 --- a/services/AuditLogService.php +++ b/services/AuditLogService.php @@ -56,7 +56,7 @@ public function view($id) 'label' => $item['label'], 'changed' => !isset($log['before'][$handle]) || ($item['value'] != $log['before'][$handle]['value']), 'after' => $item['value'], - 'before' => $log['before'][$handle]['value'], + 'before' => isset($log['before'][$handle]) ? $log['before'][$handle]['value'] : '', ); } From e2dd9b71738a08dedb9621d31f77e0ef8c2d9e30 Mon Sep 17 00:00:00 2001 From: Bob Olde Hampsink Date: Mon, 31 Oct 2016 09:14:33 +0100 Subject: [PATCH 4/4] Set license in composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 897e453..cb0fb5f 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "email": "b.oldehampsink@itmundi.nl" } ], + "license": "MIT", "type": "craft-plugin", "require": { "composer/installers": "~1.0"