Permalink
Browse files

Support patching issues with only updated fields

Fixes #23396
  • Loading branch information...
vboctor committed Oct 14, 2017
1 parent f57697d commit d33a5dc76c688bc1ea870397c1b1fbc6f0c166ed
Showing with 8 additions and 2 deletions.
  1. +8 −2 api/rest/restcore/issues_rest.php
@@ -203,14 +203,20 @@ function rest_issue_note_delete( \Slim\Http\Request $p_request, \Slim\Http\Respo
* @return \Slim\Http\Response The augmented response.
*/
function rest_issue_update( \Slim\Http\Request $p_request, \Slim\Http\Response $p_response, array $p_args ) {
$t_issue = (object)$p_request->getParsedBody();
$t_issue_id = isset( $p_args['id'] ) ? $p_args['id'] : $p_request->getParam( 'id' );
if( is_blank( $t_issue_id ) ) {
$t_message = "Mandatory field 'id' is missing.";
return $p_response->withStatus( HTTP_STATUS_BAD_REQUEST, $t_message );
}
# Load the latest issue state from the db to merge with the provided fields to patch
$t_original_issue = mc_issue_get( /* username */ '', /* password */ '', $t_issue_id );
# Construct full issue from issue from db + patched info
$t_issue_patch = $p_request->getParsedBody();
$t_issue = (object)array_merge( $t_original_issue, $t_issue_patch );
# Trigger the issue update
$t_result = mc_issue_update( /* username */ '', /* password */ '', $t_issue_id, $t_issue );
if( ApiObjectFactory::isFault( $t_result ) ) {
return $p_response->withStatus( $t_result->status_code, $t_result->fault_string );

0 comments on commit d33a5dc

Please sign in to comment.