The $where operator applies to top-level elements only, however in 2.4 the specific implementation allowed usage under a sub-field within the $elemMatch operator as an edge case. This behavior was unintentional. With the introduction of the new query engine in 2.6 the $where usage should have been removed in the $elemMatch operator. The special case of $where as the first condition was missed.
As the behavior has changed from 2.4.9 some queries relying on the $where operator in $elemMatch may no longer work and return an error instead.
In most cases, a rewrite of the query and replacement of $where clauses in the $elemMatch document should be possible.
Consistent rejection of the $where operator anywhere in $elemMatch queries, with a clear error message.
Version 2.6.0 was affected by this bug.
The patch is included in the 2.6.1 production release.