@@ -72,8 +72,7 @@ static public function prepare( $query , $limit = null, $offset = null, $isManip
7272 throw new \OC \DatabaseException ($ e ->getMessage ());
7373 }
7474 // differentiate between query and manipulation
75- $ result = new OC_DB_StatementWrapper ($ result , $ isManipulation );
76- return $ result ;
75+ return new OC_DB_StatementWrapper ($ result , $ isManipulation );
7776 }
7877
7978 /**
@@ -84,22 +83,26 @@ static public function prepare( $query , $limit = null, $offset = null, $isManip
8483 * @return bool
8584 */
8685 static public function isManipulation ( $ sql ) {
86+ $ sql = trim ($ sql );
8787 $ selectOccurrence = stripos ($ sql , 'SELECT ' );
88- if ($ selectOccurrence !== false && $ selectOccurrence < 10 ) {
88+ if ($ selectOccurrence === 0 ) {
8989 return false ;
9090 }
9191 $ insertOccurrence = stripos ($ sql , 'INSERT ' );
92- if ($ insertOccurrence !== false && $ insertOccurrence < 10 ) {
92+ if ($ insertOccurrence === 0 ) {
9393 return true ;
9494 }
9595 $ updateOccurrence = stripos ($ sql , 'UPDATE ' );
96- if ($ updateOccurrence !== false && $ updateOccurrence < 10 ) {
96+ if ($ updateOccurrence === 0 ) {
9797 return true ;
9898 }
9999 $ deleteOccurrence = stripos ($ sql , 'DELETE ' );
100- if ($ deleteOccurrence !== false && $ deleteOccurrence < 10 ) {
100+ if ($ deleteOccurrence === 0 ) {
101101 return true ;
102102 }
103+
104+ \OC ::$ server ->getLogger ()->logException (new \Exception ('Can not detect if query is manipulating: ' . $ sql ));
105+
103106 return false ;
104107 }
105108
0 commit comments