Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use wcf\data\contact\option\ContactOptionEditor;
use wcf\data\contact\option\ContactOptionList;
use wcf\util\JSON;

use wcf\util\OptionUtil;

$contactOptionList = new ContactOptionList();
Expand Down Expand Up @@ -39,7 +39,7 @@
$editor = new ContactOptionEditor($contactOption);
$editor->update([
'optionType' => $optionType,
'configuration' => JSON::encode($configuration),
'configuration' => \json_encode($configuration, \JSON_THROW_ON_ERROR),
]);
}

Expand All @@ -57,5 +57,5 @@ function convertSelectOptions(string $selectOptions): string
];
}

return JSON::encode($options);
return \json_encode($options, \JSON_THROW_ON_ERROR);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use wcf\system\exception\SystemException;
use wcf\system\WCF;
use wcf\system\worker\IWorker;
use wcf\util\JSON;

/**
* Handles worker actions.
Expand Down Expand Up @@ -143,7 +142,7 @@ protected function sendResponse($progress = 0, ?array $parameters = null, $proce

// send JSON-encoded response
\header('Content-type: application/json; charset=UTF-8');
echo JSON::encode($returnValues);
echo \json_encode($returnValues, \JSON_THROW_ON_ERROR);

exit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use wcf\system\form\builder\IFormDocument;
use wcf\system\form\option\FormOptionHandler;
use wcf\system\form\option\SharedConfigurationFormFields;
use wcf\util\JSON;

/**
* Default implementation for a form that adds custom options based on the form option system.
Expand Down Expand Up @@ -47,7 +46,7 @@ function (IFormDocument $document, array $parameters) {
}
}

$parameters['data']['configuration'] = JSON::encode($configuration);
$parameters['data']['configuration'] = \json_encode($configuration, \JSON_THROW_ON_ERROR);

return $parameters;
},
Expand All @@ -56,7 +55,7 @@ function (IFormDocument $document, array $data, IStorableObject $object) {

// @phpstan-ignore property.notFound
if ($object->configuration) {
$data = \array_merge($data, JSON::decode($object->configuration));
$data = \array_merge($data, \json_decode($object->configuration, true, flags: \JSON_THROW_ON_ERROR));
}

return $data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use wcf\system\exception\UserInputException;
use wcf\system\file\upload\UploadFile;
use wcf\system\file\upload\UploadHandler;
use wcf\util\JSON;

/**
* Copy of the default implementation for file uploads using the AJAX-API.
Expand Down Expand Up @@ -97,7 +96,7 @@ public function execute()
*/
protected function sendJsonResponse(array $data)
{
$json = JSON::encode($data);
$json = \json_encode($data, \JSON_THROW_ON_ERROR);

// send JSON response
\header('Content-type: application/json; charset=UTF-8');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use wcf\system\WCF;
use wcf\util\FileUtil;
use wcf\util\ImageUtil;
use wcf\util\JSON;

/**
* Copy of the default implementation for file uploads using the AJAX-API.
Expand Down Expand Up @@ -153,7 +152,7 @@ public function execute()
*/
protected function sendJsonResponse(array $data)
{
$json = JSON::encode($data);
$json = \json_encode($data, \JSON_THROW_ON_ERROR);

// send JSON response
\header('Content-type: application/json; charset=UTF-8');
Expand Down
3 changes: 1 addition & 2 deletions wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use wcf\system\IAJAXInvokeAction;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
use wcf\util\JSON;
use wcf\util\StringUtil;

/**
Expand Down Expand Up @@ -168,7 +167,7 @@ protected function invoke()
protected function sendResponse()
{
\header('Content-type: application/json; charset=UTF-8');
echo JSON::encode($this->response);
echo \json_encode($this->response, \JSON_THROW_ON_ERROR);

exit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace wcf\action;

use wcf\util\JSON;

/**
* @deprecated 5.5 Use PSR-7 responses (e.g. Laminas' JsonResponse).
*/
Expand All @@ -17,7 +15,7 @@ abstract class AbstractAjaxAction extends AbstractAction
*/
protected function sendJsonResponse(array $data)
{
$json = JSON::encode($data);
$json = \json_encode($data, \JSON_THROW_ON_ERROR);

// send JSON response
\header('Content-type: application/json; charset=UTF-8');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use wcf\system\user\authentication\oauth\User as OauthUser;
use wcf\system\WCF;
use wcf\util\HtmlString;
use wcf\util\JSON;

/**
* Generic implementation to handle the OAuth 2 flow.
Expand Down Expand Up @@ -182,7 +181,7 @@ protected function codeToAccessToken(string $code): array
}
}

$parsed = JSON::decode((string)$response->getBody());
$parsed = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);

if (!empty($parsed['error'])) {
throw new \Exception(\sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use wcf\system\user\authentication\oauth\User as OauthUser;
use wcf\system\WCF;
use wcf\util\HtmlString;
use wcf\util\JSON;

/**
* Generic implementation to handle the OAuth 2 flow.
Expand Down Expand Up @@ -163,7 +162,7 @@ protected function getAccessToken(OAuth2Success $auth2Success): array
}
}

$parsed = JSON::decode((string)$response->getBody());
$parsed = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);

if (!empty($parsed['error'])) {
throw new \Exception(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use GuzzleHttp\Psr7\Request;
use wcf\system\request\LinkHandler;
use wcf\system\user\authentication\oauth\User as OauthUser;
use wcf\util\JSON;
use wcf\util\StringUtil;

/**
Expand Down Expand Up @@ -75,7 +74,7 @@ protected function getUser(array $accessToken): OauthUser
'authorization' => \sprintf('Bearer %s', $accessToken['access_token']),
]);
$response = $this->getHttpClient()->send($request);
$parsed = JSON::decode((string)$response->getBody());
$parsed = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);

$parsed['__id'] = $parsed['id'];
$parsed['__username'] = $parsed['name'];
Expand Down
5 changes: 2 additions & 3 deletions wcfsetup/install/files/lib/action/GithubAuthAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Psr\Http\Message\ResponseInterface;
use wcf\system\request\LinkHandler;
use wcf\system\user\authentication\oauth\User as OauthUser;
use wcf\util\JSON;
use wcf\util\StringUtil;

/**
Expand Down Expand Up @@ -71,7 +70,7 @@ protected function getUser(array $accessToken): OauthUser
'authorization' => \sprintf('Bearer %s', $accessToken['access_token']),
]);
$response = $this->getHttpClient()->send($request);
$parsed = JSON::decode((string)$response->getBody());
$parsed = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);

$parsed['__id'] = $parsed['id'];
$parsed['__username'] = $parsed['login'];
Expand All @@ -95,7 +94,7 @@ protected function redirectToRegistration(OauthUser $oauthUser): ResponseInterfa
'authorization' => \sprintf('Bearer %s', $oauthUser["accessToken"]["access_token"]),
]);
$response = $this->getHttpClient()->send($request);
$emails = JSON::decode((string)$response->getBody());
$emails = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);

// search primary email
$email = $emails[0]['email'];
Expand Down
5 changes: 2 additions & 3 deletions wcfsetup/install/files/lib/action/GoogleAuthAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use GuzzleHttp\Psr7\Request;
use wcf\system\request\LinkHandler;
use wcf\system\user\authentication\oauth\User as OauthUser;
use wcf\util\JSON;
use wcf\util\StringUtil;

/**
Expand Down Expand Up @@ -35,7 +34,7 @@ private function getConfiguration(): array
$request = new Request('GET', 'https://accounts.google.com/.well-known/openid-configuration');
$response = $this->getHttpClient()->send($request);

$this->configuration = JSON::decode((string)$response->getBody());
$this->configuration = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);
}

return $this->configuration;
Expand Down Expand Up @@ -91,7 +90,7 @@ protected function getUser(array $accessToken): OauthUser
'authorization' => \sprintf('Bearer %s', $accessToken['access_token']),
]);
$response = $this->getHttpClient()->send($request);
$parsed = JSON::decode((string)$response->getBody());
$parsed = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);

$parsed['__id'] = $parsed['sub'];
$parsed['__username'] = $parsed['name'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use wcf\system\user\authentication\oauth\twitter\Success as OAuth2TwitterSuccess;
use wcf\system\user\authentication\oauth\User as OauthUser;
use wcf\system\WCF;
use wcf\util\JSON;
use wcf\util\StringUtil;

/**
Expand Down Expand Up @@ -134,7 +133,7 @@ protected function getUser(array $accessToken): OauthUser
);
$response = $this->getHttpClient()->send($request);

$parsed = JSON::decode((string)$response->getBody());
$parsed = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);
$parsed['__id'] = $parsed['id'];
$parsed['__username'] = $parsed['name'];
if (!empty($parsed['email'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use wcf\system\io\AtomicWriter;
use wcf\system\language\LanguageFactory;
use wcf\system\WCF;
use wcf\util\JSON;

/**
* Generate then `manifest-*.json` files for a style.
Expand Down Expand Up @@ -43,16 +42,16 @@ public function __invoke(): void
"type" => "image/png"
];
}
$icons = JSON::encode($icons);
$icons = \json_encode($icons, \JSON_THROW_ON_ERROR);

$originalLanguage = WCF::getLanguage();
try {
foreach (LanguageFactory::getInstance()->getLanguages() as $language) {
// To get the correct landing page url, we need to change the language.
WCF::setLanguage($language->languageID);

$title = JSON::encode($language->get(PAGE_TITLE));
$startUrl = JSON::encode($landingPage->getLink());
$title = \json_encode($language->get(PAGE_TITLE), \JSON_THROW_ON_ERROR);
$startUrl = \json_encode($landingPage->getLink(), \JSON_THROW_ON_ERROR);

// update manifest.json
$manifest = <<<MANIFEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use wcf\system\request\RequestHandler;
use wcf\system\WCF;
use wcf\util\ArrayUtil;
use wcf\util\JSON;
use wcf\util\StringUtil;

/**
Expand Down Expand Up @@ -655,8 +654,8 @@ protected function readValue($variableName, $allowEmpty, $arrayIndex, $type, $st
}
} else {
try {
$target[$variableName] = JSON::decode($target[$variableName]);
} catch (SystemException $e) {
$target[$variableName] = \json_decode($target[$variableName], true, flags: \JSON_THROW_ON_ERROR);
} catch (\JsonException) {
throw new UserInputException($variableName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use wcf\data\blacklist\status\BlacklistStatusEditor;
use wcf\system\io\HttpFactory;
use wcf\system\WCF;
use wcf\util\JSON;

/**
* Executes blacklist entry-related actions.
Expand Down Expand Up @@ -61,7 +60,7 @@ public function import()
return;
}

$data = JSON::decode((string)$response->getBody());
$data = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);
$sql = "INSERT INTO wcf1_blacklist_entry
(type, hash, lastSeen, occurrences)
VALUES (?, ?, ?, ?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use wcf\data\DatabaseObject;
use wcf\system\exception\SystemException;
use wcf\system\io\HttpFactory;
use wcf\util\JSON;

/**
* Represents a blacklist status.
Expand Down Expand Up @@ -113,7 +112,7 @@ public static function getNextDelta(array $status, ?ClientInterface $client = nu
return null;
}

$data = JSON::decode((string)$response->getBody());
$data = \json_decode((string)$response->getBody(), true, flags: \JSON_THROW_ON_ERROR);
$deltas = ['delta1', 'delta2', 'delta3', 'delta4'];

// The array is ordered from "now" to "14 days ago".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use wcf\system\form\option\FormOptionHandler;
use wcf\system\form\option\IFormOption;
use wcf\system\WCF;
use wcf\util\JSON;

/**
* Represents a contact option.
Expand Down Expand Up @@ -75,6 +74,6 @@ public function getFormOption(): IFormOption
*/
public function getConfiguration(): array
{
return $this->configuration ? JSON::decode($this->configuration) : [];
return $this->configuration ? \json_decode($this->configuration, true, flags: \JSON_THROW_ON_ERROR) : [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use wcf\data\language\Language;
use wcf\system\language\LanguageFactory;
use wcf\system\WCF;
use wcf\util\JSON;

/**
* Represents a missing language item log entry.
Expand Down Expand Up @@ -47,7 +46,7 @@ public function getLanguage()
*/
public function getStackTrace()
{
$stackTrace = JSON::decode($this->stackTrace);
$stackTrace = \json_decode($this->stackTrace, true, flags: \JSON_THROW_ON_ERROR);

return WCF::getTPL()->render('wcf', '__devtoolsMissingLanguageItemStackTrace', [
'stackTrace' => $stackTrace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use wcf\data\IDeleteAction;
use wcf\system\exception\IllegalLinkException;
use wcf\system\WCF;
use wcf\util\JSON;
use wcf\util\StringUtil;

/**
Expand Down Expand Up @@ -70,7 +69,7 @@ public function logLanguageItem()
return $item;
}, \wcf\functions\exception\sanitizeStacktrace(new \Exception(), true));

$stackTrace = JSON::encode($stackTraceData);
$stackTrace = \json_encode($stackTraceData, \JSON_THROW_ON_ERROR);

$sql = "INSERT INTO wcf1_devtools_missing_language_item
(languageID, languageItem, lastTime, stackTrace)
Expand Down
Loading