mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Added Deprecated tab to DebugBar to catch future incompatibilities with later Grav versions
This commit is contained in:
parent
89f64e423d
commit
756ddaa97d
|
|
@ -1,3 +1,10 @@
|
|||
# v1.5.2
|
||||
## mm/dd/2018
|
||||
|
||||
1. [](#new)
|
||||
* Added `Deprecated` tab to DebugBar to catch future incompatibilities with later Grav versions
|
||||
* Added deprecation notices for features which will be removed in Grav 2.0
|
||||
|
||||
# v1.5.1
|
||||
## 08/23/2018
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package Grav.Core
|
||||
*
|
||||
|
|
@ -7,6 +8,7 @@
|
|||
*/
|
||||
|
||||
namespace Grav;
|
||||
|
||||
define('GRAV_PHP_MIN', '5.6.4');
|
||||
|
||||
// Ensure vendor libraries exist
|
||||
|
|
@ -29,7 +31,7 @@ if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
|
|||
}
|
||||
|
||||
// Register the auto-loader.
|
||||
$loader = require_once $autoload;
|
||||
$loader = require $autoload;
|
||||
|
||||
// Set timezone to default, falls back to system if php.ini not set
|
||||
date_default_timezone_set(@date_default_timezone_get());
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ class Config extends Data
|
|||
*/
|
||||
public function getLanguages()
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use Grav::instance()[\'languages\'] instead', E_USER_DEPRECATED);
|
||||
|
||||
return Grav::instance()['languages'];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
namespace Grav\Common;
|
||||
|
||||
use DebugBar\DataCollector\ConfigCollector;
|
||||
use DebugBar\DataCollector\MessagesCollector;
|
||||
use DebugBar\JavascriptRenderer;
|
||||
use DebugBar\StandardDebugBar;
|
||||
use Grav\Common\Config\Config;
|
||||
|
|
@ -31,6 +32,11 @@ class Debugger
|
|||
|
||||
protected $timers = [];
|
||||
|
||||
/** @var string[] $deprecations */
|
||||
protected $deprecations = [];
|
||||
|
||||
protected $errorHandler;
|
||||
|
||||
/**
|
||||
* Debugger constructor.
|
||||
*/
|
||||
|
|
@ -41,6 +47,9 @@ class Debugger
|
|||
|
||||
$this->debugbar = new StandardDebugBar();
|
||||
$this->debugbar['time']->addMeasure('Loading', $this->debugbar['time']->getRequestStartTime(), microtime(true));
|
||||
|
||||
// Set deprecation collector.
|
||||
$this->setErrorHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -177,6 +186,8 @@ class Debugger
|
|||
return $this;
|
||||
}
|
||||
|
||||
$this->addDeprecations();
|
||||
|
||||
echo $this->renderer->render();
|
||||
}
|
||||
|
||||
|
|
@ -191,6 +202,7 @@ class Debugger
|
|||
public function sendDataInHeaders()
|
||||
{
|
||||
if ($this->enabled()) {
|
||||
$this->addDeprecations();
|
||||
$this->debugbar->sendDataInHeaders();
|
||||
}
|
||||
|
||||
|
|
@ -208,6 +220,7 @@ class Debugger
|
|||
return null;
|
||||
}
|
||||
|
||||
$this->addDeprecations();
|
||||
$this->timers = [];
|
||||
|
||||
return $this->debugbar->getData();
|
||||
|
|
@ -279,4 +292,55 @@ class Debugger
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setErrorHandler()
|
||||
{
|
||||
$this->errorHandler = set_error_handler(
|
||||
[$this, 'deprecatedErrorHandler'],
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $errno
|
||||
* @param string $errstr
|
||||
* @param string $errfile
|
||||
* @param int $errline
|
||||
* @return bool
|
||||
*/
|
||||
public function deprecatedErrorHandler($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
$this->deprecations[] = [
|
||||
'message' => $errstr,
|
||||
'file' => $errfile,
|
||||
'line' => $errline
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function addDeprecations()
|
||||
{
|
||||
if (!$this->deprecations) {
|
||||
return;
|
||||
}
|
||||
|
||||
$collector = new MessagesCollector('deprecated');
|
||||
$this->addCollector($collector);
|
||||
$collector->addMessage('Your site is using following deprecated features:');
|
||||
|
||||
/** @var array $deprecated */
|
||||
foreach ($this->deprecations as $deprecated) {
|
||||
if (strpos($deprecated['message'], 'Grav') !== false) {
|
||||
$scope = 'grav';
|
||||
} elseif (strpos($deprecated['file'], 'Twig') !== false) {
|
||||
$scope = 'twig';
|
||||
} elseif (strpos($deprecated['file'], 'yaml') !== false) {
|
||||
$scope = 'yaml';
|
||||
} else {
|
||||
$scope = 'unknown';
|
||||
}
|
||||
$collector->addMessage($deprecated, $scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,5 +74,8 @@ class Errors
|
|||
}
|
||||
|
||||
$whoops->register();
|
||||
|
||||
// Re-register deprecation handler.
|
||||
$grav['debugger']->setErrorHandler();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
namespace Grav\Common;
|
||||
|
||||
/**
|
||||
* @deprecated 2.0
|
||||
* @deprecated 1.4 Use Grav::instance() instead
|
||||
*/
|
||||
trait GravTrait
|
||||
{
|
||||
|
|
@ -24,8 +24,7 @@ trait GravTrait
|
|||
self::$grav = Grav::instance();
|
||||
}
|
||||
|
||||
$caller = self::$grav['debugger']->getCaller();
|
||||
self::$grav['debugger']->addMessage("Deprecated GravTrait used in {$caller['file']}", 'deprecated');
|
||||
user_error(__TRAIT__ . ' is deprecated since Grav 1.4, use Grav::instance() instead', E_USER_DEPRECATED);
|
||||
|
||||
return self::$grav;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -764,6 +764,8 @@ class Page implements PageInterface
|
|||
|
||||
// pages.markdown_extra is deprecated, but still check it...
|
||||
if (!isset($defaults['extra']) && (isset($this->markdown_extra) || $config->get('system.pages.markdown_extra') !== null)) {
|
||||
user_error('Configuration option \'system.pages.markdown_extra\' is deprecated since Grav 1.5, use \'system.pages.markdown.extra\' instead', E_USER_DEPRECATED);
|
||||
|
||||
$defaults['extra'] = $this->markdown_extra ?: $config->get('system.pages.markdown_extra');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,12 @@ class Session extends \Grav\Framework\Session\Session
|
|||
|
||||
/**
|
||||
* @return \Grav\Framework\Session\Session
|
||||
* @deprecated 1.5
|
||||
* @deprecated 1.5 Use getInstance() method instead
|
||||
*/
|
||||
public static function instance()
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use getInstance() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return static::getInstance();
|
||||
}
|
||||
|
||||
|
|
@ -51,10 +53,12 @@ class Session extends \Grav\Framework\Session\Session
|
|||
* Returns attributes.
|
||||
*
|
||||
* @return array Attributes
|
||||
* @deprecated 1.5
|
||||
* @deprecated 1.5 Use getAll() method instead
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use getAll() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->getAll();
|
||||
}
|
||||
|
||||
|
|
@ -62,10 +66,12 @@ class Session extends \Grav\Framework\Session\Session
|
|||
* Checks if the session was started.
|
||||
*
|
||||
* @return Boolean
|
||||
* @deprecated 1.5
|
||||
* @deprecated 1.5 Use isStarted() method instead
|
||||
*/
|
||||
public function started()
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use isStarted() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->isStarted();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,10 @@ class Twig
|
|||
$params['autoescape'] = $this->autoescape;
|
||||
}
|
||||
|
||||
if (empty($params['autoescape'])) {
|
||||
user_error('Having Twig auto-escaping turned off is deprecated since Grav 1.5, please disable \'system.strict_mode.twig_compat\' setting in your configuration', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->twig = new TwigEnvironment($loader_chain, $params);
|
||||
|
||||
if ($config->get('system.twig.undefined_functions')) {
|
||||
|
|
@ -411,8 +415,12 @@ class Twig
|
|||
* Overrides the autoescape setting
|
||||
*
|
||||
* @param boolean $state
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
public function setAutoescape($state) {
|
||||
public function setAutoescape($state)
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5', E_USER_DEPRECATED);
|
||||
|
||||
$this->autoescape = (bool) $state;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,6 +266,8 @@ class User extends Data
|
|||
*/
|
||||
public function authorise($action)
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use authorize() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->authorize($action);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -696,6 +696,8 @@ abstract class Utils
|
|||
*/
|
||||
public static function resolve(array $array, $path, $default = null)
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use getDotNotation() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return static::getDotNotation($array, $path, $default);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class IniFormatter implements FormatterInterface
|
|||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use getDefaultFileExtension() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->getDefaultFileExtension();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ class JsonFormatter implements FormatterInterface
|
|||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use getDefaultFileExtension() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->getDefaultFileExtension();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ class MarkdownFormatter implements FormatterInterface
|
|||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use getDefaultFileExtension() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->getDefaultFileExtension();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class SerializeFormatter implements FormatterInterface
|
|||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use getDefaultFileExtension() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->getDefaultFileExtension();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ class YamlFormatter implements FormatterInterface
|
|||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.5, use getDefaultFileExtension() method instead', E_USER_DEPRECATED);
|
||||
|
||||
return $this->getDefaultFileExtension();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user