Skip to content

Commit

Permalink
Http::unserialize - centralise debug logging of response
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianZaremba committed Oct 18, 2021
1 parent a34056a commit f5a4e22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
15 changes: 1 addition & 14 deletions src/Wikipedia/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,6 @@ public function edit(
}

$x = $this->http->post($this->apiurl, $params);
if ($this->logger !== null) {
$this->logger->addDebug($x);
}

$x = $this->http->unserialize($x);

if ($x['edit']['result'] == 'Success') {
Expand Down Expand Up @@ -523,7 +519,7 @@ public function gettoken($title)
public function getLoginToken()
{
$x = $this->http->get($this->apiurl . '?rawcontinue=1&format=php' .
'?action=query&meta=tokens&type=login');
'&meta=tokens&type=login');
$x = $this->http->unserialize($x);

return $x['query']['tokens']['logintoken'];
Expand All @@ -547,10 +543,6 @@ public function login($user, $pass)
'lgtoken' => $this->getLoginToken())
);

if ($this->logger !== null) {
$this->logger->addDebug($x);
}

$x = $this->http->unserialize($x);

return $x['login']['result'] == 'Success';
Expand Down Expand Up @@ -584,11 +576,6 @@ public function move($old, $new, $reason, $checkrun = true)
);

$x = $this->http->post($this->apiurl, $params);

if ($this->logger !== null) {
$this->logger->addDebug($x);
}

$this->http->unserialize($x); // this emits warnings if needed
}

Expand Down
4 changes: 4 additions & 0 deletions src/Wikipedia/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ public function get($url)
**/
public function unserialize($response)
{
if ($this->logger !== null) {
$this->logger->addDebug('Decoding response: ' . $response);
}

$response = unserialize($response);

if ($this->logger !== null) {
Expand Down

0 comments on commit f5a4e22

Please sign in to comment.