Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.3] Core deprecation notice logging #6389

Merged
merged 1 commit into from
Feb 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Asset/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Target
*/
public function listAll()
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __METHOD__), E_USER_DEPRECATED);
$reflection = new \ReflectionClass($this);

return $reflection->getConstants();
Expand Down
2 changes: 2 additions & 0 deletions src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public function __construct($directory, $extension = self::EXTENSION, $umask = 0
*/
public function clearCache()
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use flushAll() instead.', __METHOD__));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing E_USER_DEPRECATED here.


$this->flushAll();

return [
Expand Down
11 changes: 11 additions & 0 deletions src/Configuration/ResourceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ public function useLoader(ClassLoader $loader)
*/
public function setApp(Application $app)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __METHOD__), E_USER_DEPRECATED);

$this->app = $app;
self::$theApp = $app;
$this->pathResolver = $app['path_resolver'];
Expand All @@ -179,6 +181,8 @@ public function setApp(Application $app)
*/
public function setPath($name, $value, $applyToResolver = true)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \$app[\'path_resolver\'] instead.', __METHOD__), E_USER_DEPRECATED);

if (strpos($value, '%') !== false) { // contains variable
$path = function () use ($value) {
if (!$this->pathResolver) {
Expand Down Expand Up @@ -232,6 +236,8 @@ public function setPath($name, $value, $applyToResolver = true)
*/
public function getPath($name)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \$app[\'path_resolver\'] instead.', __METHOD__), E_USER_DEPRECATED);

return $this->getPathObject($name)->string();
}

Expand Down Expand Up @@ -292,6 +298,7 @@ public function getPathObject($name)
*/
public function hasPath($name)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \$app[\'path_resolver\'] instead.', __METHOD__), E_USER_DEPRECATED);
if (strpos($name, '/') !== false) {
$parts = explode('/', $name);
$name = array_shift($parts);
Expand Down Expand Up @@ -406,6 +413,7 @@ public function getRequest($name)
*/
public function getPaths()
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \$app[\'path_resolver\'] instead.', __METHOD__), E_USER_DEPRECATED);
if ($this->pathsProxy === null) {
$this->pathsProxy = new PathsProxy($this);
}
Expand Down Expand Up @@ -581,6 +589,7 @@ public function getClassLoader()
*/
public static function getApp()
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __METHOD__), E_USER_DEPRECATED);
if (! static::$theApp) {
$trace = debug_backtrace(false);
$trace = $trace[0]['file'] . '::' . $trace[0]['line'];
Expand All @@ -601,6 +610,8 @@ public static function getApp()
*/
public function findRelativePath($frompath, $topath)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \$app[\'path_resolver\'] instead.', __METHOD__), E_USER_DEPRECATED);

$filesystem = new Filesystem();
$relative = $filesystem->makePathRelative($topath, $frompath);

Expand Down
28 changes: 28 additions & 0 deletions src/Controller/Routing.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Routing extends Requirement
*/
public function getAnyContentTypeRequirement()
{
$this->deprecationNotice(__FUNCTION__, 'anyContentType');

return $this->anyContentType();
}

Expand All @@ -19,6 +21,8 @@ public function getAnyContentTypeRequirement()
*/
public function getPluralContentTypeRequirement()
{
$this->deprecationNotice(__FUNCTION__, 'pluralContentTypes');

return $this->pluralContentTypes();
}

Expand All @@ -27,6 +31,8 @@ public function getPluralContentTypeRequirement()
*/
public function getAnyTaxonomyTypeRequirement()
{
$this->deprecationNotice(__FUNCTION__, 'anyTaxonomyType');

return $this->anyTaxonomyType();
}

Expand All @@ -35,6 +41,8 @@ public function getAnyTaxonomyTypeRequirement()
*/
public function getPluralTaxonomyTypeRequirement()
{
$this->deprecationNotice(__FUNCTION__, 'pluralTaxonomyTypes');

return $this->pluralTaxonomyTypes();
}

Expand All @@ -48,6 +56,26 @@ public function getPluralTaxonomyTypeRequirement()
*/
public function getTaxonomyRequirement($taxonomyName, $emptyValue = 'none')
{
$this->deprecationNotice(__FUNCTION__, 'singleTaxonomy');

return $this->singleTaxonomy($taxonomyName, $emptyValue);
}

/**
* @param string $old Old function name
* @param string $new New function name
*
* @internal
*/
private function deprecationNotice($old, $new)
{
@trigger_error(
sprintf(
'The app/config/routing.yml routing requirement parameter "Bolt\Controllers\Routing::%s" is deprecated and will be removed in version 4.0. Use "controller.requirement:%s" instead',
$old,
$new
),
E_USER_DEPRECATED
);
}
}
4 changes: 4 additions & 0 deletions src/Extension/AssetTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ private function addAsset(AssetInterface $asset)
*/
protected function addJquery()
{
@trigger_error(sprintf('%s::%s is deprecated and will be removed in version 4.0.', get_called_class(), __FUNCTION__), E_USER_DEPRECATED);

$this->getContainer()['config']->set('general/add_jquery', true);
}

Expand All @@ -147,6 +149,8 @@ protected function addJquery()
*/
protected function disableJquery()
{
@trigger_error(sprintf('%s::%s is deprecated and will be removed in version 4.0.', get_called_class(), __FUNCTION__), E_USER_DEPRECATED);

$this->getContainer()['config']->set('general/add_jquery', false);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Extension/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ private function isClassLoadable($className)
*/
protected function getApp()
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Inject the required services directly into your own service constructor as required.', __METHOD__), E_USER_DEPRECATED);

return $this->app;
}
}
2 changes: 2 additions & 0 deletions src/Extension/MenuTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ function (MenuEntry $menus) {
*/
final protected function addMenuEntry($label, $path, $icon = null, $permission = null)
{
@trigger_error(sprintf('%s::%s is deprecated and will be removed in version 4.0. Use registerMenuEntries() instead.', get_called_class(), __FUNCTION__), E_USER_DEPRECATED);

$this->menuEntries[] = (new MenuEntry($label, $path))
->setLabel($label)
->setIcon($icon)
Expand Down
2 changes: 2 additions & 0 deletions src/Extension/NutTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ final protected function extendNutService()
*/
protected function addConsoleCommand(Command $command)
{
@trigger_error(sprintf('%s::%s is deprecated and will be removed in version 4.0. Use registerNutCommands() instead.', get_called_class(), __FUNCTION__), E_USER_DEPRECATED);

$app = $this->getContainer();
$app['nut.commands.add']($command);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Helpers/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public static function column(array $input, $columnKey, $indexKey = null)
*/
public static function makeValuePairs($array, $key, $value)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use array_column() or Arr::column()', __METHOD__), E_USER_DEPRECATED);
if (!is_array($array)) {
return [];
}
Expand All @@ -163,6 +164,7 @@ public static function makeValuePairs($array, $key, $value)
*/
public static function mergeRecursiveDistinct(array &$array1, array &$array2)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use array_replace_recursive() or Arr::replaceRecursive()', __METHOD__), E_USER_DEPRECATED);
$merged = $array1;

foreach ($array2 as $key => &$value) {
Expand Down Expand Up @@ -196,6 +198,8 @@ public static function mergeRecursiveDistinct(array &$array1, array &$array2)
*/
public static function isIndexedArray(array $arr)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use Arr::isIndexed() or Arr::isAssociative()', __METHOD__), E_USER_DEPRECATED);

foreach ($arr as $key => $val) {
if ($key !== (int) $key) {
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/Legacy/BaseExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ abstract class BaseExtension extends SimpleExtension
*/
public function __construct(Application $app)
{
@trigger_error(sprintf('%s is extending the deprecated %s class that will be removed in version 4.0. Use \Bolt\Extension\SimpleExtension instead.', get_called_class(), __CLASS__), E_USER_DEPRECATED);

$this->app = $app;

$this->extensionConfig = null;
Expand Down
6 changes: 2 additions & 4 deletions src/Menu/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ private function resolveRouteToLink(array $item)
$param = !empty($item['param']) ? $item['param'] : [];

if (isset($item['add'])) {
$this->app['logger.system']->warning(
Trans::__('Menu item property "add" is deprecated. Use "#" under "param" instead.'),
['event' => 'deprecated']
);
@trigger_error('Menu item property "add" is deprecated. Use "#" under "param" instead.', E_USER_DEPRECATED);

$add = $item['add'];
if (!empty($add) && $add[0] !== '?') {
$add = '?' . $add;
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/DatabaseSchemaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function ($app) {
/** @deprecated Deprecated since 3.0, to be removed in 4.0. */
$app['integritychecker'] = $app->share(
function ($app) {
$app['logger.system']->warning("[DEPRECATED]: An extension is using app['integritychecker'] and this has been replaced with app['schema'].", ['event' => 'deprecated']);
@trigger_error("Accessing \$app['integritychecker'] is deprecated and will be removed in version 4.0. Use \$app['schema'] instead.", E_USER_DEPRECATED);

return $app['schema'];
}
Expand Down
2 changes: 2 additions & 0 deletions src/Session/Generator/RandomGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function __construct($generator, $length = 32)
*/
public function generateId()
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __CLASS__), E_USER_DEPRECATED);

return $this->generator->generateString($this->length);
}
}
4 changes: 4 additions & 0 deletions src/Storage/Database/Schema/Builder/ExtensionTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public function getSchemaTables(Schema $schema)
*/
public function addTable(callable $generator)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __METHOD__), E_USER_DEPRECATED);

$this->tableGenerators[] = $generator;
}

Expand All @@ -85,6 +87,8 @@ public function addTable(callable $generator)
*/
public function addPrefix($prefix)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __METHOD__), E_USER_DEPRECATED);

$this->prefix = $prefix;
}
}
4 changes: 2 additions & 2 deletions src/Storage/Database/Schema/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(Application $app)
*/
public function __call($name, $args)
{
$this->app['logger.system']->warning('[DEPRECATED]: An extension called an invalid, or removed, integrity checker function: ' . $name, ['event' => 'deprecated']);
@trigger_error(sprintf('An extension called an invalid, or removed, integrity checker function: %s', $name), E_USER_DEPRECATED);
}

/**
Expand All @@ -65,7 +65,7 @@ public function __call($name, $args)
*/
public function __get($name)
{
$this->app['logger.system']->warning('[DEPRECATED]: An extension called an invalid, or removed integrity, checker property: ' . $name, ['event' => 'deprecated']);
@trigger_error(sprintf('An extension accessed an invalid, or removed, integrity checker property: %s', $name), E_USER_DEPRECATED);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Storage/Database/Schema/Table/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ private function columnDateTime($fieldName)
*/
private function columnDecimal($fieldName)
{
@trigger_error('The "decimal" field type is deprecated and will be removed in version 4.', E_USER_DEPRECATED);

$this->table->addColumn($fieldName, 'decimal', ['precision' => '18', 'scale' => '9', 'default' => 0]);
}

Expand Down
8 changes: 8 additions & 0 deletions src/Storage/Entity/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public function set($key, $value)
*/
public function getSortorder()
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __METHOD__), E_USER_DEPRECATED);

return $this->sortorder;
}

Expand All @@ -87,6 +89,8 @@ public function getSortorder()
*/
public function setSortorder($sortorder)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __METHOD__), E_USER_DEPRECATED);

$this->sortorder = $sortorder;
}

Expand Down Expand Up @@ -289,6 +293,8 @@ public function setTaxonomy(Collection\Taxonomy $taxonomy)
*/
public function getGroup()
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __METHOD__), E_USER_DEPRECATED);

return $this->group;
}

Expand All @@ -297,6 +303,8 @@ public function getGroup()
*/
public function setGroup($group)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0.', __METHOD__), E_USER_DEPRECATED);

$this->group = $group;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Storage/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ public function getLogger()
*/
public function __call($method, $args)
{
//$this->getLogger()->warning('[DEPRECATED] Accessing ['storage']->$method is no longer supported and will be removed in a future version.');
@trigger_error(sprintf("Accessing \$app['storage']->%s() is deprecated and will be removed in version 4.0.", $method), E_USER_DEPRECATED);

return call_user_func_array([$this->legacy(), $method], $args);
}

Expand All @@ -443,6 +444,8 @@ public function __call($method, $args)
*/
public function getContent($textquery, $parameters = [], &$pager = [], $whereparameters = [])
{
@trigger_error("Accessing \$app['storage']->getContent() is deprecated and will be removed in version 4.0.", E_USER_DEPRECATED);

return $this->legacy()->getContent($textquery, $parameters, $pager, $whereparameters);
}
}
8 changes: 8 additions & 0 deletions src/Storage/Field/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,26 @@ public function __construct()

public function addField(FieldInterface $field)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \Bolt\Storage\FieldManager instead.', __METHOD__), E_USER_DEPRECATED);
$this->fields[$field->getName()] = $field;
}

public function addDummyField($field)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \Bolt\Storage\FieldManager instead.', __METHOD__), E_USER_DEPRECATED);
$this->dummyFields[] = $field;
}

public function fields()
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \Bolt\Storage\FieldManager instead.', __METHOD__), E_USER_DEPRECATED);

return $this->fields;
}

public function getField($name)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \Bolt\Storage\FieldManager instead.', __METHOD__), E_USER_DEPRECATED);
if ($this->has($name)) {
return $this->fields[$name];
} else {
Expand All @@ -55,6 +60,7 @@ public function getField($name)

public function getDatabaseField($field)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \Bolt\Storage\FieldManager instead.', __METHOD__), E_USER_DEPRECATED);
if (in_array($field, $this->dummyFields)) {
return false;
}
Expand All @@ -64,6 +70,8 @@ public function getDatabaseField($field)

public function has($field)
{
@trigger_error(sprintf('%s is deprecated and will be removed in version 4.0. Use \Bolt\Storage\FieldManager instead.', __METHOD__), E_USER_DEPRECATED);

return isset($this->fields[$field]) || in_array($field, $this->dummyFields);
}
}
Loading