ErrorLog
in package
implements
ActionInterface
Uses
BackwardCompatibility
Shows a list of all errors that were logged on the forum, and allows filtering and deleting them.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $filter : array<string|int, mixed>
- $filters : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- call() : void
- Convenience method to load() and execute() an instance of this class.
- execute() : void
- Dispatcher to whichever method is necessary.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- load() : object
- Static wrapper for constructor.
- view() : void
- View the forum's error log.
- viewBacktrace() : void
- View a backtrace specified in $_REQUEST['backtrace'], with PHP highlighting.
- viewFile() : void
- View a file specified in $_REQUEST['file'], with PHP highlighting.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- deleteErrors() : mixed
- Delete all or some of the errors in the error log.
Properties
$filter
public
array<string|int, mixed>
$filter
Info about the currently applied filter.
$filters
public
array<string|int, mixed>
$filters
= ['id_member' => ['txt' => 'username', 'operator' => '=', 'datatype' => 'int'], 'ip' => ['txt' => 'ip_address', 'operator' => '=', 'datatype' => 'inet'], 'session' => ['txt' => 'session', 'operator' => 'LIKE', 'datatype' => 'string'], 'url' => ['txt' => 'error_url', 'operator' => 'LIKE', 'datatype' => 'string'], 'message' => ['txt' => 'error_message', 'operator' => 'LIKE', 'datatype' => 'string'], 'error_type' => ['txt' => 'error_type', 'operator' => 'LIKE', 'datatype' => 'string'], 'file' => ['txt' => 'file', 'operator' => 'LIKE', 'datatype' => 'string'], 'line' => ['txt' => 'line', 'operator' => '=', 'datatype' => 'int']]
Basic info about the available filters.
$obj
protected
static object
$obj
An instance of this class. This is used by the load() method to prevent mulitple instantiations.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'ViewErrorLog']]
BackwardCompatibility settings for this class.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
execute()
Dispatcher to whichever method is necessary.
public
execute() : void
exportStatic()
Provides a way to export a class's public static properties and methods to global namespace.
public
static exportStatic() : void
To do so:
- Use this trait in the class.
- At the END of the class's file, call its exportStatic() method.
Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.
Regarding the $backcompat items:
A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].
$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.
$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.
Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
view()
View the forum's error log.
public
view() : void
This function sets all the context up to show the error log for maintenance. It requires the maintain_forum permission. It is accessed from ?action=admin;area=logs;sa=errorlog.
viewBacktrace()
View a backtrace specified in $_REQUEST['backtrace'], with PHP highlighting.
public
viewBacktrace() : void
Preconditions:
- user must have admin_forum permission.
viewFile()
View a file specified in $_REQUEST['file'], with PHP highlighting.
public
viewFile() : void
Preconditions:
- file must be readable,
- full file path must be base64 encoded,
- user must have admin_forum permission.
The line number number is specified by $_REQUEST['line']... This method will try to get the 20 lines before and after the specified line.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
deleteErrors()
Delete all or some of the errors in the error log.
protected
deleteErrors() : mixed
It applies any necessary filters to deletion. It attempts to TRUNCATE the table to reset the auto_increment. Redirects back to the error log when done.