Skip to content

Commit 9431a38

Browse files
Merge branch '2.8' into 3.3
* 2.8: [travis] add ldap.so for php70 [HttpFoundation] Fix logic when JsonSerializable is missing
2 parents 87b3b1a + e4ce14d commit 9431a38

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ before_install:
128128
129129
- |
130130
# Install extra PHP extensions
131+
if [[ ! $skip && $PHP = 7.0 ]]; then
132+
wget https://github.com/symfony/binary-utils/releases/download/v0.1/ldap-php70.tar.bz2
133+
tar -xjf ldap-php70.tar.bz2
134+
echo extension = $(pwd)/ldap.so >> $INI
135+
fi
131136
if [[ ! $skip && $PHP = 5.* ]]; then
132137
([[ $deps ]] || tfold ext.symfony_debug 'cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> '"$INI") &&
133138
tfold ext.apcu4 'echo yes | pecl install -f apcu-4.0.11'

src/Symfony/Component/HttpFoundation/JsonResponse.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,22 @@ public function setData($data = array())
145145
// If only PHP did the same...
146146
$data = json_encode($data, $this->encodingOptions);
147147
} else {
148-
try {
149-
if (!interface_exists('JsonSerializable', false)) {
150-
set_error_handler(function () { return false; });
148+
if (!interface_exists('JsonSerializable', false)) {
149+
set_error_handler(function () { return false; });
150+
try {
151151
$data = @json_encode($data, $this->encodingOptions);
152-
restore_error_handler();
153-
} else {
154-
$data = json_encode($data, $this->encodingOptions);
155-
}
156-
} catch (\Exception $e) {
157-
if (!interface_exists('JsonSerializable', false)) {
152+
} finally {
158153
restore_error_handler();
159-
} elseif ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
160-
throw $e->getPrevious() ?: $e;
161154
}
162-
throw $e;
155+
} else {
156+
try {
157+
$data = json_encode($data, $this->encodingOptions);
158+
} catch (\Exception $e) {
159+
if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
160+
throw $e->getPrevious() ?: $e;
161+
}
162+
throw $e;
163+
}
163164
}
164165
}
165166

0 commit comments

Comments
 (0)