Skip to content

Commit

Permalink
API Explicitly deprecate legacy file resolution (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Feb 28, 2023
1 parent 9706028 commit 4d68ca9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/FilenameParsing/LegacyFileIDHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,34 @@ public function parseFileID($fileID)
return null;
}

// This helper is only used if the natural and hash helpers have already failed to parse the ID
// So if we can parse the ID here it means the project has a deprecated legacy file structure.
$deprecationMessage = 'Use of legacy file resolution strategies is deprecated.'
. ' See https://docs.silverstripe.org/en/4/developer_guides/files/file_migration/.'
. ' After migrating your files, change your file resolution configuration to match the defaults:'
. ' https://github.com/silverstripe/silverstripe-installer/blob/4/app/_config/assets.yml';


// Can't have a resampled folder without a variant
if (empty($matches['variant']) && strpos($fileID ?? '', '_resampled') !== false) {
return $this->parseSilverStripe30VariantFileID($fileID);
$parsed = $this->parseSilverStripe30VariantFileID($fileID);
if ($parsed) {
Deprecation::notice('4.13.0', $deprecationMessage, Deprecation::SCOPE_GLOBAL);
}
return $parsed;
}

$filename = $matches['folder'] . $matches['basename'] . $matches['extension'];
return new ParsedFileID(
$parsed = new ParsedFileID(
$filename,
'',
isset($matches['variant']) ? str_replace('/', '_', $matches['variant']) : '',
$fileID
);
if ($parsed) {
Deprecation::notice('4.13.0', $deprecationMessage, Deprecation::SCOPE_GLOBAL);
}
return $parsed;
}

/**
Expand Down

0 comments on commit 4d68ca9

Please sign in to comment.