From 4584990cc35455bd87eed03b9ce8fb320ed591e3 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Mon, 4 Dec 2017 23:00:55 -0800 Subject: [PATCH 1/2] Cleaner re-implementation of loop-detection for asset-assigned-assets (#4553) * Cleaner re-implementation of loop-detection for asset-assigned-assets * Get rid of the other static and pass it along recursively too. --- app/Console/Commands/SyncAssetLocations.php | 2 +- app/Models/Asset.php | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/Console/Commands/SyncAssetLocations.php b/app/Console/Commands/SyncAssetLocations.php index 98279eca3..25e27c742 100644 --- a/app/Console/Commands/SyncAssetLocations.php +++ b/app/Console/Commands/SyncAssetLocations.php @@ -109,7 +109,7 @@ class SyncAssetLocations extends Command $assigned_asset_asset->unsetEventDispatcher(); $assigned_asset_asset->save(); } else { - $output['warn'][] ='Asset Assigned asset ' . $assigned_asset_asset->assetLoc()->id. ' ('.$assigned_asset_asset->asset_tag.') does not seem to have a valid location'; + $output['warn'][] ='Asset Assigned asset ' . $assigned_asset_asset->id. ' ('.$assigned_asset_asset->asset_tag.') does not seem to have a valid location'; } $bar->advance(); diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 9924d83ee..15510e858 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -257,13 +257,10 @@ class Asset extends Depreciable /** * Get the asset's location based on the assigned user **/ - public function assetLoc() + public function assetLoc($iterations = 1,$first_asset = null) { - static $iterations=0; - static $first_asset; if (!empty($this->assignedType())) { if ($this->assignedType() == self::ASSET) { - $iterations++; if(!$first_asset) { $first_asset=$this; } @@ -272,7 +269,7 @@ class Asset extends Depreciable } $assigned_to=Asset::find($this->assigned_to); //have to do this this way because otherwise it errors if ($assigned_to) { - return $assigned_to->assetLoc(); + return $assigned_to->assetLoc($iterations + 1, $first_asset); } // Recurse until we have a final location } if ($this->assignedType() == self::LOCATION) { From 28fdbdd5d848fe8102796daaeedd568cb5cbc61c Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 4 Dec 2017 23:50:45 -0800 Subject: [PATCH 2/2] Bumped version --- config/version.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/version.php b/config/version.php index f9e59a80a..afef58b85 100644 --- a/config/version.php +++ b/config/version.php @@ -1,10 +1,10 @@ 'v4.1.6', - 'full_app_version' => 'v4.1.6 - build 2834', - 'build_version' => '2834', + 'app_version' => 'v4.1.7', + 'full_app_version' => 'v4.1.7 - build 3031-g4f3c932', + 'build_version' => '3031', 'prerelease_version' => '', - 'hash_version' => 'g83c8449', - 'full_hash' => 'v4.1.6', + 'hash_version' => 'g4f3c932', + 'full_hash' => 'v4.1.6-37-g4f3c932', 'branch' => 'develop', -); +); \ No newline at end of file