dongzun9958 2015-10-14 23:30
浏览 256
已采纳

云代码中的Parse.com php-sdk错误:'DateTime :: __ construct()需要字符串,给定数组'

I am calling this function in cloud code (it's a pretty simple search function to get around the fact that the php sdk has no "contains") :

Parse.Cloud.define("searchVenues", function(request,response) {
 var query = new Parse.Query("Venue");
 query.contains("nameLowercase",request.params.term);
 query.find({
  success: function(results){
   response.success(results);
  },error: function(){
   response.error("Cloud Venue search failed");
  }
 });
});

I am calling it in a php script as follows:

$search_result = ParseCloud::run("searchVenues", ["term" => $term]);

This function used to work! But now I am getting an error and the following stack trace:

:  Uncaught exception 'Exception' with message 'DateTime::__construct()     expects parameter 1 to be string, array given' in        C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseObject.php:683
Stack trace:
#0 C:\xampp\htdocs\bcweb\vendor\parse\php- sdk\src\Parse\ParseObject.php(683): DateTime->__construct(Array)
#1 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseObject.php(631): Parse\ParseObject->_mergeMagicFields(Array)
#2 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseObject.php(599): Parse\ParseObject->mergeFromServer(Array, true)
#3 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseClient.php(198): Parse\ParseObject->_mergeAfterFetch(Array)
#4 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseClient.php(209): Parse\ParseClient::_decode(Array)
#5 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseCloud.php(35): Parse\ParseClient::_decode(Array)
#6 C:\xampp\htdocs\bcweb\lrs\makeCrawl.php(21): Parse\ParseCloud::run('searchVenues', Array)
#7 {main}

I can't imagine what happened to break this? I have a companion function that creates the nameLowercase field on new records, as well. This was there during the happy times when the function worked correctly, so I can't imagine it's existence has anything to do with the error:

Parse.Cloud.beforeSave("Venue", function(request, response) {
 if (request.object.get("name")) {
     request.object.set("nameLowercase",request.object.get("name").toLowerCase());
 }
 response.success();
});

There are some single quotes in the strings, but they were there before too. Can anyone who has knowledge of the parse php-sdk explain what may be the problem here? Thanks!

  • 写回答

1条回答 默认 最新

  • doudieyou5209 2015-12-14 01:33
    关注

    The error was in the parse php-sdk. Updating the php-sdk to version 1.1.9 fixed this problem, and the code works as it did before.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?