Skip to content

Commit 2c62e8b

Browse files
committed
Merge pull request parse-community#169 from Pmovil/master
Missing PSR4 update on CONTRIBUTING.md
2 parents 69093d7 + 7d3773c commit 2c62e8b

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ App just for testing, and deploy some cloud code to it.
2020
* Use the Parse CLI to create a Cloud Code folder for the new app.
2121
* Copy tests/cloudcode/cloud/main.js into the newly created cloud/ folder.
2222
* Run "parse deploy" in your cloud folder.
23-
* Paste your App ID, REST API Key, and Master Key in tests/ParseTestHelper.php
23+
* Paste your App ID, REST API Key, and Master Key in tests/Parse/Helper.php
2424

2525
You should now be able to execute, from project root folder:
2626

src/Parse/ParseClient.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ final class ParseClient
6464
*/
6565
private static $forceRevocableSession = false;
6666

67+
/**
68+
* Number of seconds to wait while trying to connect. Use 0 to wait indefinitely.
69+
*
70+
* @var int
71+
*/
72+
private static $connectionTimeout;
73+
74+
/**
75+
* Maximum number of seconds of request/response operation.
76+
*
77+
* @var int
78+
*/
79+
private static $timeout;
80+
6781
/**
6882
* Constant for version string to include with requests.
6983
*
@@ -280,6 +294,14 @@ public static function _request($method, $relativeUrl, $sessionToken = null,
280294
curl_setopt($rest, CURLOPT_CUSTOMREQUEST, $method);
281295
}
282296
curl_setopt($rest, CURLOPT_HTTPHEADER, $headers);
297+
298+
if (!is_null(self::$connectionTimeout)) {
299+
curl_setopt($rest, CURLOPT_CONNECTTIMEOUT, self::$connectionTimeout);
300+
}
301+
if (!is_null(self::$timeout)) {
302+
curl_setopt($rest, CURLOPT_TIMEOUT, self::$timeout);
303+
}
304+
283305
$response = curl_exec($rest);
284306
$status = curl_getinfo($rest, CURLINFO_HTTP_CODE);
285307
$contentType = curl_getinfo($rest, CURLINFO_CONTENT_TYPE);
@@ -439,4 +461,24 @@ public static function enableRevocableSessions()
439461
{
440462
self::$forceRevocableSession = true;
441463
}
464+
465+
/**
466+
* Sets number of seconds to wait while trying to connect. Use 0 to wait indefinitely, null to default behaviour.
467+
*
468+
* @param int|null $connectionTimeout
469+
*/
470+
public static function setConnectionTimeout($connectionTimeout)
471+
{
472+
self::$connectionTimeout = $connectionTimeout;
473+
}
474+
475+
/**
476+
* Sets maximum number of seconds of request/response operation. Use 0 to wait indefinitely, null to default behaviour.
477+
*
478+
* @param int|null $timeout
479+
*/
480+
public static function setTimeout($timeout)
481+
{
482+
self::$timeout = $timeout;
483+
}
442484
}

src/Parse/ParsePush.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ public static function send($data, $useMasterKey = false)
4141
}
4242
if (isset($data['where'])) {
4343
if ($data['where'] instanceof ParseQuery) {
44-
45-
$where_options = $data['where']->_getOptions();
44+
$where_options = $data['where']->_getOptions();
4645

4746
if (!isset($query_where['where'])) {
4847
$data['where'] = '{}';
4948
} else {
5049
$data['where'] = $data['where']->_getOptions()['where'];
5150
}
52-
5351
} else {
5452
throw new Exception(
5553
'Where parameter for Parse Push must be of type ParseQuery'

0 commit comments

Comments
 (0)