class PhpNoticesSensorPlugin in Monitoring 8
Displays the most frequent PHP notices and errors.
Plugin annotation
@SensorPlugin(
id = "php_notices",
provider = "dblog",
label = @Translation("PHP notices (database log)"),
description = @Translation("Displays the most frequent PHP notices and errors."),
addable = FALSE
)
Hierarchy
- class \Drupal\monitoring\SensorPlugin\SensorPluginBase implements SensorPluginInterface uses MessengerTrait, StringTranslationTrait
- class \Drupal\monitoring\SensorPlugin\DatabaseAggregatorSensorPluginBase
- class \Drupal\monitoring\Plugin\monitoring\SensorPlugin\DatabaseAggregatorSensorPlugin implements ExtendedInfoSensorPluginInterface uses DependencyTrait
- class \Drupal\monitoring\Plugin\monitoring\SensorPlugin\WatchdogAggregatorSensorPlugin implements ExtendedInfoSensorPluginInterface
- class \Drupal\monitoring\Plugin\monitoring\SensorPlugin\PhpNoticesSensorPlugin
- class \Drupal\monitoring\Plugin\monitoring\SensorPlugin\WatchdogAggregatorSensorPlugin implements ExtendedInfoSensorPluginInterface
- class \Drupal\monitoring\Plugin\monitoring\SensorPlugin\DatabaseAggregatorSensorPlugin implements ExtendedInfoSensorPluginInterface uses DependencyTrait
- class \Drupal\monitoring\SensorPlugin\DatabaseAggregatorSensorPluginBase
Expanded class hierarchy of PhpNoticesSensorPlugin
File
- src/
Plugin/ monitoring/ SensorPlugin/ PhpNoticesSensorPlugin.php, line 23 - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\PhpNoticesSensorPlugin.
Namespace
Drupal\monitoring\Plugin\monitoring\SensorPluginView source
class PhpNoticesSensorPlugin extends WatchdogAggregatorSensorPlugin {
/**
* {@inheritdoc}
*/
protected $configurableConditions = FALSE;
/**
* {@inheritdoc}
*/
protected $configurableVerboseOutput = FALSE;
/**
* {@inheritdoc}
*/
public function runSensor(SensorResultInterface $result) {
parent::runSensor($result);
if (!empty($this->fetchedObject->variables)) {
$variables = unserialize($this->fetchedObject->variables);
$variables['%file'] = $this
->shortenFilename($variables['%file']);
$result
->setMessage('@count times: @error', [
'@count' => (int) $this->fetchedObject->records_count,
'@error' => new FormattableMarkup('%type: @message in %function (Line %line of %file).', $variables),
]);
}
}
/**
* {@inheritdoc}
*/
public function getAggregateQuery() {
$query = parent::getAggregateQuery();
$query
->addField('watchdog', 'variables');
$query
->condition('type', 'php', NULL);
// The message is the most recurring php error.
$query
->groupBy('variables');
$query
->orderBy('records_count', 'DESC');
$query
->range(0, 1);
return $query;
}
/**
* {@inheritdoc}
*/
public function getQuery() {
$query = parent::getQuery();
$query
->addField('watchdog', 'variables');
$this
->addAggregateExpression($query);
$query
->condition('type', 'php', NULL);
$query
->groupBy('variables');
// Drop the existing order, order by record count instead.
$order =& $query
->getOrderBy();
$order = [];
$query
->orderBy('records_count', 'DESC');
$query
->range(0, 20);
return $query;
}
/**
* {@inheritdoc}
*/
public function verboseResultUnaggregated(array &$output) {
parent::verboseResultUnaggregated($output);
$rows = [];
foreach ($output['verbose_sensor_result']['#rows'] as $delta => $row) {
$variables = unserialize($row['variables']);
$variables['%file'] = $this
->shortenFilename($variables['%file']);
$rows[$delta]['count'] = $row['records_count'];
$rows[$delta]['type'] = $variables['%type'];
$rows[$delta]['message'] = $variables['@message'];
$rows[$delta]['caller'] = $variables['%function'];
$rows[$delta]['file'] = $variables['%file'] . ':' . $variables['%line'];
}
$output['verbose_sensor_result']['#rows'] = $rows;
$output['verbose_sensor_result']['#header'] = $this
->buildTableHeader($rows);
}
/**
* Removes the root path from a filename.
*
* @param string $filename
* Name of the file.
*
* @return string
* The shortened filename.
*/
protected function shortenFilename($filename) {
return str_replace(DRUPAL_ROOT . '/', '', $filename);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DatabaseAggregatorSensorPlugin:: |
protected | property | The arguments of the executed query. | |
DatabaseAggregatorSensorPlugin:: |
protected | property | The fetched object from the query result. | |
DatabaseAggregatorSensorPlugin:: |
protected | property | The arguments of the executed query. | |
DatabaseAggregatorSensorPlugin:: |
protected | property | The query string of the executed query. | |
DatabaseAggregatorSensorPlugin:: |
protected | function | Adds the aggregate expression to the select query. | 2 |
DatabaseAggregatorSensorPlugin:: |
public | function | Add row to table when pressing 'Add another condition' and rebuild. | |
DatabaseAggregatorSensorPlugin:: |
public | function | Adds another field to the keys table when pressing 'Add another key'. | |
DatabaseAggregatorSensorPlugin:: |
public | function |
Adds UI for variables table, conditions and keys. Overrides DatabaseAggregatorSensorPluginBase:: |
1 |
DatabaseAggregatorSensorPlugin:: |
protected | function | Builds the header for a table based on rows. | 3 |
DatabaseAggregatorSensorPlugin:: |
protected | function | Builds the rows of a table. | 1 |
DatabaseAggregatorSensorPlugin:: |
public | function |
Calculates dependencies for the configured plugin. Overrides SensorPluginBase:: |
|
DatabaseAggregatorSensorPlugin:: |
public | function | Returns the updated 'conditions' fieldset for replacement by ajax. | |
DatabaseAggregatorSensorPlugin:: |
public | function | Returns the updated 'output_table' fieldset for replacement by ajax. | |
DatabaseAggregatorSensorPlugin:: |
protected | function | Provides list of operators for conditions. | |
DatabaseAggregatorSensorPlugin:: |
protected | function | Builds history query over one db table. | |
DatabaseAggregatorSensorPlugin:: |
protected | function | Get the timestamp of the oldest entry that fits owr conditions. | |
DatabaseAggregatorSensorPlugin:: |
public | function |
Provide additional info about sensor call. Overrides ExtendedInfoSensorPluginInterface:: |
3 |
DatabaseAggregatorSensorPlugin:: |
public | function |
Form submission handler. Overrides DatabaseAggregatorSensorPluginBase:: |
|
DatabaseAggregatorSensorPlugin:: |
protected | function | Translates the string operators to SQL equivalents. | |
DatabaseAggregatorSensorPlugin:: |
public | function |
Form validation handler. Overrides SensorPluginBase:: |
|
DatabaseAggregatorSensorPluginBase:: |
protected | property |
Allows plugins to control if the value type can be configured. Overrides SensorPluginBase:: |
|
DatabaseAggregatorSensorPluginBase:: |
protected | function | Gets conditions to be used in the select query. | |
DatabaseAggregatorSensorPluginBase:: |
protected | function | Gets the time field. | |
DatabaseAggregatorSensorPluginBase:: |
protected | function | Returns time interval options. | |
DatabaseAggregatorSensorPluginBase:: |
protected | function | Gets the time interval value. | |
DependencyTrait:: |
protected | property | The object's dependencies. | |
DependencyTrait:: |
protected | function | Adds multiple dependencies. | |
DependencyTrait:: |
protected | function | Adds a dependency. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PhpNoticesSensorPlugin:: |
protected | property |
Allows plugins to control if the conditions table should be shown. Overrides DatabaseAggregatorSensorPlugin:: |
|
PhpNoticesSensorPlugin:: |
protected | property |
Allows plugins to control if the verbose output table should be shown. Overrides DatabaseAggregatorSensorPlugin:: |
|
PhpNoticesSensorPlugin:: |
public | function |
Builds simple aggregate query over one db table. Overrides DatabaseAggregatorSensorPlugin:: |
|
PhpNoticesSensorPlugin:: |
public | function |
Builds the query for verbose output. Overrides DatabaseAggregatorSensorPlugin:: |
|
PhpNoticesSensorPlugin:: |
public | function |
Runs the sensor, updating $sensor_result. Overrides DatabaseAggregatorSensorPlugin:: |
|
PhpNoticesSensorPlugin:: |
protected | function | Removes the root path from a filename. | |
PhpNoticesSensorPlugin:: |
public | function |
Adds unaggregated verbose output to the render array $output. Overrides WatchdogAggregatorSensorPlugin:: |
|
SensorPluginBase:: |
protected | property | The plugin implementation definition. | |
SensorPluginBase:: |
protected | property | The plugin_id. | |
SensorPluginBase:: |
protected | property | Current sensor config object. | |
SensorPluginBase:: |
protected | property | ||
SensorPluginBase:: |
public | function |
Service setter. Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
public static | function |
Creates an instance of the sensor with config. Overrides SensorPluginInterface:: |
7 |
SensorPluginBase:: |
public | function |
Configurable value type. Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
SensorPluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
SensorPluginBase:: |
public | function |
Gets sensor name (not the label). Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
public | function |
@todo: Replace with injection Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
public | function |
Determines if sensor is enabled. Overrides SensorPluginInterface:: |
|
SensorPluginBase:: |
function | Instantiates a sensor object. | 8 | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
WatchdogAggregatorSensorPlugin:: |
protected | property |
Allows plugins to control if the table can be configured. Overrides DatabaseAggregatorSensorPlugin:: |
|
WatchdogAggregatorSensorPlugin:: |
protected | property |
Allows plugins to control if a timestamp field can be configured. Overrides DatabaseAggregatorSensorPluginBase:: |
|
WatchdogAggregatorSensorPlugin:: |
public | function |
Default configuration for a sensor. Overrides DatabaseAggregatorSensorPlugin:: |
|
WatchdogAggregatorSensorPlugin:: |
public | function |
Adds history verbose output to the render array $output. Overrides DatabaseAggregatorSensorPlugin:: |