Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/255921
Change subject: Add documentation for EntityContentDataCodec defaults ...................................................................... Add documentation for EntityContentDataCodec defaults This also makes it possible to omit the parameter. Before it must be called as $codec->encode( $data, null ), which is odd. To what does "null" refer? Is there a "null" format? Can the format be disabled somehow? Now it can be called as $codec->encode( $data ). This should make it more obvious that a default is used. Change-Id: I172ccfa317f2ec0550cc106c0e22217342e3494f --- M lib/includes/store/EntityContentDataCodec.php 1 file changed, 14 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/21/255921/1 diff --git a/lib/includes/store/EntityContentDataCodec.php b/lib/includes/store/EntityContentDataCodec.php index 3ea46b5..aeb5f30 100644 --- a/lib/includes/store/EntityContentDataCodec.php +++ b/lib/includes/store/EntityContentDataCodec.php @@ -57,7 +57,8 @@ * @param EntityIdParser $entityIdParser * @param Serializer $entitySerializer * @param Deserializer $entityDeserializer - * @param int $maxBlobSize The maximum size of a blob to allow during serialization/deserialization, in bytes. + * @param int $maxBlobSize The maximum size of a blob to allow during + * serialization/deserialization, in bytes. Set to 0 to disable the check. */ public function __construct( EntityIdParser $entityIdParser, @@ -139,13 +140,14 @@ * @see EntityHandler::serializeContent() * * @param Entity $entity - * @param string|null $format The desired serialization format. + * @param string|null $format The desired serialization format. One of the CONTENT_FORMAT_... + * constants or null for the default. * * @throws InvalidArgumentException If the format is not supported. * @throws MWContentSerializationException * @return string A blob representing the given Entity. */ - public function encodeEntity( Entity $entity, $format ) { + public function encodeEntity( Entity $entity, $format = null ) { try { $data = $this->entitySerializer->serialize( $entity ); $blob = $this->encodeEntityContentData( $data, $format ); @@ -167,13 +169,14 @@ * @see EntityHandler::serializeContent() * * @param EntityRedirect $redirect - * @param string|null $format The desired serialization format. + * @param string|null $format The desired serialization format. One of the CONTENT_FORMAT_... + * constants or null for the default. * * @throws InvalidArgumentException If the format is not supported. * @throws MWContentSerializationException * @return string A blob representing the given Entity. */ - public function encodeRedirect( EntityRedirect $redirect, $format ) { + public function encodeRedirect( EntityRedirect $redirect, $format = null ) { // TODO: Use proper Serializer $data = array( 'entity' => $redirect->getEntityId()->getSerialization(), @@ -225,13 +228,14 @@ * @see EntityHandler::unserializeContent() * * @param string $blob - * @param string|null $format The serialization format of $blob. + * @param string|null $format The serialization format of the data blob. One of the + * CONTENT_FORMAT_... constants or null for the default. * * @throws InvalidArgumentException If the format is not supported. * @throws MWContentSerializationException * @return Entity|null The Entity represented by $blob, or null if $blob represents a redirect. */ - public function decodeEntity( $blob, $format ) { + public function decodeEntity( $blob, $format = null ) { if ( $this->maxBlobSize > 0 && strlen( $blob ) > $this->maxBlobSize ) { throw new MWContentSerializationException( 'Blob too big for deserialization!' ); } @@ -257,14 +261,15 @@ * @see EntityHandler::unserializeContent() * * @param string $blob - * @param string|null $format The serialization format of $blob. + * @param string|null $format The serialization format of the data blob. One of the + * CONTENT_FORMAT_... constants or null for the default. * * @throws InvalidArgumentException If the format is not supported. * @throws MWContentSerializationException If the array could not be decoded. * @return EntityRedirect|null The EntityRedirect represented by $blob, * or null if $blob does not represent a redirect. */ - public function decodeRedirect( $blob, $format ) { + public function decodeRedirect( $blob, $format = null ) { $data = $this->decodeEntityContentData( $blob, $format ); $targetId = $this->extractEntityId( $data, 'redirect' ); -- To view, visit https://gerrit.wikimedia.org/r/255921 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I172ccfa317f2ec0550cc106c0e22217342e3494f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits