function mongodb_watchdog_build_filter_query in MongoDB 6
Same name and namespace in other branches
- 7 mongodb_watchdog/mongodb_watchdog.admin.inc \mongodb_watchdog_build_filter_query()
Build a MongoDB query based on the selected filters.
MongoDB issue regarding the $in value is PHP-1051. MongoDB issue regarding numeric keys on objects is PHP-104.
Return value
array An array to build a MongoDB query.
See also
https://jira.mongodb.org/browse/PHP-1051
https://jira.mongodb.org/browse/PHP-104
File
- mongodb_watchdog/
mongodb_watchdog.admin.inc, line 439 - Settings for mongodb. Moved back to module file.
Code
function mongodb_watchdog_build_filter_query() {
if (empty($_SESSION['mongodb_watchdog_overview_filter'])) {
return array();
}
// Build query.
$where = $args = array();
$types = $_SESSION['mongodb_watchdog_overview_filter']['type'] ? $_SESSION['mongodb_watchdog_overview_filter']['type'] : NULL;
$severities = $_SESSION['mongodb_watchdog_overview_filter']['severity'] ? $_SESSION['mongodb_watchdog_overview_filter']['severity'] : NULL;
$find = array();
if ($types) {
$find['type'] = array(
'$in' => array_values($types),
);
}
if ($severities) {
// MongoDB is picky about types, ensure the severities are all integers.
$find['severity'] = array(
'$in' => array_values(array_map('intval', $severities)),
);
}
return $find;
}