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/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" diff --git a/services/AuditLogService.php b/services/AuditLogService.php index 278dc66..771344f 100644 --- a/services/AuditLogService.php +++ b/services/AuditLogService.php @@ -54,9 +54,9 @@ 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'], + 'before' => isset($log['before'][$handle]) ? $log['before'][$handle]['value'] : '', ); } @@ -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']; }