You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Operation/MapReduce.php
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,8 @@
40
40
usefunctionMongoDB\create_field_path_type_map;
41
41
usefunctionMongoDB\is_mapreduce_output_inline;
42
42
usefunctionMongoDB\server_supports_feature;
43
+
usefunctiontrigger_error;
44
+
useconstE_USER_DEPRECATED;
43
45
44
46
/**
45
47
* Operation for the mapReduce command.
@@ -88,9 +90,15 @@ class MapReduce implements Executable
88
90
* * map (MongoDB\BSON\Javascript): A JavaScript function that associates
89
91
* or "maps" a value with a key and emits the key and value pair.
90
92
*
93
+
* Passing a Javascript instance with a scope is deprecated. Put all
94
+
* scope variables in the "scope" option of the MapReduce operation.
95
+
*
91
96
* * reduce (MongoDB\BSON\Javascript): A JavaScript function that "reduces"
92
97
* to a single object all the values associated with a particular key.
93
98
*
99
+
* Passing a Javascript instance with a scope is deprecated. Put all
100
+
* scope variables in the "scope" option of the MapReduce operation.
101
+
*
94
102
* * out (string|document): Specifies where to output the result of the
95
103
* map-reduce operation. You can either output to a collection or return
96
104
* the result inline. On a primary member of a replica set you can output
@@ -114,6 +122,9 @@ class MapReduce implements Executable
114
122
* * finalize (MongoDB\BSON\JavascriptInterface): Follows the reduce method
115
123
* and modifies the output.
116
124
*
125
+
* Passing a Javascript instance with a scope is deprecated. Put all
126
+
* scope variables in the "scope" option of the MapReduce operation.
127
+
*
117
128
* * jsMode (boolean): Specifies whether to convert intermediate data into
118
129
* BSON format between the execution of the map and reduce functions.
119
130
*
@@ -242,6 +253,19 @@ public function __construct($databaseName, $collectionName, JavascriptInterface
242
253
unset($options['writeConcern']);
243
254
}
244
255
256
+
// Handle deprecation of CodeWScope
257
+
if ($map->getScope() !== null) {
258
+
@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);
259
+
}
260
+
261
+
if ($reduce->getScope() !== null) {
262
+
@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);
263
+
}
264
+
265
+
if (isset($options['finalize']) && $options['finalize']->getScope() !== null) {
266
+
@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);
0 commit comments