Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit b4ee993

Browse files
committed
Update CHANGELOG for #1001 and fixed review
1 parent 179eec3 commit b4ee993

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Version 5 of the Facebook PHP SDK is a complete refactor of version 4. It comes
1010
- Add `joined` to list of fields to be cast to `\DateTime` (#950)
1111
- Add `GraphPage::getFanCount()` to get the number of people who like the page (#815)
1212
- Fixed HTTP/2 support (#1079)
13+
- Fixed resumable upload error (#1001)
1314
- 5.6.3 (2018-07-01)
1415
- Add fix for countable error in PHP 7.2 (originally #969 by @andreybolonin)
1516
- 5.6.2 (2018-02-15)

src/Facebook/Exceptions/FacebookResponseException.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,10 @@ public static function create(FacebookResponse $response)
9797
case 1363037:
9898
$previousException = new FacebookResumableUploadException($message, $code);
9999

100-
$startOffset = isset($data['error']['error_data']['start_offset']) ?
101-
$data['error']['error_data']['start_offset'] : null;
100+
$startOffset = isset($data['error']['error_data']['start_offset']) ? (int) $data['error']['error_data']['start_offset'] : null;
102101
$previousException->setStartOffset($startOffset);
103102

104-
$endOffset = isset($data['error']['error_data']['end_offset']) ?
105-
$data['error']['error_data']['end_offset'] : null;
103+
$endOffset = isset($data['error']['error_data']['end_offset']) ? (int) $data['error']['error_data']['end_offset'] : null;
106104
$previousException->setEndOffset($endOffset);
107105

108106
return new static($response, $previousException);

src/Facebook/Exceptions/FacebookResumableUploadException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,31 @@ class FacebookResumableUploadException extends FacebookSDKException
3535
protected $endOffset;
3636

3737
/**
38-
* @return int
38+
* @return int|null
3939
*/
4040
public function getStartOffset()
4141
{
4242
return $this->startOffset;
4343
}
4444

4545
/**
46-
* @param int $startOffset
46+
* @param int|null $startOffset
4747
*/
4848
public function setStartOffset($startOffset)
4949
{
5050
$this->startOffset = $startOffset;
5151
}
5252

5353
/**
54-
* @return int
54+
* @return int|null
5555
*/
5656
public function getEndOffset()
5757
{
5858
return $this->endOffset;
5959
}
6060

6161
/**
62-
* @param int $endOffset
62+
* @param int|null $endOffset
6363
*/
6464
public function setEndOffset($endOffset)
6565
{

src/Facebook/FileUpload/FacebookResumableUploader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function transfer($endpoint, FacebookTransferChunk $chunk, $allowToThrow
121121
throw $e;
122122
}
123123

124-
if (!is_null($preException->getStartOffset()) && !is_null($preException->getEndOffset())) {
124+
if (null !== $preException->getStartOffset() && null !== $preException->getEndOffset()) {
125125
return new FacebookTransferChunk(
126126
$chunk->getFile(),
127127
$chunk->getUploadSessionId(),

src/Facebook/FileUpload/FacebookTransferChunk.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ public function getStartOffset()
121121
return $this->startOffset;
122122
}
123123

124+
/**
125+
* @return int
126+
*/
127+
public function getEndOffset()
128+
{
129+
return $this->endOffset;
130+
}
131+
124132
/**
125133
* Get uploaded video Id
126134
*

tests/FileUpload/FacebookResumableUploaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function testFailedResumableTransferWillNotThrowAndReturnNewChunk()
106106

107107
$chunk = new FacebookTransferChunk($this->file, '1', '2', '3', '4');
108108
$newChunk = $uploader->transfer('/me/videos', $chunk);
109-
$this->assertEquals('40', $newChunk->getStartOffset());
109+
$this->assertEquals(40, $newChunk->getStartOffset());
110+
$this->assertEquals(50, $newChunk->getEndOffset());
110111
}
111112
}

0 commit comments

Comments
 (0)