diff --git a/.upgrade.yml b/.upgrade.yml index 2158c1164..3cebded3c 100644 --- a/.upgrade.yml +++ b/.upgrade.yml @@ -953,3 +953,151 @@ excludedPaths: - '*vendor*' doctorTasks: SilverStripe\Dev\Upgrade\UpgradeBootstrap: src/Dev/Upgrade/UpgradeBootstrap.php +warnings: + classes: + 'Object': + message: 'Replaced with traits' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#object-replace' + 'SS_Log': + message: 'Replaced with a PSR-3 logger' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#psr3-logging' + 'Session': + message: 'Session is no longer statically accessible' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#session' + 'SQLQuery': + message: 'Use SQLSelect instead' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#sqlquery' + 'SilverStripe\AssetAdmin\Forms\UploadField': + message: 'Class implementations should be wrapped with FileHandleField' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#uploadfield' + 'CompositeDBField': + message: 'Class has been replaced with an abstract DBComposite' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#compositedbfield' + 'BuildTask': + message: 'Now needs a $segment property to run it' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#buildtask-segment' + 'RestfulService': + message: 'Removed from core, please use Guzzle' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#restfulservice' + 'Oembed': + message: 'Removed from core, please use third party lib' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#oembed' + 'SS_Cache': + message: 'Using symfony/cache now' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#cache' + 'LeftAndMain_TreeNode': + message: 'Renamed to CMSMain_TreeNode' + 'SilverStripe\ORM\Hierarchy->getChildrenAsUL()': + message: 'Replaced with renderChildren()' + 'SilverStripe\Security\Permission::flush_permission_cache()': + message: 'Renamed to reset()' + methods: + 'setFilename()': + message: 'Filenames should not be set directly any more' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#write-file-dataobject' + 'File::handle_shortcode()': + message: 'Has been removed' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#file-shortcode' + 'database_fields()': + message: 'Does not have a second parameter any more' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#dataobject-db-database-fields' + 'Authenticator::register()': + message: 'Custom authenticators work differently now' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#custom-authenticators' + 'Object::useCustomClass()': + message: 'Use injector instead' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#custom-authenticators' + 'Director::setUrlParams()': + message: 'Method removed' + 'manyManyComponent()': + message: 'DataObject->manyManyComponent() moved to DataObjectSchema, access through getSchema()' + 'belongsToComponent()': + message: 'DataObject->belongsToComponent() moved to DataObjectSchema, access through getSchema()' + 'hasOneComponent()': + message: 'DataObject->hasOneComponent() moved to DataObjectSchema, access through getSchema()' + 'hasManyComponent()': + message: 'DataObject->hasManyComponent() moved to DataObjectSchema, access through getSchema()' + 'getRemoteJoinField()': + message: 'DataObject->getRemoteJoinField() moved to DataObjectSchema, access through getSchema()' + 'has_own_table()': + message: 'DataObject::has_own_table() moved to DataObjectSchema->classHasTable(), access through getSchema()' + 'database_fields()': + message: 'DataObject::database_fields() moved to DataObjectSchema->databaseFields(), access through getSchema()' + 'database_fields()': + message: 'DataObject::database_fields() moved to DataObjectSchema->databaseFields(), access through getSchema()' + 'manyManyExtraFieldsForComponent()': + message: 'DataObject::manyManyExtraFieldsForComponent() moved to DataObjectSchema, access through getSchema()' + 'validateModelDefinitions()': + message: 'Removed DataObject->validateModelDefinitions()' + 'hasOwnTableDatabaseField()': + message: 'DataObject->hasOwnTableDatabaseField() has been replaced with DataObjectSchema::fieldSpec(), access through getSchema()' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#dataobject-has-own' + 'has_own_table_database_field()': + message: 'DataObject::has_own_table_database_field() has been replaced with DataObjectSchema::fieldSpec(), access through getSchema()' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#dataobject-has-own' + 'hasDatabaseFields()': + message: 'DataObject->hasDatabaseFields() has been replaced with DataObjectSchema::fieldSpec(), access through getSchema()' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#dataobject-has-own' + 'is_composite_field()' + message: 'Removed DataObject::is_composite_field. Use DataObjectSchema::compositeField instead.' + 'custom_database_fields()': + message: 'Removed DataObject::custom_database_fields. Use DataObjectSchema::databaseFields' + props: + 'class': + message: '$this->class access has been removed' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#object-replace' + functions: + 'file_get_contents()': + message: 'Use new asset abstraction' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#asset-storage' + 'file_put_contents()': + message: 'Use new asset abstraction' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#asset-storage' + constants: + 'SS_TRUSTED_PROXY_HOST_HEADER': + message: 'See TrustedProxyMiddleware' + 'SS_TRUSTED_PROXY_PROTOCOL_HEADER': + message: 'See TrustedProxyMiddleware' + 'SS_TRUSTED_PROXY_IP_HEADER': + message: 'See TrustedProxyMiddleware' + 'SS_TRUSTED_PROXY_HOST_HEADER': + message: 'See TrustedProxyMiddleware' + 'MODULES_PATH': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'MODULES_DIR': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'FRAMEWORK_PATH': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'FRAMEWORK_DIR': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'CMS_PATH': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'CMS_DIR': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'FRAMEWORK_ADMIN_PATH': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'FRAMEWORK_ADMIN_DIR': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'FRAMEWORK_ADMIN_THIRDPARTY_DIR': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'THEMES_PATH': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'THEMES_DIR': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'THIRDPARTY_PATH': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' + 'THIRDPARTY_DIR': + message: 'Path constants have been deprecated, use the Requirements and ModuleResourceLoader APIs' + url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#module-paths' \ No newline at end of file diff --git a/docs/en/04_Changelogs/4.0.0.md b/docs/en/04_Changelogs/4.0.0.md index ef7c73dd8..023b861e9 100644 --- a/docs/en/04_Changelogs/4.0.0.md +++ b/docs/en/04_Changelogs/4.0.0.md @@ -129,6 +129,20 @@ For a full list of renamed classes, check the `.upgrade.yml` definitions in each The rename won't affect class-based permission codes or database table names. +##### Using the upgrader tool to get upgrade tips on your code + +While there's some code we can automatically rewrite, other uses of changed SilverStripe APIs aren't that obvious. +You can use our heuristics to get some hints on where you need to review code manually. +Hints will generally point to more detail about a specific upgrade in this guide. +This task should be run *after* `upgrade-code upgrade`. + +``` +~/.composer/vendor/bin/upgrade-code inspect ./mysite +``` + +These hints only cover a part of the upgrade work, +but can serve as a good indicator for where to start. + ##### Upgrade references to literal or class table names In 3.x the class name of any DataObject matched the table name, but in 4.x all classes are namespaced, and it is @@ -251,7 +265,7 @@ visibility) will make it 4.0 compatible. ]; ``` -#### Upgrade module paths in file references +#### Upgrade module paths in file references You should no longer rely on modules being placed in a deterministic folder (e.g. `/framework`), and use getters on the [Module](api:SilverStripe\Core\Manifest\Module) object instead. @@ -340,7 +354,7 @@ or explicitly switch to the "copy" mode to avoid symlinks. The below sections deal with upgrades to specific parts of various API. Projects which rely on certain API should be upgraded as appropriate using any of the relevant processes documented below. -#### Upgrade references of SS_Log to use PSR-3 logging +#### Upgrade references of SS_Log to use PSR-3 logging One of the great changes that comes with SilverStripe 4 is the introduction of [PSR-3](http://www.php-fig.org/psr/psr-3/) compatible logger interfaces. This @@ -398,7 +412,7 @@ implements the `Monolog\Formatter\FormatterInterface` interface. #### Upgrade `mysite/_config.php` The globals `$database` and `$databaseConfig` are deprecated. You should upgrade your -site _config.php files to use the `.env` configuration (below). +site `_config.php` files to use the `.env` configuration (below). `conf/ConfigureFromEnv.php` is also no longer used, and references to this file should be deleted. @@ -488,7 +502,7 @@ which is no longer necessary. See [Environment Management docs](/getting-started/environment_management/) for full details. -#### Replace usages of Object class +#### Replace usages of Object class Object has been superseded by a trio of traits which replace components of this legacy class: @@ -562,7 +576,7 @@ Extensions +$extensions = DataObject::get_extensions(File::class); // alternate ``` -#### Upgrade references to Session object +#### Upgrade references to Session object Session object is no longer statically accessible via `Session::inst()`. Instead, Session is a member of the current request. @@ -740,6 +754,8 @@ class MyObject extends ViewableData After: ```php +use SilverStripe\Core\Convert; + class MyObject extends SilverStripe\View\ViewableData { private static $casting = [ @@ -748,7 +764,7 @@ class MyObject extends SilverStripe\View\ViewableData public function getSomeHTML { - $title = SilverStripe\Core\Convert::raw2xml($this->Title); + $title = Convert::raw2xml($this->Title); return "