|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-05-09 08:29 UTC] xcl_rockman at qq dot com
Description:
------------
addtask cant pass the reference parameter of the context
can't return context
Test script:
---------------
$client = new GearmanClient();
$client->addServer();
# set a function to be called when the work is complete
$client->setCompleteCallback("reverse_complete");
# Add some tasks for a placeholder of where to put the results
$results = array();
$client->addTask("reverse", "Hello World!", &$results, "t1");
$client->addTask("reverse", "!dlroW olleH", &$results, "t2");
$client->runTasks();
# The results should now be filled in from the callbacks
foreach ($results as $id => $result)
echo $id . ": " . $result['handle'] . ", " . $result['data'] . "\n";
function reverse_complete($task, $results)
{
$results[$task->unique()] = array("handle"=>$task->jobHandle(), "data"=>$task->data());
}
Expected result:
----------------
t2: H.foo:21, Hello World!
t1: H:foo:22, !dlroW olleH
Actual result:
--------------
empty
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
PHP 5.4 changed how references can be passed in a function. So this is not a Gearman issue. Try the following //remove reference '&' from $results $client->addTask("reverse", "Hello World!", $results, "t1"); //add reference '&' for $results function reverse_complete($task, $results)