Skip to content

Commit a500a3b

Browse files
committed
Fix update method
1 parent ef58a21 commit a500a3b

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/Mvc/Controller/CronJobFunctionController.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ public function update($field, $value, $data)
181181
}
182182

183183
// Update function with new content hash
184-
$data['content_hash'] = $newContentHash;
184+
$function->content_hash = $newContentHash;
185+
$function->modified_by = $this->api->user ? $this->api->user->id : null;
186+
$function->date_modified = time();
187+
$function->save([], $this->api->user ? $this->api->user->id : null);
185188

186189
// Create new version
187190
$this->createVersion($functionId, $newContentHash, $nextVersion, 'Code updated', $this->api->user ? $this->api->user->id : null);
@@ -193,10 +196,17 @@ public function update($field, $value, $data)
193196
}
194197
}
195198

196-
// Update function record (if any other fields changed)
197-
if (!empty($data)) {
198-
parent::update($field, $value, $data);
199-
}
199+
// Build response with updated function data
200+
$responseData = $function->getAllParams($this->dateformat);
201+
202+
// Call hook_response_data to add decompressed function body and version info
203+
$this->hook_response_data('update', $function, $responseData);
204+
205+
// Set response
206+
$this->response['data'] = [$responseData];
207+
208+
// Output response as JSON
209+
echo json_encode($this->response);
200210
}
201211

202212
/**

0 commit comments

Comments
 (0)