From 3b953941b1ddb456f100b260628d7e7e4e9133a7 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Tue, 1 Dec 2020 11:21:28 -0500 Subject: [PATCH] Remove Deprecated Beta14 Code (#2428) --- framework/core/js/src/common/Component.ts | 38 +--------- framework/core/js/src/common/index.js | 2 +- .../core/js/src/common/utils/patchMithril.js | 24 ------- .../core/js/src/forum/ForumApplication.js | 5 -- .../js/src/forum/components/ComposerBody.js | 6 -- .../core/js/src/forum/states/ComposerState.js | 11 --- .../core/src/Event/PrepareUserGroups.php | 39 ---------- framework/core/src/Foundation/Application.php | 44 ------------ .../src/Notification/MailableInterface.php | 4 +- .../core/src/User/AssertPermissionTrait.php | 72 ------------------- .../core/src/User/Event/GetDisplayName.php | 31 -------- framework/core/src/User/User.php | 8 +-- framework/core/src/helpers.php | 43 ----------- 13 files changed, 4 insertions(+), 323 deletions(-) delete mode 100644 framework/core/src/Event/PrepareUserGroups.php delete mode 100644 framework/core/src/User/AssertPermissionTrait.php delete mode 100644 framework/core/src/User/Event/GetDisplayName.php diff --git a/framework/core/js/src/common/Component.ts b/framework/core/js/src/common/Component.ts index 3a19032a0..00a970f02 100644 --- a/framework/core/js/src/common/Component.ts +++ b/framework/core/js/src/common/Component.ts @@ -1,8 +1,5 @@ import * as Mithril from 'mithril'; -let deprecatedPropsWarned = false; -let deprecatedInitPropsWarned = false; - export interface ComponentAttrs extends Mithril.Attributes {} /** @@ -131,38 +128,5 @@ export default abstract class Component(attrs: T): void { - // Deprecated, part of Mithril 2 BC layer - if ('initProps' in this && !deprecatedInitPropsWarned) { - deprecatedInitPropsWarned = true; - console.warn('initProps is deprecated, please use initAttrs instead.'); - (this as any).initProps(attrs); - } - } - - // BEGIN DEPRECATED MITHRIL 2 BC LAYER - - /** - * The attributes passed into the component. - * - * @see https://mithril.js.org/components.html#passing-data-to-components - * - * @deprecated, use attrs instead. - */ - get props() { - if (!deprecatedPropsWarned) { - deprecatedPropsWarned = true; - console.warn('this.props is deprecated, please use this.attrs instead.'); - } - return this.attrs; - } - set props(props) { - if (!deprecatedPropsWarned) { - deprecatedPropsWarned = true; - console.warn('this.props is deprecated, please use this.attrs instead.'); - } - this.attrs = props; - } - - // END DEPRECATED MITHRIL 2 BC LAYER + protected static initAttrs(attrs: T): void {} } diff --git a/framework/core/js/src/common/index.js b/framework/core/js/src/common/index.js index 13fb5b4e4..f4f176d44 100644 --- a/framework/core/js/src/common/index.js +++ b/framework/core/js/src/common/index.js @@ -1,6 +1,6 @@ import 'expose-loader?$!expose-loader?jQuery!jquery'; import 'expose-loader?m!mithril'; -import 'expose-loader?moment!expose-loader?dayjs!dayjs'; +import 'expose-loader?dayjs!dayjs'; import 'expose-loader?m.bidi!m.attrs.bidi'; import 'bootstrap/js/affix'; import 'bootstrap/js/dropdown'; diff --git a/framework/core/js/src/common/utils/patchMithril.js b/framework/core/js/src/common/utils/patchMithril.js index a1b114167..ee5fcc58f 100644 --- a/framework/core/js/src/common/utils/patchMithril.js +++ b/framework/core/js/src/common/utils/patchMithril.js @@ -1,9 +1,3 @@ -import withAttr from './withAttr'; -import Stream from './Stream'; - -let deprecatedMPropWarned = false; -let deprecatedMWithAttrWarned = false; - export default function patchMithril(global) { const defaultMithril = global.m; @@ -22,23 +16,5 @@ export default function patchMithril(global) { Object.keys(defaultMithril).forEach((key) => (modifiedMithril[key] = defaultMithril[key])); - // BEGIN DEPRECATED MITHRIL 2 BC LAYER - modifiedMithril.prop = function (...args) { - if (!deprecatedMPropWarned) { - deprecatedMPropWarned = true; - console.warn('m.prop() is deprecated, please use the Stream util (flarum/utils/Streams) instead.'); - } - return Stream.bind(this)(...args); - }; - - modifiedMithril.withAttr = function (...args) { - if (!deprecatedMWithAttrWarned) { - deprecatedMWithAttrWarned = true; - console.warn("m.withAttr() is deprecated, please use flarum's withAttr util (flarum/utils/withAttr) instead."); - } - return withAttr.bind(this)(...args); - }; - // END DEPRECATED MITHRIL 2 BC LAYER - global.m = modifiedMithril; } diff --git a/framework/core/js/src/forum/ForumApplication.js b/framework/core/js/src/forum/ForumApplication.js index 78f300a60..041b21275 100644 --- a/framework/core/js/src/forum/ForumApplication.js +++ b/framework/core/js/src/forum/ForumApplication.js @@ -90,11 +90,6 @@ export default class ForumApplication extends Application { * @type {DiscussionListState} */ this.discussions = new DiscussionListState({}, this); - - /** - * @deprecated beta 14, remove in beta 15. - */ - this.cache.discussionList = this.discussions; } /** diff --git a/framework/core/js/src/forum/components/ComposerBody.js b/framework/core/js/src/forum/components/ComposerBody.js index ff934bb1b..d81a2c87a 100644 --- a/framework/core/js/src/forum/components/ComposerBody.js +++ b/framework/core/js/src/forum/components/ComposerBody.js @@ -44,12 +44,6 @@ export default class ComposerBody extends Component { } this.composer.fields.content(this.attrs.originalContent || ''); - - /** - * @deprecated BC layer, remove in Beta 15. - */ - this.content = this.composer.fields.content; - this.editor = this.composer; } view() { diff --git a/framework/core/js/src/forum/states/ComposerState.js b/framework/core/js/src/forum/states/ComposerState.js index 736a3e68d..dd4ed9645 100644 --- a/framework/core/js/src/forum/states/ComposerState.js +++ b/framework/core/js/src/forum/states/ComposerState.js @@ -34,11 +34,6 @@ class ComposerState { this.editor = null; this.clear(); - - /** - * @deprecated BC layer, remove in Beta 15. - */ - this.component = this; } /** @@ -77,12 +72,6 @@ class ComposerState { this.fields = { content: Stream(''), }; - - /** - * @deprecated BC layer, remove in Beta 15. - */ - this.content = this.fields.content; - this.value = this.fields.content; } /** diff --git a/framework/core/src/Event/PrepareUserGroups.php b/framework/core/src/Event/PrepareUserGroups.php deleted file mode 100644 index 813c7e8e6..000000000 --- a/framework/core/src/Event/PrepareUserGroups.php +++ /dev/null @@ -1,39 +0,0 @@ -user = $user; - $this->groupIds = &$groupIds; - } -} diff --git a/framework/core/src/Foundation/Application.php b/framework/core/src/Foundation/Application.php index 10fa4448b..59398f9f5 100644 --- a/framework/core/src/Foundation/Application.php +++ b/framework/core/src/Foundation/Application.php @@ -153,50 +153,6 @@ class Application $this->register(new EventServiceProvider($this->container)); } - /** - * Get the base path of the Laravel installation. - * - * @return string - * @deprecated Will be removed in Beta.15. - */ - public function basePath() - { - return $this->paths->base; - } - - /** - * Get the path to the public / web directory. - * - * @return string - * @deprecated Will be removed in Beta.15. - */ - public function publicPath() - { - return $this->paths->public; - } - - /** - * Get the path to the storage directory. - * - * @return string - * @deprecated Will be removed in Beta.15. - */ - public function storagePath() - { - return $this->paths->storage; - } - - /** - * Get the path to the vendor directory where dependencies are installed. - * - * @return string - * @deprecated Will be removed in Beta.15. - */ - public function vendorPath() - { - return $this->paths->vendor; - } - /** * Register a service provider with the application. * diff --git a/framework/core/src/Notification/MailableInterface.php b/framework/core/src/Notification/MailableInterface.php index 14360d757..d52664668 100644 --- a/framework/core/src/Notification/MailableInterface.php +++ b/framework/core/src/Notification/MailableInterface.php @@ -25,7 +25,5 @@ interface MailableInterface * * @return string */ - // TODO: This is temporarily commented out to avoid BC breaks between beta 13 and beta 14. - // It should be uncommented before beta 15. - // public function getEmailSubject(TranslatorInterface $translator); + public function getEmailSubject(TranslatorInterface $translator); } diff --git a/framework/core/src/User/AssertPermissionTrait.php b/framework/core/src/User/AssertPermissionTrait.php deleted file mode 100644 index 1996ead5e..000000000 --- a/framework/core/src/User/AssertPermissionTrait.php +++ /dev/null @@ -1,72 +0,0 @@ -assertCan($ability); - */ -trait AssertPermissionTrait -{ - /** - * Ensure the current user is allowed to do something. - * - * If the condition is not met, an exception will be thrown that signals the - * lack of permissions. This is about *authorization*, i.e. retrying such a - * request / operation without a change in permissions (or using another - * user account) is pointless. - * - * @param bool $condition - * @throws PermissionDeniedException - */ - protected function assertPermission($condition) - { - if (! $condition) { - throw new PermissionDeniedException; - } - } - - /** - * Ensure the given actor is authenticated. - * - * This will throw an exception for guest users, signaling that - * *authorization* failed. Thus, they could retry the operation after - * logging in (or using other means of authentication). - * - * @param User $actor - * @throws NotAuthenticatedException - */ - protected function assertRegistered(User $actor) - { - $actor->assertRegistered(); - } - - /** - * @param User $actor - * @param string $ability - * @param mixed $arguments - * @throws PermissionDeniedException - */ - protected function assertCan(User $actor, $ability, $arguments = []) - { - $actor->assertCan($ability, $arguments); - } - - /** - * @param User $actor - * @throws PermissionDeniedException - */ - protected function assertAdmin(User $actor) - { - $actor->assertCan('administrate'); - } -} diff --git a/framework/core/src/User/Event/GetDisplayName.php b/framework/core/src/User/Event/GetDisplayName.php deleted file mode 100644 index 9ceb5e9e1..000000000 --- a/framework/core/src/User/Event/GetDisplayName.php +++ /dev/null @@ -1,31 +0,0 @@ -user = $user; - } -} diff --git a/framework/core/src/User/User.php b/framework/core/src/User/User.php index 168f3a594..6f8714539 100644 --- a/framework/core/src/User/User.php +++ b/framework/core/src/User/User.php @@ -15,7 +15,6 @@ use Flarum\Database\AbstractModel; use Flarum\Database\ScopeVisibilityTrait; use Flarum\Discussion\Discussion; use Flarum\Event\ConfigureUserPreferences; -use Flarum\Event\PrepareUserGroups; use Flarum\Foundation\EventGeneratorTrait; use Flarum\Group\Group; use Flarum\Group\Permission; @@ -30,7 +29,6 @@ use Flarum\User\Event\CheckingPassword; use Flarum\User\Event\Deleted; use Flarum\User\Event\EmailChanged; use Flarum\User\Event\EmailChangeRequested; -use Flarum\User\Event\GetDisplayName; use Flarum\User\Event\PasswordChanged; use Flarum\User\Event\Registered; use Flarum\User\Event\Renamed; @@ -327,8 +325,7 @@ class User extends AbstractModel */ public function getDisplayNameAttribute() { - // Event is deprecated in beta 14, remove in beta 15. - return static::$dispatcher->until(new GetDisplayName($this)) ?: static::$displayNameDriver->displayName($this); + return static::$displayNameDriver->displayName($this); } /** @@ -722,9 +719,6 @@ class User extends AbstractModel $groupIds = array_merge($groupIds, [Group::MEMBER_ID], $this->groups->pluck('id')->all()); } - /** @deprecated in beta 14, remove in beta 15 */ - event(new PrepareUserGroups($this, $groupIds)); - foreach (static::$groupProcessors as $processor) { $groupIds = $processor($this, $groupIds); } diff --git a/framework/core/src/helpers.php b/framework/core/src/helpers.php index 4d0e121c0..d46660297 100644 --- a/framework/core/src/helpers.php +++ b/framework/core/src/helpers.php @@ -7,7 +7,6 @@ * LICENSE file that was distributed with this source code. */ -use Flarum\Foundation\Paths; use Illuminate\Container\Container; if (! function_exists('app')) { @@ -28,48 +27,6 @@ if (! function_exists('app')) { } } -if (! function_exists('base_path')) { - /** - * Get the path to the base of the install. - * - * @param string $path - * @return string - * @deprecated Will be removed in Beta.15. - */ - function base_path($path = '') - { - return app(Paths::class)->base.($path ? DIRECTORY_SEPARATOR.$path : $path); - } -} - -if (! function_exists('public_path')) { - /** - * Get the path to the public folder. - * - * @param string $path - * @return string - * @deprecated Will be removed in Beta.15. - */ - function public_path($path = '') - { - return app(Paths::class)->public.($path ? DIRECTORY_SEPARATOR.$path : $path); - } -} - -if (! function_exists('storage_path')) { - /** - * Get the path to the storage folder. - * - * @param string $path - * @return string - * @deprecated Will be removed in Beta.15. - */ - function storage_path($path = '') - { - return app(Paths::class)->storage.($path ? DIRECTORY_SEPARATOR.$path : $path); - } -} - if (! function_exists('event')) { /** * Fire an event and call the listeners.