Skip to content

Commit

Permalink
more log in JsonCodec::serialize
Browse files Browse the repository at this point in the history
  • Loading branch information
rpuboh committed Jul 1, 2024
1 parent 655b70d commit ddd013c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion includes/json/JsonCodec.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
use InvalidArgumentException;
use JsonSerializable;
use Wikimedia\Assert\Assert;
use CacheTime;
use MediaWiki\Json\JsonUnserializable;

/**
* Helper class to serialize/unserialize things to/from JSON.
Expand Down Expand Up @@ -88,12 +90,17 @@ public function unserializeArray( array $array ): array {

public function serialize( $value ) {
$valclass = get_class($value);
$v1 = $value instanceof JsonSerializable;
$v2 = $value instanceof CacheTime;
$v3 = $value instanceof JsonUnserializable;
if ( $value instanceof JsonSerializable ) {
wfDebugLog('pcd', "JC: calling jsonSerialize");
$value = $value->jsonSerialize();
}
$json = FormatJson::encode( $value, false, FormatJson::ALL_OK );
wfDebugLog('pcd', "JC: $valclass; $json");
usleep(2000);
wfDebugLog('pcd', "JsonSerializable $v1; CacheTime $v2; JsonUnserializable $v3");
usleep(1000);
if ( !$json ) {
// TODO: make it JsonException
throw new InvalidArgumentException(
Expand Down

0 comments on commit ddd013c

Please sign in to comment.