Lucas_Werkmeister_WMDE added a comment.

  This hack makes the `PATCH 
/entities/items/{item_id}/statements/{statement_id}` test work again:
  
    diff --git 
a/repo/rest-api/src/RouteHandlers/PatchItemStatementRouteHandler.php 
b/repo/rest-api/src/RouteHandlers/PatchItemStatementRouteHandler.php
    index 76cfe52a94..615717b413 100644
    --- a/repo/rest-api/src/RouteHandlers/PatchItemStatementRouteHandler.php
    +++ b/repo/rest-api/src/RouteHandlers/PatchItemStatementRouteHandler.php
    @@ -4,6 +4,7 @@
     
     use MediaWiki\MediaWikiServices;
     use MediaWiki\Rest\Handler;
    +use MediaWiki\Rest\LocalizedHttpException;
     use MediaWiki\Rest\RequestInterface;
     use MediaWiki\Rest\Response;
     use MediaWiki\Rest\ResponseInterface;
    @@ -22,6 +23,7 @@
     use Wikibase\Repo\RestApi\RouteHandlers\Middleware\MiddlewareHandler;
     use 
Wikibase\Repo\RestApi\RouteHandlers\Middleware\UserAgentCheckMiddleware;
     use Wikibase\Repo\RestApi\WbRestApi;
    +use Wikimedia\Message\MessageValue;
     use Wikimedia\ParamValidator\ParamValidator;
     
     /**
    @@ -137,6 +139,23 @@ public function getParamSettings(): array {
                ];
        }
     
    +   public function parseBodyData( RequestInterface $request ): ?array {
    +           if ( $request->getBodyType() === 
ContentTypeCheckMiddleware::TYPE_JSON_PATCH ) {
    +                   // copy+paste from the standard JSON case in the parent 
method
    +                   $jsonStream = $request->getBody();
    +                   $parsedBody = json_decode( "$jsonStream", true );
    +                   if ( !is_array( $parsedBody ) ) {
    +                           throw new LocalizedHttpException(
    +                           // Fixme: missing parameter
    +                                   new MessageValue( 
'rest-json-body-parse-error', [ "" ] ),
    +                                   400
    +                           );
    +                   }
    +                   return $parsedBody;
    +           }
    +           return parent::parseBodyData( $request );
    +   }
    +
        /**
         * @inheritDoc
         */
  
  But I’m not sure if it was intended in T358557 
<https://phabricator.wikimedia.org/T358557> that all handlers should now have 
to override `parseBodyData()` if they want to support content types other than 
`application/x-www-form-urlencoded`, `multipart/form-data` and 
`application/json`.
  
  Also, this doesn’t seem to be a test problem, it’ll actually break JSON PATCH 
requests in production when this rolls out with the train. So this should 
probably be a train blocker?

TASK DETAIL
  https://phabricator.wikimedia.org/T359149

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Lucas_Werkmeister_WMDE
Cc: Lucas_Werkmeister_WMDE, Aklapper, Jakob_WMDE, Danny_Benjafield_WMDE, 
Isabelladantes1983, Themindcoder, Adamm71, Jersione, Hellket777, LisafBia6531, 
Astuthiodit_1, 786, Biggs657, karapayneWMDE, Invadibot, maantietaja, Juan90264, 
Alter-paule, Beast1978, ItamarWMDE, Un1tY, Akuckartz, apaskulin, Hook696, 
Kent7301, joker88john, CucyNoiD, Nandana, Gaboe420, Giuliamocci, Cpaulf30, 
Lahi, Gq86, Af420, Xinbenlv, Bsandipan, GoranSMilovanovic, QZanden, KimKelting, 
LawExplorer, Lewizho99, Maathavan, _jensen, rosalieper, Neuronton, Scott_WUaS, 
Wikidata-bugs, aude, Jdforrester-WMF, Mbch331
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to