Skip to content

Commit

Permalink
Yii2 2.0.14 upgrade: Use yii::debug instead of yii::trace. Add debug …
Browse files Browse the repository at this point in the history
…messages with the request and response data.
  • Loading branch information
drsdre committed Feb 20, 2018
1 parent eb80203 commit 8256e14
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
17 changes: 15 additions & 2 deletions Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace drsdre\WordpressApi;

use yii;
use yii\helpers\Json;
use yii\authclient\OAuthToken;
use yii\base\BaseObject;
use yii\base\InvalidConfigException;
use yii\base\InvalidParamException;
use yii\base\InvalidArgumentException;
use yii\httpclient\Request;
use yii\httpclient\Response;
use yii\httpclient\Client as HttpClient;
Expand All @@ -22,6 +23,8 @@
* @see http://v2.wp-api.org/
*
* @author Andre Schuurman <[email protected]>
*
* @property $lastRequestContent string
*/
class Client extends BaseObject {

Expand Down Expand Up @@ -426,9 +429,19 @@ protected function executeRequest() {

do {
try {
yii::debug(
'Send ' . $this->request->method . ' request to WP url ' . $this->request->fullUrl,
__METHOD__
);

// Execute the request
$this->response = $this->request->send();

yii::debug(
'WP Response: ' . $this->response->content,
__METHOD__
);

// Test the result
$result_content = Json::decode( $this->response->content, false );

Expand Down Expand Up @@ -562,7 +575,7 @@ protected function executeRequest() {
}
}

} catch ( InvalidParamException $e ) {
} catch ( InvalidArgumentException $e ) {
// Handle JSON parsing error
// Map to status code 512 (unassigned, used for 'illegal response')
throw new Exception( 'Invalid JSON data returned (' . $e->getMessage() . "): " . $this->response->content,
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
],
"require": {
"php": ">=5.5.0",
"yiisoft/yii2-authclient": "^2.1.3"
"yiisoft/yii2": "~2.0.14",
"yiisoft/yii2-authclient": "~2.1.3"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit 8256e14

Please sign in to comment.