Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix: Clean cmd Exception when using MongoDB Docs

findAndRemove() find the first element and return it
This leads to an exception when trying to count it in L54 of the CleanCommand.php

Add: Return the correct number of deleted rows

Thanks to @jmikola,
We're using the Query Option "safe" to get the number of rows modified by the query.

When executing the query, it now returns the following Array:
Array
(
    [n] => 0
    [connectionId] => 113959
    [err] =>
    [ok] => 1
)

Where n is the number of deleted rows.
  • Loading branch information...
commit 0ea8017807e6b8e9a545b43d16454a1e50756613 1 parent c437696
@jmig jmig authored
Showing with 10 additions and 6 deletions.
  1. +5 −3 Document/AuthCodeManager.php
  2. +5 −3 Document/TokenManager.php
View
8 Document/AuthCodeManager.php
@@ -78,12 +78,14 @@ public function deleteAuthCode(AuthCodeInterface $authCode)
*/
public function deleteExpired()
{
- return $this
+ $result = $this
->repository
->createQueryBuilder()
- ->findAndRemove()
+ ->remove()
->field('expiresAt')->lt(time())
- ->getQuery()
+ ->getQuery(array('safe' => true))
->execute();
+
+ return $result['n'];
}
}
View
8 Document/TokenManager.php
@@ -79,12 +79,14 @@ public function deleteToken(TokenInterface $token)
*/
public function deleteExpired()
{
- return $this
+ $result = $this
->repository
->createQueryBuilder()
- ->findAndRemove()
+ ->remove()
->field('expiresAt')->lt(time())
- ->getQuery()
+ ->getQuery(array('safe' => true))
->execute();
+
+ return $result['n'];
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.