Updated comments again :-/

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-05-15 17:52:50 +01:00
parent c7accb4599
commit cb22a3d556
2 changed files with 19 additions and 11 deletions

View file

@ -1051,15 +1051,19 @@ class AssetsController extends Controller
if ($asset) { if ($asset) {
/** /**
* We don't want to log this as a normal update, so let's bypass that using unsetEventDispatcher(), * Even though we do a save() further down, we don't want to log this as a "normal" asset update,
* otherwise the audit will create an action_log entry and so will be saving of the asset model * which would trigger the Asset Observer and would log an asset *update* log entry (because the
* with the de-normed fields (next_audit_date, etc.) But invoking unsetEventDispatcher() will bypass * de-normed fields like next_audit_date on the asset itself will change on save()) *in addition* to
* normal model-level validation that's usually handled at the observer ) * the audit log entry we're creating through this controller.
* *
* We handle validation on the save by checking if the asset is valid via the ->isValid() method, * To prevent this double-logging (one for update and one for audit), we skip the observer and bypass
* that de-normed update log entry by using unsetEventDispatcher(), BUT invoking unsetEventDispatcher()
* will bypass normal model-level validation that's usually handled at the observer )
*
* We handle validation on the save() by checking if the asset is valid via the ->isValid() method,
* which manually invokes Watson Validating to make sure the asset's model is valid. * which manually invokes Watson Validating to make sure the asset's model is valid.
* *
* @see App\Observers\AssetObserver::updating() * @see \App\Observers\AssetObserver::updating()
*/ */
$asset->unsetEventDispatcher(); $asset->unsetEventDispatcher();
$asset->next_audit_date = $dt; $asset->next_audit_date = $dt;

View file

@ -881,12 +881,16 @@ class AssetsController extends Controller
$asset = Asset::findOrFail($id); $asset = Asset::findOrFail($id);
/** /**
* We don't want to log this as a normal update, so let's bypass that using unsetEventDispatcher(), * Even though we do a save() further down, we don't want to log this as a "normal" asset update,
* otherwise the audit will create an action_log entry and so will be saving of the asset model * which would trigger the Asset Observer and would log an asset *update* log entry (because the
* with the de-normed fields (next_audit_date, etc.) But invoking unsetEventDispatcher() will bypass * de-normed fields like next_audit_date on the asset itself will change on save()) *in addition* to
* normal model-level validation that's usually handled at the observer ) * the audit log entry we're creating through this controller.
* *
* We handle validation on the save by checking if the asset is valid via the ->isValid() method, * To prevent this double-logging (one for update and one for audit), we skip the observer and bypass
* that de-normed update log entry by using unsetEventDispatcher(), BUT invoking unsetEventDispatcher()
* will bypass normal model-level validation that's usually handled at the observer )
*
* We handle validation on the save() by checking if the asset is valid via the ->isValid() method,
* which manually invokes Watson Validating to make sure the asset's model is valid. * which manually invokes Watson Validating to make sure the asset's model is valid.
* *
* @see \App\Observers\AssetObserver::updating() * @see \App\Observers\AssetObserver::updating()