Skip to content

Commit

Permalink
Merge branch '1' into 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Nov 21, 2022
2 parents a2733b9 + c98b8fb commit d078f57
Show file tree
Hide file tree
Showing 44 changed files with 607 additions and 75 deletions.
4 changes: 4 additions & 0 deletions src/Dev/FixFolderPermissionsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Queries\SQLUpdate;
use SilverStripe\Security\InheritedPermissionFlusher;
Expand All @@ -16,6 +17,8 @@
* @see https://github.com/silverstripe/silverstripe-secureassets
* This helper class resets the `CanViewType` of files that are `NULL`.
* You need to flush your cache after running this via CLI.
*
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
class FixFolderPermissionsHelper
{
Expand All @@ -30,6 +33,7 @@ class FixFolderPermissionsHelper

public function __construct()
{
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
$this->logger = new NullLogger();
}

Expand Down
9 changes: 8 additions & 1 deletion src/Dev/Tasks/FileMigrationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use SilverStripe\Core\Environment;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataQuery;
Expand All @@ -27,6 +28,8 @@
* Service to help migrate File dataobjects to the new APL.
*
* This service does not alter these records in such a way that prevents downgrading back to 3.x
*
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
class FileMigrationHelper
{
Expand Down Expand Up @@ -59,6 +62,9 @@ class FileMigrationHelper

public function __construct()
{
Deprecation::withNoReplacement(function () {
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
});
$this->logger = new NullLogger();
}

Expand Down Expand Up @@ -546,11 +552,12 @@ private function chunk(DataList $query)
/**
* Get map of File IDs to legacy filenames
*
* @deprecated 4.4.0
* @deprecated 1.4.0 Will be removed without equivalent functionality to replace it
* @return array
*/
protected function getFilenameArray()
{
Deprecation::notice('1.4.0', 'Will be removed without equivalent functionality to replace it');
$table = DataObject::singleton(File::class)->baseTable();
// Convert original query, ensuring the legacy "Filename" is included in the result
/** @skipUpgrade */
Expand Down
5 changes: 4 additions & 1 deletion src/Dev/Tasks/FolderMigrationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use SilverStripe\Core\Environment;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataQuery;
Expand All @@ -20,7 +21,8 @@
*
* This service does not alter these records in such a way that prevents downgrading back to 3.x
*
* @internal This class is not a part of Silverstripe CMS public API
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*
*/
class FolderMigrationHelper
{
Expand All @@ -38,6 +40,7 @@ class FolderMigrationHelper

public function __construct()
{
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
$this->logger = new NullLogger();
}

Expand Down
3 changes: 3 additions & 0 deletions src/Dev/Tasks/LegacyThumbnailMigrationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataQuery;
use SilverStripe\ORM\DB;
Expand All @@ -37,6 +38,7 @@
* - Does not filter out unused CMS thumbnails (they're using a new size now)
* - Does not move legacy thumbnails to the protected store if the original file
* has been unpublished or protected since an earlier 4.x migration run
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
class LegacyThumbnailMigrationHelper
{
Expand All @@ -52,6 +54,7 @@ class LegacyThumbnailMigrationHelper

public function __construct()
{
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
$this->logger = new NullLogger();
}

Expand Down
6 changes: 6 additions & 0 deletions src/Dev/Tasks/NormaliseAccessMigrationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use SilverStripe\Core\Environment;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Security\Member;
use SilverStripe\Security\Security;
use SilverStripe\Versioned\Versioned;
Expand All @@ -28,6 +29,8 @@
* the appropriate physical location.
*
* This is meant to correct files that got save to the wrong location following the CVE-2019-12245 vulnerability.
*
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
class NormaliseAccessMigrationHelper
{
Expand Down Expand Up @@ -88,6 +91,9 @@ class NormaliseAccessMigrationHelper
*/
public function __construct($base = '')
{
Deprecation::withNoReplacement(function () {
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
});
$this->logger = new NullLogger();
if ($base) {
$this->basePath = $base;
Expand Down
5 changes: 4 additions & 1 deletion src/Dev/Tasks/SecureAssetsMigrationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use SilverStripe\Assets\Folder;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Queries\SQLSelect;

Expand All @@ -25,7 +26,7 @@
*
* See https://github.com/silverstripe/silverstripe-assets/issues/231
*
* @internal
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
class SecureAssetsMigrationHelper
{
Expand All @@ -48,6 +49,8 @@ class SecureAssetsMigrationHelper

public function __construct()
{
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);

$this->logger = new NullLogger();

$this->htaccessRegexes = [
Expand Down
3 changes: 3 additions & 0 deletions src/Dev/Tasks/TagsToShortcodeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use SilverStripe\Assets\File;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\Connect\DatabaseException;
use SilverStripe\ORM\Connect\Query;
use SilverStripe\ORM\DataObject;
Expand All @@ -31,6 +32,7 @@
* SS4 and its File Migration Task changes the way in which files are stored in the assets folder, with files placed
* in subfolders named with partial hashmap values of the file version. This helper class goes through the HTML content
* fields looking for instances of image links, and corrects the link path to what it should be, with an image shortcode.
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
class TagsToShortcodeHelper
{
Expand Down Expand Up @@ -84,6 +86,7 @@ public function setLogger(LoggerInterface $logger)
*/
public function __construct($baseClass = null, $includeBaseClass = false)
{
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
$flysystemAssetStore = singleton(AssetStore::class);
if (!($flysystemAssetStore instanceof FlysystemAssetStore)) {
throw new InvalidArgumentException("FlysystemAssetStore missing");
Expand Down
8 changes: 8 additions & 0 deletions src/Dev/Tasks/TagsToShortcodeTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
use SilverStripe\Assets\Storage\FileHashingService;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\BuildTask;
use SilverStripe\Dev\Deprecation;

/**
* SS4 and its File Migration Task changes the way in which files are stored in the assets folder, with files placed
* in subfolders named with partial hashmap values of the file version. This build task goes through the HTML content
* fields looking for instances of image links, and corrects the link path to what it should be, with an image shortcode.
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
class TagsToShortcodeTask extends BuildTask
{
Expand All @@ -25,6 +27,12 @@ class TagsToShortcodeTask extends BuildTask
- includeBaseClass: Whether to include the base class' HTMLText fields or not
";

public function __construct()
{
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
parent::__construct();
}

/**
* @param \SilverStripe\Control\HTTPRequest $request
* @throws \ReflectionException
Expand Down
14 changes: 12 additions & 2 deletions src/Dev/Tasks/VersionedFilesMigrationTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

use SilverStripe\Assets\Dev\VersionedFilesMigrator;
use SilverStripe\Dev\BuildTask;
use SilverStripe\Dev\Deprecation;

/**
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
class VersionedFilesMigrationTask extends BuildTask
{
const STRATEGY_DELETE = 'delete';
Expand All @@ -15,11 +19,17 @@ class VersionedFilesMigrationTask extends BuildTask

protected $title = 'Migrate versionedfiles';

protected $description = 'If you had the symbiote/silverstripe-versionedfiles module installed on your 3.x site, it
protected $description = 'If you had the symbiote/silverstripe-versionedfiles module installed on your 3.x site, it
is no longer needed in 4.x as this functionality is provided by default. This task will remove the old _versions
folders or protect them, depending on the strategy you use. Use ?strategy=delete or ?strategy=protect (Apache
folders or protect them, depending on the strategy you use. Use ?strategy=delete or ?strategy=protect (Apache
only). [Default: delete]';

public function __construct()
{
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
parent::__construct();
}

/**
* @param HTTPRequest $request
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Dev/TestAssetStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public static function activate($basedir)
Injector::inst()->registerService($generated, GeneratedAssetHandler::class);
Requirements::backend()->setAssetHandler($generated);

// Disable legacy and set defaults
FlysystemAssetStore::config()->set('legacy_filenames', false);
// Set defaults
Director::config()->set('alternate_base_url', '/');
DBFile::config()->set('force_resample', false);
File::config()->set('force_resample', false);
Expand Down
10 changes: 6 additions & 4 deletions src/Dev/VersionedFilesMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
namespace SilverStripe\Assets\Dev;

use SilverStripe\Assets\Filesystem;
use SilverStripe\Assets\Storage\AssetStore;
use SilverStripe\Control\Director;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Path;
use SilverStripe\Dev\BuildTask;
use InvalidArgumentException;
use SilverStripe\Dev\Deprecation;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

/**
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
class VersionedFilesMigrator
{
use Injectable;
Expand Down Expand Up @@ -62,6 +62,8 @@ class VersionedFilesMigrator
*/
public function __construct($strategy = self::STRATEGY_DELETE, $basePath = ASSETS_DIR, $output = true)
{
Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);

if (!in_array($strategy, [self::STRATEGY_DELETE, self::STRATEGY_PROTECT])) {
throw new InvalidArgumentException(sprintf(
'Invalid strategy: %s',
Expand Down
8 changes: 4 additions & 4 deletions src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ public function Link()
}

/**
* @deprecated 4.0
* @deprecated 1.0.0 Use getURL() instead
*/
public function RelativeLink()
{
Deprecation::notice('4.0', 'Use getURL instead, as not all files will be relative to the site root.');
Deprecation::notice('1.0.0', 'Use getURL() instead');
return Director::makeRelative($this->getURL());
}

Expand Down Expand Up @@ -1123,13 +1123,13 @@ public static function format_size($size)
/**
* Convert a php.ini value (eg: 512M) to bytes
*
* @deprecated 5.0 Use Convert::memstring2bytes() instead
* @deprecated 1.12.0 Use Convert::memstring2bytes() instead
* @param string $iniValue
* @return int
*/
public static function ini2bytes($iniValue)
{
Deprecation::notice('5.0', 'Use Convert::memstring2bytes instead');
Deprecation::notice('1.12.0', 'Use Convert::memstring2bytes() instead');
return Convert::memstring2bytes($iniValue);
}

Expand Down
4 changes: 4 additions & 0 deletions src/FileMigrationHelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

/**
* @see FileMigrationHelper class
* @deprecated 1.12.0 Will be removed without equivalent functionality to replace it
*/
use SilverStripe\Assets\Dev\Tasks\FileMigrationHelper;

if (!class_exists('SilverStripe\\Assets\\FileMigrationHelper')) {
Expand Down
2 changes: 0 additions & 2 deletions src/FilenameParsing/FileIDHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

/**
* Helps build and parse Filename Identifiers (ake: FileIDs) according to a predefined format.
*
* @internal This is still an evolving API. It may change in the next minor release.
*/
interface FileIDHelper
{
Expand Down
2 changes: 0 additions & 2 deletions src/FilenameParsing/FileIDHelperResolutionStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* older file format to resolve.
*
* You may also provide a `VersionedStage` to only look at files that were published.
*
* @internal This is still an evolving API. It may change in the next minor release.
*/
class FileIDHelperResolutionStrategy implements FileResolutionStrategy
{
Expand Down
2 changes: 0 additions & 2 deletions src/FilenameParsing/FileResolutionStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

/**
* Represents a strategy for resolving files on a Flysystem Adapter.
*
* @internal This is still an evolving API. It may change in the next minor release.
*/
interface FileResolutionStrategy
{
Expand Down
2 changes: 0 additions & 2 deletions src/FilenameParsing/HashFileIDHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* SilverStripe 4.4.
*
* e.g.: `Uploads/a1312bc34d/sam__ResizedImageWzYwLDgwXQ.jpg`
*
* @internal This is still an evolving API. It may change in the next minor release.
*/
class HashFileIDHelper implements FileIDHelper
{
Expand Down
Loading

0 comments on commit d078f57

Please sign in to comment.