Unverified Commit 25c7b857 authored by Andreas Braun's avatar Andreas Braun

Merge pull request #690

parents 419ef627 a5e7454a
......@@ -13,6 +13,11 @@ name: finalize
type: :php:`MongoDB\\BSON\\Javascript <class.mongodb-bson-javascript>`
description: |
Follows the reduce method and modifies the output.
.. note::
Passing a Javascript instance with a scope is deprecated. Put all scope
variables in the ``scope`` option of the MapReduce operation.
interface: phpmethod
operation: ~
optional: true
......
......@@ -4,6 +4,11 @@ type: :php:`MongoDB\\BSON\\Javascript <mongodb-bson-javascript>`
description: |
A JavaScript function that associates or "maps" a value with a key and emits
the key and value pair.
.. note::
Passing a Javascript instance with a scope is deprecated. Put all scope
variables in the ``scope`` option of the MapReduce operation.
interface: phpmethod
operation: ~
optional: false
......@@ -14,6 +19,11 @@ type: :php:`MongoDB\\BSON\\Javascript <class.mongodb-bson-javascript>`
description: |
A JavaScript function that "reduces" to a single object all the values
associated with a particular key.
.. note::
Passing a Javascript instance with a scope is deprecated. Put all scope
variables in the ``scope`` option of the MapReduce operation.
interface: phpmethod
operation: ~
optional: false
......
......@@ -40,6 +40,8 @@ use function is_string;
use function MongoDB\create_field_path_type_map;
use function MongoDB\is_mapreduce_output_inline;
use function MongoDB\server_supports_feature;
use function trigger_error;
use const E_USER_DEPRECATED;
/**
* Operation for the mapReduce command.
......@@ -88,9 +90,15 @@ class MapReduce implements Executable
* * map (MongoDB\BSON\Javascript): A JavaScript function that associates
* or "maps" a value with a key and emits the key and value pair.
*
* Passing a Javascript instance with a scope is deprecated. Put all
* scope variables in the "scope" option of the MapReduce operation.
*
* * reduce (MongoDB\BSON\Javascript): A JavaScript function that "reduces"
* to a single object all the values associated with a particular key.
*
* Passing a Javascript instance with a scope is deprecated. Put all
* scope variables in the "scope" option of the MapReduce operation.
*
* * out (string|document): Specifies where to output the result of the
* map-reduce operation. You can either output to a collection or return
* the result inline. On a primary member of a replica set you can output
......@@ -114,6 +122,9 @@ class MapReduce implements Executable
* * finalize (MongoDB\BSON\JavascriptInterface): Follows the reduce method
* and modifies the output.
*
* Passing a Javascript instance with a scope is deprecated. Put all
* scope variables in the "scope" option of the MapReduce operation.
*
* * jsMode (boolean): Specifies whether to convert intermediate data into
* BSON format between the execution of the map and reduce functions.
*
......@@ -242,6 +253,19 @@ class MapReduce implements Executable
unset($options['writeConcern']);
}
// Handle deprecation of CodeWScope
if ($map->getScope() !== null) {
@trigger_error('Use of Javascript with scope in "$map" argument for MapReduce is deprecated. Put all scope variables in the "scope" option of the MapReduce operation.', E_USER_DEPRECATED);
}
if ($reduce->getScope() !== null) {
@trigger_error('Use of Javascript with scope in "$reduce" argument for MapReduce is deprecated. Put all scope variables in the "scope" option of the MapReduce operation.', E_USER_DEPRECATED);
}
if (isset($options['finalize']) && $options['finalize']->getScope() !== null) {
@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->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->map = $map;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment