Skip to content

Commit

Permalink
Merge pull request #13456 from marcusmoore/fixes/auto-incrementing-on-74
Browse files Browse the repository at this point in the history
Fixed passing invalid argument to `strpos()`
  • Loading branch information
snipe authored Aug 21, 2023
2 parents 2346bab + dc1a884 commit 79a4d91
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/Observers/AssetObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public function created(Asset $asset)
$tag = $asset->asset_tag;
$prefix = $settings->auto_increment_prefix;
$number = substr($tag, strlen($prefix));
// IF - auto_increment_assets is on, AND (the prefix matches the start of the tag OR there is no prefix)
// IF - auto_increment_assets is on, AND (there is no prefix OR the prefix matches the start of the tag)
// AND the rest of the string after the prefix is all digits, THEN...
if ($settings->auto_increment_assets && (strpos($tag, $prefix) === 0 || $prefix=='') && preg_match('/\d+/',$number) === 1) {
if ($settings->auto_increment_assets && ($prefix=='' || strpos($tag, $prefix) === 0) && preg_match('/\d+/',$number) === 1) {
// new way of auto-trueing-up auto_increment ID's
$next_asset_tag = intval($number, 10) + 1;
// we had to use 'intval' because the $number could be '01234' and
Expand Down

0 comments on commit 79a4d91

Please sign in to comment.