As can be seen in the Wikibase JSON documentation, we output hashes for snaks ("mainsnak") and collections of snaks ("references" and "qualifiers"). These hashes depend on the PHP serialization of these objects, for example:
abstract class SnakObject implements Snak { public function getHash() { return sha1( serialize( $this ) ); } }
Once we introduce the new PHP __serialize/ __unserialize methods (and PHP 7.4+ is used), this serialization will change. Especially when running in a mixed pre-PHP 7.4 and PHP 7.4+ environment, this can cause unexpected behavior (as hashes will change depending on the PHP version used).
In order to solve this, we should introduce legacy serialization methods that will output the old serialization regardless of the presence of the __serialize/__unserialize methods and the PHP version used.
Long-term we should consider moving away from using any form of PHP serialization for these hashes and introduce a fully controlled mean of defining these (previously discussed in T167759), but that's beyond the scope of this task.