]> git.wh0rd.org - tt-rss.git/blobdiff - classes/logger/sql.php
OPML: use PDO; minor fixes
[tt-rss.git] / classes / logger / sql.php
index b0e0b0db5e1f05eac78112931c14715ad5049052..120584014ce3be33e28eb3adc647528e55b89c7e 100644 (file)
@@ -2,30 +2,28 @@
 class Logger_SQL {
 
        function log_error($errno, $errstr, $file, $line, $context) {
+               
+               $pdo = Db::pdo();
+               
+               if ($pdo && get_schema_version() > 117) {
 
-               if ($errno == E_NOTICE) return false;
+                       try {
+                               $pdo->rollBack();
+                       } catch (Exception $e) {
+                               //
+                       }
 
-               if (Db::get()) {
+                       $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null;
 
-                       $errno = Db::get()->escape_string($errno);
-                       $errstr = Db::get()->escape_string($errstr);
-                       $file = Db::get()->escape_string($file);
-                       $line = Db::get()->escape_string($line);
-                       $context = ''; // backtrace is a lot of data which is not really critical to store
-                       //$context = db_escape_string($this->link, serialize($context));
-
-                       $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL";
-
-                       $result = Db::get()->query(
-                               "INSERT INTO ttrss_error_log
+                       $sth = $pdo->prepare("INSERT INTO ttrss_error_log
                                (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES
-                               ($errno, '$errstr', '$file', '$line', '$context', $owner_uid, NOW())");
+                               (?, ?, ?, ?, ?, ?, NOW())");
+                       $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]);
 
-                       return Db::get()->affected_rows($result) != 0;
+                       return $sth->rowCount();
                }
 
                return false;
        }
 
-}
-?>
+}
\ No newline at end of file