Skip to content

Commit

Permalink
Added column names to values that are passed to the filterLogInfo() m…
Browse files Browse the repository at this point in the history
…ethod. This will make it a bit easier to modify or remove the columns in subclasses as you'll have meaningful keys instead of just numeric indexes.

Also added $request to method arguments so that it can be used to extract more information from the request and log it.

Note that this could be a BC-break because the old column indexes are no longer available.
  • Loading branch information
YahnisElsts committed Apr 23, 2018
1 parent c291ae8 commit 5a0c7bd
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions includes/Wpup/UpdateServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,16 +415,16 @@ protected function logRequest($request) {
}

$columns = array(
str_pad($loggedIp, 15, ' '),
str_pad($request->httpMethod, 4, ' '),
$request->param('action', '-'),
$request->param('slug', '-'),
$request->param('installed_version', '-'),
isset($request->wpVersion) ? $request->wpVersion : '-',
isset($request->wpSiteUrl) ? $request->wpSiteUrl : '-',
http_build_query($request->query, '', '&')
'ip' => str_pad($loggedIp, 15, ' '),
'http_method' => str_pad($request->httpMethod, 4, ' '),
'action' => $request->param('action', '-'),
'slug' => $request->param('slug', '-'),
'installed_version' => $request->param('installed_version', '-'),
'wp_version' => isset($request->wpVersion) ? $request->wpVersion : '-',
'site_url' => isset($request->wpSiteUrl) ? $request->wpSiteUrl : '-',
'query' => http_build_query($request->query, '', '&'),
);
$columns = $this->filterLogInfo($columns);
$columns = $this->filterLogInfo($columns, $request);

//Set the time zone to whatever the default is to avoid PHP notices.
//Will default to UTC if it's not set properly in php.ini.
Expand Down Expand Up @@ -460,9 +460,10 @@ protected function getLogFileName() {
* Intended to be overridden in child classes.
*
* @param array $columns List of columns in the log entry.
* @param Wpup_Request|null $request
* @return array
*/
protected function filterLogInfo($columns) {
protected function filterLogInfo($columns, /** @noinspection PhpUnusedParameterInspection */$request = null) {
return $columns;
}

Expand Down

0 comments on commit 5a0c7bd

Please sign in to comment.