Commit 3765af4e authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #14986 from owncloud/fixmapperbackw

Fix backwards compatibility for mapper execute method
parents 73874ca2 f77ae37f
......@@ -26,7 +26,8 @@
namespace OCP\AppFramework\Db;
use \OCP\IDBConnection;
use OCP\IDBConnection;
use OCP\IDb;
/**
......@@ -193,7 +194,11 @@ abstract class Mapper {
* @return \PDOStatement the database query result
*/
protected function execute($sql, array $params=[], $limit=null, $offset=null){
$query = $this->db->prepare($sql, $limit, $offset);
if ($this->db instanceof IDb) {
$query = $this->db->prepareQuery($sql, $limit, $offset);
} else {
$query = $this->db->prepare($sql, $limit, $offset);
}
$index = 1; // bindParam is 1 indexed
foreach($params as $param) {
......@@ -217,7 +222,16 @@ abstract class Mapper {
$index++;
}
$query->execute();
$result = $query->execute();
// this is only for backwards compatibility reasons and can be removed
// in owncloud 10. IDb returns a StatementWrapper from execute, PDO,
// Doctrine and IDbConnection don't so this needs to be done in order
// to stay backwards compatible for the things that rely on the
// StatementWrapper being returned
if ($result instanceof \OC_DB_StatementWrapper) {
return $result;
}
return $query;
}
......
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