Skip to content

Commit cc54d6f

Browse files
authored
Merge branch 'master' into count-conditions
2 parents 0c0840b + 0fc3d8f commit cc54d6f

34 files changed

+883
-9
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ jobs:
2626
strategy:
2727
matrix:
2828
include:
29-
- name: PHP 8.1
30-
PHP_VERSION: 8.1
3129
- name: PHP 8.2
3230
PHP_VERSION: 8.2
31+
- name: PHP 8.1
32+
PHP_VERSION: 8.1
3333
fail-fast: false
34+
name: Test ${{ matrix.name }}
3435
steps:
3536
- uses: actions/checkout@v3
3637
- name: Use Node.js
@@ -59,3 +60,6 @@ jobs:
5960
env:
6061
CI: true
6162
- run: bash <(curl -s https://codecov.io/bash)
63+
concurrency:
64+
group: ${{ github.workflow }}-${{ github.ref }}
65+
cancel-in-progress: true

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# [2.3.0](https://github.com/parse-community/parse-php-sdk/compare/2.2.0...2.3.0) (2023-05-13)
2+
3+
4+
### Features
5+
6+
* Add query methods `fetchWithInclude` and `fetchAllWithInclude` ([#512](https://github.com/parse-community/parse-php-sdk/issues/512)) ([0570f15](https://github.com/parse-community/parse-php-sdk/commit/0570f157a5e4efb2310b7df44c25ff246077589a))
7+
8+
# [2.2.0](https://github.com/parse-community/parse-php-sdk/compare/2.1.0...2.2.0) (2023-05-13)
9+
10+
11+
### Features
12+
13+
* Allow http options to be passed into `ParseClient` ([#513](https://github.com/parse-community/parse-php-sdk/issues/513)) ([ee2a5fa](https://github.com/parse-community/parse-php-sdk/commit/ee2a5fa389d553e73e483130647fd93cf187d142))
14+
115
# [2.1.0](https://github.com/parse-community/parse-php-sdk/compare/2.0.0...2.1.0) (2023-04-29)
216

317

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ A library that gives you access to the powerful Parse Server backend from your P
2424

2525
## Table of Contents <!-- omit in toc -->
2626

27+
- [Compatibility](#compatibility)
2728
- [Installation](#installation)
2829
- [Install with Composer](#install-with-composer)
2930
- [Install with Git](#install-with-git)
@@ -64,6 +65,15 @@ A library that gives you access to the powerful Parse Server backend from your P
6465
- [Logs](#logs)
6566
- [Contributing / Testing](#contributing--testing)
6667

68+
## Compatibility
69+
70+
The Parse PHP SDK is continuously tested with the most recent releases of PHP to ensure compatibility. We follow the [PHP Long Term Support plan](https://www.php.net/supported-versions.php) and only test against versions that are officially supported and have not reached their end-of-life date.
71+
72+
| Version | End-of-Life | Compatible |
73+
|---------|-------------|------------|
74+
| PHP 8.2 | Dec 2024 | ✅ Yes |
75+
| PHP 8.1 | Nov 2023 | ✅ Yes |
76+
6777
## Installation
6878
There are various ways to install and use this sdk. We'll elaborate on a couple here.
6979
Note that the Parse PHP SDK requires PHP 5.4 or newer. It can also run on HHVM (recommended 3.0 or newer).

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
"semantic-release": "21.0.1",
3333
"winston": "3.2.1"
3434
},
35-
"version": "2.1.0"
35+
"version": "2.3.0"
3636
}

src/Parse/HttpClients/ParseCurlHttpClient.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,18 @@ public function setCAFile($caFile)
306306
$this->parseCurl->setOption(CURLOPT_CAINFO, $caFile);
307307
}
308308

309+
/**
310+
* Sets multiple curl options
311+
* https://www.php.net/manual/en/function.curl-setopt.php
312+
*
313+
* @param array $options Array of options to set
314+
* @throws ParseException
315+
*/
316+
public function setHttpOptions($options)
317+
{
318+
$this->parseCurl->setOptionsArray($options);
319+
}
320+
309321
/**
310322
* Gets the error code
311323
*

src/Parse/HttpClients/ParseHttpable.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ public function setTimeout($timeout);
6363
*/
6464
public function setCAFile($caFile);
6565

66+
/**
67+
* Sets http options to pass to the http client
68+
*
69+
* @param string $httpOptions Options to set
70+
*/
71+
public function setHttpOptions($httpOptions);
72+
6673
/**
6774
* Gets the error code
6875
*

src/Parse/HttpClients/ParseStreamHttpClient.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ class ParseStreamHttpClient implements ParseHttpable
7878
*/
7979
private $caFile;
8080

81+
/**
82+
* Options to pass to the stream context.
83+
*
84+
* @var array
85+
*/
86+
private $httpOptions;
87+
8188
/**
8289
* Optional timeout for this request
8390
*
@@ -195,6 +202,12 @@ public function send($url, $method = 'GET', $data = array())
195202
$this->options['ssl']['cafile'] = $this->caFile;
196203
}
197204

205+
if (isset($this->httpOptions)) {
206+
foreach ($this->httpOptions as $key => $value) {
207+
$this->options[$key] = $value;
208+
}
209+
}
210+
198211
// add additional options for this request
199212
$this->options['http'] = array(
200213
'method' => $method,
@@ -264,6 +277,7 @@ public function send($url, $method = 'GET', $data = array())
264277

265278
// clear options
266279
$this->options = array();
280+
$this->httpOptions = array();
267281

268282
// flush our existing headers
269283
$this->headers = array();
@@ -348,6 +362,17 @@ public function setCAFile($caFile)
348362
$this->caFile = $caFile;
349363
}
350364

365+
/**
366+
* Sets http options to pass to the stream context
367+
* https://www.php.net/manual/en/context.php
368+
*
369+
* @param array $httpOptions options to set
370+
*/
371+
public function setHttpOptions($httpOptions)
372+
{
373+
$this->httpOptions = $httpOptions;
374+
}
375+
351376
/**
352377
* Sets the request timeout
353378
*

src/Parse/ParseClient.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,19 @@ final class ParseClient
103103
*/
104104
private static $caFile;
105105

106+
/**
107+
* Options to pass to the http client.
108+
*
109+
* @var array
110+
*/
111+
private static $httpOptions;
112+
106113
/**
107114
* Constant for version string to include with requests.
108115
*
109116
* @var string
110117
*/
111-
const VERSION_STRING = '2.1.0';
118+
const VERSION_STRING = '2.3.0';
112119

113120
/**
114121
* Parse\Client::initialize, must be called before using Parse features.
@@ -301,6 +308,21 @@ public static function setCAFile($caFile)
301308
self::$caFile = $caFile;
302309
}
303310

311+
/**
312+
* Sets http options to pass to the http client
313+
* For curl
314+
* https://www.php.net/manual/en/function.curl-setopt.php
315+
*
316+
* For stream context
317+
* https://www.php.net/manual/en/context.php
318+
*
319+
* @param array $httpOptions options to set
320+
*/
321+
public static function setHttpOptions($httpOptions)
322+
{
323+
self::$httpOptions = $httpOptions;
324+
}
325+
304326
/**
305327
* ParseClient::_encode, internal method for encoding object values.
306328
*
@@ -452,6 +474,9 @@ private static function getPreparedHttpClient()
452474
// set CA file
453475
$httpClient->setCAFile(self::$caFile);
454476
}
477+
if (isset(self::$httpOptions)) {
478+
$httpClient->setHttpOptions(self::$httpOptions);
479+
}
455480

456481
return $httpClient;
457482
}

src/Parse/ParseObject.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,33 @@ public function fetch($useMasterKey = false)
570570
return $this;
571571
}
572572

573+
/**
574+
* Fetch an array of Parse objects from the server.
575+
*
576+
* @param array $objects The ParseObjects to fetch
577+
* @param array $includeKeys The nested ParseObjects to fetch
578+
* @param bool $useMasterKey Whether to override ACLs
579+
*
580+
* @return ParseObject Returns self, so you can chain this call.
581+
*/
582+
public function fetchWithInclude(array $includeKeys, $useMasterKey = false)
583+
{
584+
$sessionToken = null;
585+
if (ParseUser::getCurrentUser()) {
586+
$sessionToken = ParseUser::getCurrentUser()->getSessionToken();
587+
}
588+
$response = ParseClient::_request(
589+
'GET',
590+
'classes/'.$this->className.'/'.$this->objectId.'?include='.implode(',', $includeKeys),
591+
$sessionToken,
592+
null,
593+
$useMasterKey
594+
);
595+
$this->_mergeAfterFetch($response);
596+
597+
return $this;
598+
}
599+
573600
/**
574601
* Fetch an array of Parse objects from the server.
575602
*
@@ -593,6 +620,31 @@ public static function fetchAll(array $objects, $useMasterKey = false)
593620
return static::updateWithFetchedResults($objects, $results);
594621
}
595622

623+
/**
624+
* Fetch an array of Parse Objects from the server with nested Parse Objects.
625+
*
626+
* @param array $objects The ParseObjects to fetch
627+
* @param mixed $includeKeys The nested ParseObjects to fetch
628+
* @param bool $useMasterKey Whether to override ACLs
629+
*
630+
* @return array
631+
*/
632+
public static function fetchAllWithInclude(array $objects, $includeKeys, $useMasterKey = false)
633+
{
634+
$objectIds = static::toObjectIdArray($objects);
635+
if (!count($objectIds)) {
636+
return $objects;
637+
}
638+
$className = $objects[0]->getClassName();
639+
$query = new ParseQuery($className);
640+
$query->containedIn('objectId', $objectIds);
641+
$query->limit(count($objectIds));
642+
$query->includeKey($includeKeys);
643+
$results = $query->find($useMasterKey);
644+
645+
return static::updateWithFetchedResults($objects, $results);
646+
}
647+
596648
/**
597649
* Creates an array of object ids from a given array of ParseObjects
598650
*

0 commit comments

Comments
 (0)