Skip to content

PHPLIB-480: Deprecate MapReduce options #695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Operation/MapReduce.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ public function __construct($databaseName, $collectionName, JavascriptInterface
@trigger_error('Use of Javascript with scope in "finalize" option for MapReduce is deprecated. Put all scope variables in the "scope" option of the MapReduce operation.', E_USER_DEPRECATED);
}

$this->checkOutDeprecations($out);

$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->map = $map;
Expand Down Expand Up @@ -334,6 +336,27 @@ public function execute(Server $server)
return new MapReduceResult($getIterator, $result);
}

/**
* @param string|array|object $out
* @return void
*/
private function checkOutDeprecations($out)
{
if (is_string($out)) {
return;
}

$out = (array) $out;

if (isset($out['nonAtomic']) && ! $out['nonAtomic']) {
@trigger_error('Specifying false for "out.nonAtomic" is deprecated.', E_USER_DEPRECATED);
}

if (isset($out['sharded']) && ! $out['sharded']) {
@trigger_error('Specifying false for "out.sharded" is deprecated.', E_USER_DEPRECATED);
}
}

/**
* Create the mapReduce command.
*
Expand Down