Skip to content

Commit 5b66d5b

Browse files
committed
Handle infinite recursion correctly
1 parent eeda304 commit 5b66d5b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

client.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* @return WP_Post|WP_Error
99
*/
1010
function rest_get_client( $type, $key ) {
11-
// $this->should_attempt = false;
12-
1311
$query = new WP_Query();
1412
$consumers = $query->query( array(
1513
'post_type' => 'json_consumer',
@@ -26,8 +24,6 @@ function rest_get_client( $type, $key ) {
2624
),
2725
) );
2826

29-
// $this->should_attempt = true;
30-
3127
if ( empty( $consumers ) || empty( $consumers[0] ) ) {
3228
return new WP_Error( 'json_consumer_notfound', __( 'Consumer Key is invalid' ), array( 'status' => 401 ) );
3329
}

lib/class-wp-rest-oauth1.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ public function add_consumer( $params ) {
311311
* @return array Array of consumer object, user object
312312
*/
313313
public function check_token( $token, $consumer_key ) {
314+
$this->should_attempt = false;
314315
$consumer = rest_get_client( $this->type, $consumer_key );
316+
$this->should_attempt = true;
317+
315318
if ( is_wp_error( $consumer ) ) {
316319
return $consumer;
317320
}
@@ -479,7 +482,10 @@ public function generate_access_token( $oauth_consumer_key, $oauth_token, $oauth
479482
return new WP_Error( 'json_oauth1_invalid_verifier', __( 'OAuth verifier does not match' ), array( 'status' => 400 ) );
480483
}
481484

485+
$this->should_attempt = false;
482486
$consumer = rest_get_client( $this->type, $oauth_consumer_key );
487+
$this->should_attempt = true;
488+
483489
if ( is_wp_error( $consumer ) ) {
484490
return $consumer;
485491
}

0 commit comments

Comments
 (0)