Skip to content

Commit 2a248e5

Browse files
committed
TPCStorage: Throw a more useful error when trying to merge invalid JSON.
Since some files are built from multiple wiki pages, this is better than silently overwriting the file.
1 parent 196ae07 commit 2a248e5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

TPCStorage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ protected static function mergeOldFile( &$server, &$array, &$fn, &$changed ) {
6868
return $array;
6969
}
7070
$oldArray = json_decode( $oldJson, true );
71+
if ( $oldArray === null ) {
72+
throw new MWException(
73+
"`$fn` is invalid JSON. Ask an admin to fix the error on the server."
74+
);
75+
}
7176
return self::arrayMergeRecursiveDistinct( $oldArray, $array, $changed );
7277
}
7378

0 commit comments

Comments
 (0)