Repository navigation
Closed
Labels
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server and the Parse PHP SDK.
Issue Description
I create a cloud function that create users and i called it using PHP, not it's creating users fine and all good in Parse
but the response is not there, all i get is error
A PHP Error was encountered
Severity: Warning
Message: Undefined array key "result"
Filename: Parse/ParseCloud.php
Line Number: 40
Steps to reproduce
Create a cloud function using this code
Parse.Cloud.define("createNewUser", async (request) => {
var User = Parse.Object.extend("User");
var us = new User();
us.set("username", request.params.username);
us.set("name", request.params.name);
us.set("email", request.params.email);
us.set("password", request.params.password);
await us.save()
.then((user) => {
// Execute any logic that should take place after the object is saved.
return ('New object created with objectId: ' + user.id);
}, (error) => {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
return ('Failed to create new object, with error code: ' + error.message);
});
});
// To Run the code in PHP
$rating = ParseCloud::run("newUser", $userData);
Actual Outcome
Error as explained before
Expected Outcome
fail or success message
Environment
Parse PHP SDK
- SDK version:
2.3.2 - PHP version:
8.2.0
Server
- Parse Server version:
6.2.1 - Operating system:
Ubuntu 20 - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
Digital Ocean
Database
- System (MongoDB or Postgres):
MongoDb - Database version:
6 - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
Local
Logs
A PHP Error was encountered
Severity: Warning
Message: Undefined array key "result"
Filename: Parse/ParseCloud.php
Line Number: 40
Backtrace:
File: /Applications/MAMP/htdocs/scr/application/third_party/parse/vendor/parse/php-sdk/src/Parse/ParseCloud.php
Line: 40
Function: _error_handler
Activity
parse-github-assistant commentedon Aug 10, 2023
Thanks for opening this issue!
YousefAlsbaihi commentedon Aug 10, 2023
It's resolved,
it turned out that i have to return the whole save() function, so the cloud code would be:
i'm not sure if this is secure or not, but managed to get objectId and Error messages if there is any,
however i was confused of the example here
this example return a string, how Parse Cloud Php would get result from that ?
i haven't tested that example but just observation.
if there is a different approach, i would appreciate it please let me know.
mtrezza commentedon Aug 15, 2023
A Cloud Function can return any type, if I'm not mistaken, it doesn't even have to be a JSON. It then depends on your implementation client side to properly handle the response. So the Parse PHP SDK should not expect a certain type for a Cloud Function response.
mtrezza commentedon Aug 15, 2023
I'm closing this as it does not seem to be a Parse PHP SDK issue.