mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 12:43:52 +08:00
Remove deprecated code from beta 16 (#2705)
This commit is contained in:
parent
dd2712d5c8
commit
897e778800
|
@ -74,8 +74,7 @@
|
|||
"Flarum\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/helpers.php",
|
||||
"src/TranslatorInterface.php"
|
||||
"src/helpers.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
|
|
@ -36,8 +36,6 @@ import HeaderSecondary from './components/HeaderSecondary';
|
|||
import ComposerButton from './components/ComposerButton';
|
||||
import DiscussionList from './components/DiscussionList';
|
||||
import ReplyPlaceholder from './components/ReplyPlaceholder';
|
||||
import TextEditor from '../common/components/TextEditor'; // @deprecated beta 16, remove beta 17. Moved to common.
|
||||
import TextEditorButton from '../common/components/TextEditorButton'; // @deprecated beta 16, remove beta 17. Moved to common.
|
||||
import AvatarEditor from './components/AvatarEditor';
|
||||
import Post from './components/Post';
|
||||
import SettingsPage from './components/SettingsPage';
|
||||
|
@ -87,7 +85,6 @@ export default Object.assign(compat, {
|
|||
'utils/UserControls': UserControls,
|
||||
'utils/Pane': Pane,
|
||||
'utils/BasicEditorDriver': BasicEditorDriver,
|
||||
'utils/SuperTextarea': BasicEditorDriver, // @deprecated beta 16, remove beta 17
|
||||
'states/ComposerState': ComposerState,
|
||||
'states/DiscussionListState': DiscussionListState,
|
||||
'states/GlobalSearchState': GlobalSearchState,
|
||||
|
@ -116,8 +113,6 @@ export default Object.assign(compat, {
|
|||
'components/ComposerButton': ComposerButton,
|
||||
'components/DiscussionList': DiscussionList,
|
||||
'components/ReplyPlaceholder': ReplyPlaceholder,
|
||||
'components/TextEditor': TextEditor, // @deprecated beta 16, remove beta 17. Moved to common.
|
||||
'components/TextEditorButton': TextEditorButton, // @deprecated beta 16, remove beta 17. Moved to common.
|
||||
'components/AvatarEditor': AvatarEditor,
|
||||
'components/Post': Post,
|
||||
'components/SettingsPage': SettingsPage,
|
||||
|
|
|
@ -59,7 +59,6 @@ class CreateTokenController implements RequestHandlerInterface
|
|||
|
||||
$identification = Arr::get($body, 'identification');
|
||||
$password = Arr::get($body, 'password');
|
||||
$lifetime = Arr::get($body, 'lifetime', 3600);
|
||||
|
||||
$user = $this->users->findByIdentification($identification);
|
||||
|
||||
|
@ -67,13 +66,7 @@ class CreateTokenController implements RequestHandlerInterface
|
|||
throw new NotAuthenticatedException;
|
||||
}
|
||||
|
||||
// Use of lifetime attribute is deprecated in beta 16, removed in beta 17
|
||||
// For backward compatibility with custom integrations, longer lifetimes will be interpreted as remember tokens
|
||||
if ($lifetime > 3600 || Arr::get($body, 'remember')) {
|
||||
if ($lifetime > 3600) {
|
||||
trigger_error('Use of parameter lifetime is deprecated in beta 16, will be removed in beta 17. Use remember parameter to start a remember session', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (Arr::get($body, 'remember')) {
|
||||
$token = RememberAccessToken::generate($user->id);
|
||||
} else {
|
||||
$token = SessionAccessToken::generate($user->id);
|
||||
|
|
|
@ -9,10 +9,7 @@
|
|||
|
||||
namespace Flarum\Database;
|
||||
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\Event\GetModelIsPrivate;
|
||||
use Flarum\Foundation\AbstractServiceProvider;
|
||||
use Flarum\Post\CommentPost;
|
||||
use Illuminate\Database\Capsule\Manager;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Database\ConnectionResolverInterface;
|
||||
|
@ -63,12 +60,7 @@ class DatabaseServiceProvider extends AbstractServiceProvider
|
|||
});
|
||||
|
||||
$this->container->singleton('flarum.database.model_private_checkers', function () {
|
||||
// Discussion and CommentPost are explicitly listed here to trigger the deprecated
|
||||
// event-based model privacy system. They should be removed in beta 17.
|
||||
return [
|
||||
Discussion::class => [],
|
||||
CommentPost::class => []
|
||||
];
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -91,11 +83,6 @@ class DatabaseServiceProvider extends AbstractServiceProvider
|
|||
}
|
||||
|
||||
$instance->is_private = false;
|
||||
|
||||
// @deprecated BC layer, remove beta 17
|
||||
$event = new GetModelIsPrivate($instance);
|
||||
|
||||
$instance->is_private = $this->container->make('events')->until($event) === true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Discussion\Event;
|
||||
|
||||
use Flarum\Query\QueryCriteria;
|
||||
use Flarum\Search\SearchState;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17
|
||||
*/
|
||||
class Searching
|
||||
{
|
||||
/**
|
||||
* @var SearchState
|
||||
*/
|
||||
public $search;
|
||||
|
||||
/**
|
||||
* @var \Flarum\Query\QueryCriteria
|
||||
*/
|
||||
public $criteria;
|
||||
|
||||
/**
|
||||
* @param SearchState $search
|
||||
* @param \Flarum\Query\QueryCriteria $criteria
|
||||
*/
|
||||
public function __construct(SearchState $search, QueryCriteria $criteria)
|
||||
{
|
||||
$this->search = $search;
|
||||
$this->criteria = $criteria;
|
||||
}
|
||||
}
|
|
@ -10,11 +10,8 @@
|
|||
namespace Flarum\Discussion\Search;
|
||||
|
||||
use Flarum\Discussion\DiscussionRepository;
|
||||
use Flarum\Discussion\Event\Searching;
|
||||
use Flarum\Query\QueryCriteria;
|
||||
use Flarum\Search\AbstractSearcher;
|
||||
use Flarum\Search\GambitManager;
|
||||
use Flarum\Search\SearchState;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
@ -49,14 +46,4 @@ class DiscussionSearcher extends AbstractSearcher
|
|||
{
|
||||
return $this->discussions->query()->select('discussions.*')->whereVisibleTo($actor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated along with the Searching event, remove in Beta 17.
|
||||
*/
|
||||
protected function mutateSearch(SearchState $search, QueryCriteria $criteria)
|
||||
{
|
||||
parent::mutateSearch($search, $criteria);
|
||||
|
||||
$this->events->dispatch(new Searching($search, $criteria));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
|
||||
use Flarum\Search\GambitManager;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, removed in beta 17
|
||||
*/
|
||||
abstract class AbstractConfigureGambits
|
||||
{
|
||||
/**
|
||||
* @var GambitManager
|
||||
*/
|
||||
public $gambits;
|
||||
|
||||
/**
|
||||
* @param \Flarum\Search\GambitManager $gambits
|
||||
*/
|
||||
public function __construct(GambitManager $gambits)
|
||||
{
|
||||
$this->gambits = $gambits;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, removed in beta 17
|
||||
*/
|
||||
class ConfigureDiscussionGambits extends AbstractConfigureGambits
|
||||
{
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17.
|
||||
*/
|
||||
class ConfigurePostsQuery
|
||||
{
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
public $query;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $filter;
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param array $filter
|
||||
*/
|
||||
public function __construct(Builder $query, array $filter)
|
||||
{
|
||||
$this->query = $query;
|
||||
$this->filter = $filter;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, removed in beta 17
|
||||
*/
|
||||
class ConfigureUserGambits extends AbstractConfigureGambits
|
||||
{
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Event;
|
||||
|
||||
use Flarum\Database\AbstractModel;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17.
|
||||
*
|
||||
* Determine whether or not a model should be marked as `is_private`.
|
||||
*/
|
||||
class GetModelIsPrivate
|
||||
{
|
||||
/**
|
||||
* @var AbstractModel
|
||||
*/
|
||||
public $model;
|
||||
|
||||
/**
|
||||
* @param AbstractModel $model
|
||||
*/
|
||||
public function __construct(AbstractModel $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
}
|
|
@ -74,28 +74,6 @@ class ApiSerializer implements ExtenderInterface
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to or modify the attributes array of this serializer.
|
||||
*
|
||||
* @param callable|string $callback
|
||||
*
|
||||
* The callback can be a closure or an invokable class, and should accept:
|
||||
* - $serializer: An instance of this serializer.
|
||||
* - $model: An instance of the model being serialized.
|
||||
* - $attributes: An array of existing attributes.
|
||||
*
|
||||
* The callable should return:
|
||||
* - An array of additional attributes to merge with the existing array.
|
||||
* Or a modified $attributes array.
|
||||
*
|
||||
* @deprecated in beta 16, removed in beta 17
|
||||
* @return self
|
||||
*/
|
||||
public function mutate($callback)
|
||||
{
|
||||
return $this->attributes($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish a simple hasOne relationship from this serializer to another serializer.
|
||||
* This represents a one-to-one relationship.
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Extend;
|
||||
|
||||
use Flarum\Extension\Extension;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
/**
|
||||
* This class is used to wrap old bootstrap.php closures (as used in versions up
|
||||
* to 0.1.0-beta7) in the new Extender format.
|
||||
*
|
||||
* This gives extensions the chance to work with the new API without making any
|
||||
* changes, and have some time to convert to the pure usage of extenders.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
class Compat implements ExtenderInterface
|
||||
{
|
||||
private $callback;
|
||||
|
||||
public function __construct($callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
public function extend(Container $container, Extension $extension = null)
|
||||
{
|
||||
$container->call($this->callback);
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@
|
|||
namespace Flarum\Extension;
|
||||
|
||||
use Flarum\Database\Migrator;
|
||||
use Flarum\Extend\Compat;
|
||||
use Flarum\Extend\LifecycleInterface;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
|
@ -135,13 +134,6 @@ class Extension implements Arrayable
|
|||
public function extend(Container $container)
|
||||
{
|
||||
foreach ($this->getExtenders() as $extender) {
|
||||
// If an extension has not yet switched to the new extend.php
|
||||
// format, it might return a function (or more of them). We wrap
|
||||
// these in a Compat extender to enjoy an unique interface.
|
||||
if ($extender instanceof \Closure || is_string($extender)) {
|
||||
$extender = new Compat($extender);
|
||||
}
|
||||
|
||||
$extender->extend($container, $this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
namespace Flarum\Filter;
|
||||
|
||||
use Flarum\Event\ConfigurePostsQuery;
|
||||
use Flarum\Post\Filter\PostFilterer;
|
||||
use Flarum\Query\ApplyQueryParametersTrait;
|
||||
use Flarum\Query\QueryCriteria;
|
||||
use Flarum\Query\QueryResults;
|
||||
|
@ -71,12 +69,6 @@ abstract class AbstractFilterer
|
|||
$this->applyOffset($filterState, $offset);
|
||||
$this->applyLimit($filterState, $limit + 1);
|
||||
|
||||
// DEPRECATED BC LAYER, REMOVE BETA 17
|
||||
if (static::class === PostFilterer::class) {
|
||||
event(new ConfigurePostsQuery($query, $criteria->query));
|
||||
}
|
||||
// END DEPRECATED BC LAYER
|
||||
|
||||
foreach ($this->filterMutators as $mutator) {
|
||||
$mutator($filterState, $criteria);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class FilterServiceProvider extends AbstractServiceProvider
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('flarum.filter.filters', function () {
|
||||
$this->container->singleton('flarum.filter.filters', function () {
|
||||
return [
|
||||
DiscussionFilterer::class => [
|
||||
DiscussionQuery\AuthorFilterGambit::class,
|
||||
|
@ -45,13 +45,12 @@ class FilterServiceProvider extends AbstractServiceProvider
|
|||
PostFilter\DiscussionFilter::class,
|
||||
PostFilter\IdFilter::class,
|
||||
PostFilter\NumberFilter::class,
|
||||
PostFilter\TypeFilter::class,
|
||||
PostFilter\UserFilter::class,
|
||||
PostFilter\TypeFilter::class
|
||||
],
|
||||
];
|
||||
});
|
||||
|
||||
$this->app->singleton('flarum.filter.filter_mutators', function () {
|
||||
$this->container->singleton('flarum.filter.filter_mutators', function () {
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
@ -61,30 +60,30 @@ class FilterServiceProvider extends AbstractServiceProvider
|
|||
// We can resolve the filter mutators in the when->needs->give callback,
|
||||
// but we need to resolve at least one regardless so we know which
|
||||
// filterers we need to register filters for.
|
||||
$filters = $this->app->make('flarum.filter.filters');
|
||||
$filters = $this->container->make('flarum.filter.filters');
|
||||
|
||||
foreach ($filters as $filterer => $filterClasses) {
|
||||
$this->app
|
||||
$this->container
|
||||
->when($filterer)
|
||||
->needs('$filters')
|
||||
->give(function () use ($filterClasses) {
|
||||
$compiled = [];
|
||||
|
||||
foreach ($filterClasses as $filterClass) {
|
||||
$filter = $this->app->make($filterClass);
|
||||
$filter = $this->container->make($filterClass);
|
||||
$compiled[$filter->getFilterKey()][] = $filter;
|
||||
}
|
||||
|
||||
return $compiled;
|
||||
});
|
||||
|
||||
$this->app
|
||||
$this->container
|
||||
->when($filterer)
|
||||
->needs('$filterMutators')
|
||||
->give(function () use ($filterer) {
|
||||
return array_map(function ($filterMutatorClass) {
|
||||
return ContainerUtil::wrapCallback($filterMutatorClass, $this->app);
|
||||
}, Arr::get($this->app->make('flarum.filter.filter_mutators'), $filterer, []));
|
||||
return ContainerUtil::wrapCallback($filterMutatorClass, $this->container);
|
||||
}, Arr::get($this->container->make('flarum.filter.filter_mutators'), $filterer, []));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use Illuminate\Support\ServiceProvider;
|
|||
abstract class AbstractServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17
|
||||
* @deprecated perpetually, not removed because Laravel needs it.
|
||||
* @var Container
|
||||
*/
|
||||
protected $app;
|
||||
|
|
|
@ -67,20 +67,12 @@ class AccessToken extends AbstractModel
|
|||
* Generate an access token for the specified user.
|
||||
*
|
||||
* @param int $userId
|
||||
* @param int $lifetime Does nothing. Deprecated in beta 16, removed in beta 17
|
||||
* @return static
|
||||
*/
|
||||
public static function generate($userId, $lifetime = null)
|
||||
public static function generate($userId)
|
||||
{
|
||||
if (! is_null($lifetime)) {
|
||||
trigger_error('Parameter $lifetime is deprecated in beta 16, will be removed in beta 17', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (static::class === self::class) {
|
||||
trigger_error('Use of AccessToken::generate() is deprecated in beta 16. Use SessionAccessToken::generate() or RememberAccessToken::generate()', E_USER_DEPRECATED);
|
||||
|
||||
$token = new SessionAccessToken;
|
||||
$token->type = 'session';
|
||||
throw new \Exception('Use of AccessToken::generate() is not allowed: use the `generate` method on one of the subclasses.');
|
||||
} else {
|
||||
$token = new static;
|
||||
$token->type = static::$type;
|
||||
|
|
|
@ -32,37 +32,17 @@ class Rememberer
|
|||
/**
|
||||
* Sets the remember cookie on a response.
|
||||
* @param ResponseInterface $response
|
||||
* @param RememberAccessToken $token The remember token to set on the response. Use of non-remember token is deprecated in beta 16, removed eta 17.
|
||||
* @param RememberAccessToken $token The remember token to set on the response.
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function remember(ResponseInterface $response, AccessToken $token)
|
||||
public function remember(ResponseInterface $response, RememberAccessToken $token)
|
||||
{
|
||||
if (! ($token instanceof RememberAccessToken)) {
|
||||
trigger_error('Parameter $token of type AccessToken is deprecated in beta 16, must be instance of RememberAccessToken in beta 17', E_USER_DEPRECATED);
|
||||
|
||||
$token->type = 'session_remember';
|
||||
$token->save();
|
||||
}
|
||||
|
||||
return FigResponseCookies::set(
|
||||
$response,
|
||||
$this->cookie->make(self::COOKIE_NAME, $token->token, RememberAccessToken::rememberCookieLifeTime())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ResponseInterface $response
|
||||
* @param $userId
|
||||
* @return ResponseInterface
|
||||
* @deprecated beta 16, removed beta 17. Use remember() with a token
|
||||
*/
|
||||
public function rememberUser(ResponseInterface $response, $userId)
|
||||
{
|
||||
$token = RememberAccessToken::generate($userId);
|
||||
|
||||
return $this->remember($response, $token);
|
||||
}
|
||||
|
||||
public function forget(ResponseInterface $response)
|
||||
{
|
||||
return FigResponseCookies::set(
|
||||
|
|
|
@ -15,20 +15,10 @@ class SessionAuthenticator
|
|||
{
|
||||
/**
|
||||
* @param Session $session
|
||||
* @param AccessToken|int $token Token or user ID. Use of User ID is deprecated in beta 16, will be removed in beta 17
|
||||
* @param AccessToken $token
|
||||
*/
|
||||
public function logIn(Session $session, $token)
|
||||
public function logIn(Session $session, AccessToken $token)
|
||||
{
|
||||
// Backwards compatibility with $userId as parameter
|
||||
// Remove in beta 17
|
||||
if (! ($token instanceof AccessToken)) {
|
||||
$userId = $token;
|
||||
|
||||
trigger_error('Parameter $userId is deprecated in beta 16, will be replaced by $token in beta 17', E_USER_DEPRECATED);
|
||||
|
||||
$token = SessionAccessToken::generate($userId);
|
||||
}
|
||||
|
||||
$session->regenerate(true);
|
||||
$session->put('access_token', $token->token);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ use Flarum\Foundation\Paths;
|
|||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Translation\Translator as TranslatorContract;
|
||||
use Symfony\Component\Translation\TranslatorInterface as DeprecatedTranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class LocaleServiceProvider extends AbstractServiceProvider
|
||||
|
@ -67,7 +66,6 @@ class LocaleServiceProvider extends AbstractServiceProvider
|
|||
$this->container->alias('translator', Translator::class);
|
||||
$this->container->alias('translator', TranslatorContract::class);
|
||||
$this->container->alias('translator', TranslatorInterface::class);
|
||||
$this->container->alias('translator', DeprecatedTranslatorInterface::class);
|
||||
}
|
||||
|
||||
private function getDefaultLocale(): string
|
||||
|
|
|
@ -12,9 +12,8 @@ namespace Flarum\Locale;
|
|||
use Illuminate\Contracts\Translation\Translator as TranslatorContract;
|
||||
use Symfony\Component\Translation\MessageCatalogueInterface;
|
||||
use Symfony\Component\Translation\Translator as BaseTranslator;
|
||||
use Symfony\Component\Translation\TranslatorInterface; // Defined locally as BC layer
|
||||
|
||||
class Translator extends BaseTranslator implements TranslatorContract, TranslatorInterface
|
||||
class Translator extends BaseTranslator implements TranslatorContract
|
||||
{
|
||||
const REFERENCE_REGEX = '/^=>\s*([a-z0-9_\-\.]+)$/i';
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Post\Filter;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17. Use AuthorFilter instead.
|
||||
*/
|
||||
class UserFilter extends AuthorFilter
|
||||
{
|
||||
public function getFilterKey(): string
|
||||
{
|
||||
return 'user';
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
namespace Flarum\Query;
|
||||
|
||||
use Flarum\Search\SearchCriteria;
|
||||
use Flarum\User\User;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +16,7 @@ use Flarum\User\User;
|
|||
* query. The limit and offset are not included because they only determine
|
||||
* which part of the entire result set will be returned.
|
||||
*/
|
||||
class QueryCriteria extends SearchCriteria
|
||||
class QueryCriteria
|
||||
{
|
||||
/**
|
||||
* The user performing the query.
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
|
||||
namespace Flarum\Query;
|
||||
|
||||
use Flarum\Search\SearchResults;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class QueryResults extends SearchResults
|
||||
class QueryResults
|
||||
{
|
||||
/**
|
||||
* @var Collection
|
||||
|
|
|
@ -14,9 +14,7 @@ abstract class AbstractRegexGambit implements GambitInterface
|
|||
/**
|
||||
* The regex pattern to match the bit against.
|
||||
*/
|
||||
protected function getGambitPattern()
|
||||
{
|
||||
}
|
||||
abstract protected function getGambitPattern();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -40,8 +38,7 @@ abstract class AbstractRegexGambit implements GambitInterface
|
|||
*/
|
||||
protected function match($bit)
|
||||
{
|
||||
// @deprecated, remove use of $this->pattern during beta 17.
|
||||
if (preg_match('/^(-?)'.($this->pattern ?? $this->getGambitPattern()).'$/i', $bit, $matches)) {
|
||||
if (preg_match('/^(-?)'.$this->getGambitPattern().'$/i', $bit, $matches)) {
|
||||
return $matches;
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +52,5 @@ abstract class AbstractRegexGambit implements GambitInterface
|
|||
* or not the conditions should be negated.
|
||||
* @return mixed
|
||||
*/
|
||||
// Uncomment for beta 17
|
||||
// abstract protected function conditions(SearchState $search, array $matches, $negate);
|
||||
abstract protected function conditions(SearchState $search, array $matches, $negate);
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Search;
|
||||
|
||||
use Flarum\Query\AbstractQueryState;
|
||||
|
||||
/**
|
||||
* @deprecated, use SearchState instead.
|
||||
* These methods should be transferred over to SearchState in beta 17.
|
||||
*/
|
||||
class AbstractSearch extends AbstractQueryState
|
||||
{
|
||||
/**
|
||||
* @var GambitInterface[]
|
||||
*/
|
||||
protected $activeGambits = [];
|
||||
|
||||
/**
|
||||
* Get a list of the gambits that are active in this search.
|
||||
*
|
||||
* @return GambitInterface[]
|
||||
*/
|
||||
public function getActiveGambits()
|
||||
{
|
||||
return $this->activeGambits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a gambit as being active in this search.
|
||||
*
|
||||
* @param GambitInterface $gambit
|
||||
* @return void
|
||||
*/
|
||||
public function addActiveGambit(GambitInterface $gambit)
|
||||
{
|
||||
$this->activeGambits[] = $gambit;
|
||||
}
|
||||
}
|
|
@ -37,13 +37,6 @@ abstract class AbstractSearcher
|
|||
|
||||
abstract protected function getQuery(User $actor): Builder;
|
||||
|
||||
protected function mutateSearch(SearchState $search, QueryCriteria $criteria)
|
||||
{
|
||||
foreach ($this->searchMutators as $mutator) {
|
||||
$mutator($search, $criteria);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param QueryCriteria $criteria
|
||||
* @param int|null $limit
|
||||
|
@ -65,7 +58,9 @@ abstract class AbstractSearcher
|
|||
$this->applyOffset($search, $offset);
|
||||
$this->applyLimit($search, $limit + 1);
|
||||
|
||||
$this->mutateSearch($search, $criteria);
|
||||
foreach ($this->searchMutators as $mutator) {
|
||||
$mutator($search, $criteria);
|
||||
}
|
||||
|
||||
// Execute the search query and retrieve the results. We get one more
|
||||
// results than the user asked for, so that we can say if there are more
|
||||
|
|
|
@ -36,22 +36,6 @@ class GambitManager
|
|||
$this->gambits[] = $gambit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Do not use. Added temporarily to provide support for ConfigureUserGambits and ConfigureDiscussionGambits until they are removed in beta 17.
|
||||
*/
|
||||
public function getFullTextGambit()
|
||||
{
|
||||
return $this->fulltextGambit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Do not use. Added temporarily to provide support for ConfigureUserGambits and ConfigureDiscussionGambits until they are removed in beta 17.
|
||||
*/
|
||||
public function getGambits()
|
||||
{
|
||||
return $this->gambits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply gambits to a search, given a search query.
|
||||
*
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Search;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17
|
||||
*/
|
||||
class SearchCriteria
|
||||
{
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Search;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17
|
||||
*/
|
||||
class SearchResults
|
||||
{
|
||||
}
|
|
@ -12,8 +12,6 @@ namespace Flarum\Search;
|
|||
use Flarum\Discussion\Query as DiscussionQuery;
|
||||
use Flarum\Discussion\Search\DiscussionSearcher;
|
||||
use Flarum\Discussion\Search\Gambit\FulltextGambit as DiscussionFulltextGambit;
|
||||
use Flarum\Event\ConfigureDiscussionGambits;
|
||||
use Flarum\Event\ConfigureUserGambits;
|
||||
use Flarum\Foundation\AbstractServiceProvider;
|
||||
use Flarum\Foundation\ContainerUtil;
|
||||
use Flarum\User\Query as UserQuery;
|
||||
|
@ -76,33 +74,6 @@ class SearchServiceProvider extends AbstractServiceProvider
|
|||
$gambitManager->add($this->container->make($gambit));
|
||||
}
|
||||
|
||||
// Temporary BC Layer
|
||||
// @deprecated beta 16, remove beta 17.
|
||||
|
||||
$oldEvents = [
|
||||
DiscussionSearcher::class => ConfigureDiscussionGambits::class,
|
||||
UserSearcher::class => ConfigureUserGambits::class
|
||||
];
|
||||
|
||||
foreach ($oldEvents as $oldSearcher => $event) {
|
||||
if ($searcher === $oldSearcher) {
|
||||
$tempGambits = new GambitManager;
|
||||
$this->container->make('events')->dispatch(
|
||||
new $event($tempGambits)
|
||||
);
|
||||
|
||||
if (! is_null($fullTextGambit = $tempGambits->getFullTextGambit())) {
|
||||
$gambitManager->setFullTextGambit($this->container->make($fullTextGambit));
|
||||
}
|
||||
|
||||
foreach ($tempGambits->getGambits() as $gambit) {
|
||||
$gambitManager->add($this->container->make($gambit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End BC Layer
|
||||
|
||||
return $gambitManager;
|
||||
});
|
||||
|
||||
|
|
|
@ -9,6 +9,33 @@
|
|||
|
||||
namespace Flarum\Search;
|
||||
|
||||
class SearchState extends AbstractSearch
|
||||
use Flarum\Query\AbstractQueryState;
|
||||
|
||||
class SearchState extends AbstractQueryState
|
||||
{
|
||||
/**
|
||||
* @var GambitInterface[]
|
||||
*/
|
||||
protected $activeGambits = [];
|
||||
|
||||
/**
|
||||
* Get a list of the gambits that are active in this search.
|
||||
*
|
||||
* @return GambitInterface[]
|
||||
*/
|
||||
public function getActiveGambits()
|
||||
{
|
||||
return $this->activeGambits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a gambit as being active in this search.
|
||||
*
|
||||
* @param GambitInterface $gambit
|
||||
* @return void
|
||||
*/
|
||||
public function addActiveGambit(GambitInterface $gambit)
|
||||
{
|
||||
$this->activeGambits[] = $gambit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Translation;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17.
|
||||
* This is here to provide a graceful transition for classes typehinting the old interface.
|
||||
* Temporarily, `Flarum\Locale\Translator` will implement this to avoid breaking that typehint.
|
||||
* Before beta 17, this should be removed from autoload.
|
||||
*/
|
||||
interface TranslatorInterface
|
||||
{
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\User\Event;
|
||||
|
||||
use Flarum\User\User;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove in beta 17. Use Auth extender instead.
|
||||
*/
|
||||
class CheckingPassword
|
||||
{
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $password;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $password
|
||||
*/
|
||||
public function __construct($user, $password)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->password = $password;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\User\Event;
|
||||
|
||||
use Flarum\Query\QueryCriteria;
|
||||
use Flarum\Search\SearchState;
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17
|
||||
*/
|
||||
class Searching
|
||||
{
|
||||
/**
|
||||
* @var \Flarum\User\Search\SearchState
|
||||
*/
|
||||
public $search;
|
||||
|
||||
/**
|
||||
* @var QueryCriteria
|
||||
*/
|
||||
public $criteria;
|
||||
|
||||
/**
|
||||
* @param SearchState $search
|
||||
* @param QueryCriteria $criteria
|
||||
*/
|
||||
public function __construct(SearchState $search, QueryCriteria $criteria)
|
||||
{
|
||||
$this->search = $search;
|
||||
$this->criteria = $criteria;
|
||||
}
|
||||
}
|
|
@ -9,11 +9,8 @@
|
|||
|
||||
namespace Flarum\User\Search;
|
||||
|
||||
use Flarum\Query\QueryCriteria;
|
||||
use Flarum\Search\AbstractSearcher;
|
||||
use Flarum\Search\GambitManager;
|
||||
use Flarum\Search\SearchState;
|
||||
use Flarum\User\Event\Searching;
|
||||
use Flarum\User\User;
|
||||
use Flarum\User\UserRepository;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
@ -49,14 +46,4 @@ class UserSearcher extends AbstractSearcher
|
|||
{
|
||||
return $this->users->query()->whereVisibleTo($actor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated along with the Searching event, remove in Beta 17.
|
||||
*/
|
||||
protected function mutateSearch(SearchState $search, QueryCriteria $criteria)
|
||||
{
|
||||
parent::mutateSearch($search, $criteria);
|
||||
|
||||
$this->events->dispatch(new Searching($search, $criteria));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ use Flarum\Post\Post;
|
|||
use Flarum\User\DisplayName\DriverInterface;
|
||||
use Flarum\User\Event\Activated;
|
||||
use Flarum\User\Event\AvatarChanged;
|
||||
use Flarum\User\Event\CheckingPassword;
|
||||
use Flarum\User\Event\Deleted;
|
||||
use Flarum\User\Event\EmailChanged;
|
||||
use Flarum\User\Event\EmailChangeRequested;
|
||||
|
@ -343,7 +342,7 @@ class User extends AbstractModel
|
|||
*/
|
||||
public function checkPassword($password)
|
||||
{
|
||||
$valid = static::$dispatcher->until(new CheckingPassword($this, $password));
|
||||
$valid = false;
|
||||
|
||||
foreach (static::$passwordCheckers as $checker) {
|
||||
$result = $checker($this, $password);
|
||||
|
@ -355,7 +354,7 @@ class User extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
return $valid || false;
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
namespace Flarum\Tests\integration\api\posts;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Flarum\Event\ConfigurePostsQuery;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
|
@ -114,44 +113,6 @@ class ListTests extends TestCase
|
|||
$this->assertEquals(['1', '2', '3', '4', '5'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @deprecated
|
||||
*/
|
||||
public function user_filter_works()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/posts', ['authenticatedAs' => 1])
|
||||
->withQueryParams([
|
||||
'filter' => ['user' => 'admin'],
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(['1', '2'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @deprecated
|
||||
*/
|
||||
public function user_filter_works_with_multiple_values()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/posts', ['authenticatedAs' => 1])
|
||||
->withQueryParams([
|
||||
'filter' => ['user' => 'admin,normal'],
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(['1', '2', '3', '4', '5'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
@ -241,24 +202,4 @@ class ListTests extends TestCase
|
|||
|
||||
$this->assertEquals(['1', '3', '5'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated beta 16, remove beta 17
|
||||
* @test
|
||||
*/
|
||||
public function deprecated_configure_posts_query_extension_still_works()
|
||||
{
|
||||
$this->app()->getContainer()->make('events')->listen(ConfigurePostsQuery::class, function (ConfigurePostsQuery $event) {
|
||||
$event->query->where('id', '1');
|
||||
});
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/posts', ['authenticatedAs' => 1])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(['1'], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class ModelPrivateTest extends TestCase
|
|||
$discussion = Discussion::start('Some Discussion', $user);
|
||||
$discussion->save();
|
||||
|
||||
$this->assertFalse($discussion->is_private);
|
||||
$this->assertNull($discussion->is_private);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user