summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/dbupdater.php4
-rw-r--r--classes/digest.php6
-rw-r--r--classes/diskcache.php8
-rw-r--r--classes/dlg.php2
-rw-r--r--classes/feedparser.php4
-rw-r--r--classes/labels.php2
-rw-r--r--classes/opml.php11
-rwxr-xr-xclasses/pluginhost.php4
8 files changed, 23 insertions, 18 deletions
diff --git a/classes/dbupdater.php b/classes/dbupdater.php
index 94307aea0..3cc6e9125 100644
--- a/classes/dbupdater.php
+++ b/classes/dbupdater.php
@@ -6,7 +6,7 @@ class DbUpdater {
private $need_version;
function __construct($pdo, $db_type, $need_version) {
- $this->pdo = Db::pdo(); //$pdo;
+ $this->pdo = $pdo;
$this->db_type = $db_type;
$this->need_version = (int) $need_version;
}
@@ -24,7 +24,7 @@ class DbUpdater {
$filename = "schema/versions/".$this->db_type."/$version.sql";
if (file_exists($filename)) {
- return explode(";", preg_replace("/[\r\n]/", "", file_get_contents($filename)));
+ return explode(";", (string)preg_replace("/[\r\n]/", "", (string)file_get_contents($filename)));
} else {
user_error("DB Updater: schema file for version $version is not found.");
return false;
diff --git a/classes/digest.php b/classes/digest.php
index 5128b4186..7790424ca 100644
--- a/classes/digest.php
+++ b/classes/digest.php
@@ -5,8 +5,6 @@ class Digest
/**
* Send by mail a digest of last articles.
*
- * @param mixed $link The database connection.
- * @param integer $limit The maximum number of articles by digest.
* @return boolean Return false if digests are not enabled.
*/
static function send_headlines_digests() {
@@ -18,7 +16,7 @@ class Digest
if (DB_TYPE == "pgsql") {
$interval_qpart = "last_digest_sent < NOW() - INTERVAL '1 days'";
- } else if (DB_TYPE == "mysql") {
+ } else /* if (DB_TYPE == "mysql") */ {
$interval_qpart = "last_digest_sent < DATE_SUB(NOW(), INTERVAL 1 DAY)";
}
@@ -113,7 +111,7 @@ class Digest
if (DB_TYPE == "pgsql") {
$interval_qpart = "ttrss_entries.date_updated > NOW() - INTERVAL '$days days'";
- } else if (DB_TYPE == "mysql") {
+ } else /* if (DB_TYPE == "mysql") */ {
$interval_qpart = "ttrss_entries.date_updated > DATE_SUB(NOW(), INTERVAL $days DAY)";
}
diff --git a/classes/diskcache.php b/classes/diskcache.php
index daa171bf6..dcd7791d8 100644
--- a/classes/diskcache.php
+++ b/classes/diskcache.php
@@ -329,7 +329,9 @@ class DiskCache {
}
if ($need_saving) {
- $doc->removeChild($doc->firstChild); //remove doctype
+ if (isset($doc->firstChild))
+ $doc->removeChild($doc->firstChild); //remove doctype
+
$res = $doc->saveHTML();
}
}
@@ -384,7 +386,7 @@ class DiskCache {
$mimetype_blacklist = [ "image/svg+xml" ];
/* only serve video and images */
- if (!preg_match("/(image|audio|video)\//", $mimetype) || in_array($mimetype, $mimetype_blacklist)) {
+ if (!preg_match("/(image|audio|video)\//", (string)$mimetype) || in_array($mimetype, $mimetype_blacklist)) {
http_response_code(400);
header("Content-type: text/plain");
@@ -403,7 +405,7 @@ class DiskCache {
header("Content-type: $mimetype");
- $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT";
+ $stamp = gmdate("D, d M Y H:i:s", (int)filemtime($filename)) . " GMT";
header("Last-Modified: $stamp", true);
return readfile($filename);
diff --git a/classes/dlg.php b/classes/dlg.php
index 8873a0cb9..2fa232053 100644
--- a/classes/dlg.php
+++ b/classes/dlg.php
@@ -136,7 +136,7 @@ class Dlg extends Handler_Protected {
// and add the $min_size set above
$size = round($min_size + (($value - $min_qty) * $step));
- $key_escaped = str_replace("'", "\\'", $key);
+ $key_escaped = str_replace("'", "\\'", (string)$key);
echo "<a href=\"#\" onclick=\"Feeds.open({feed:'$key_escaped'}) \" style=\"font-size: " .
$size . "px\" title=\"$value articles tagged with " .
diff --git a/classes/feedparser.php b/classes/feedparser.php
index 9677164d3..daba271fb 100644
--- a/classes/feedparser.php
+++ b/classes/feedparser.php
@@ -53,7 +53,7 @@ class FeedParser {
$root = $xpath->query("(//atom03:feed|//atom:feed|//channel|//rdf:rdf|//rdf:RDF)");
- if ($root && $root->length > 0) {
+ if (!empty($root) && $root->length > 0) {
$root = $root->item(0);
if ($root) {
@@ -106,7 +106,7 @@ class FeedParser {
$articles = $xpath->query("//atom:entry");
- if (!$articles || $articles->length == 0)
+ if (empty($articles) || $articles->length == 0)
$articles = $xpath->query("//atom03:entry");
foreach ($articles as $article) {
diff --git a/classes/labels.php b/classes/labels.php
index 1f27ee25c..786091650 100644
--- a/classes/labels.php
+++ b/classes/labels.php
@@ -196,6 +196,8 @@ class Labels
$sth->execute([$caption, $owner_uid, $fg_color, $bg_color]);
$result = $sth->rowCount();
+ } else {
+ $result = false;
}
if (!$tr_in_progress) $pdo->commit();
diff --git a/classes/opml.php b/classes/opml.php
index 37e653a39..bc2d4d7b9 100644
--- a/classes/opml.php
+++ b/classes/opml.php
@@ -272,7 +272,7 @@ class Opml extends Handler_Protected {
$doc->preserveWhiteSpace = false;
$doc->loadXML($out);
- $xpath = new DOMXpath($doc);
+ $xpath = new DOMXPath($doc);
$outlines = $xpath->query("//outline[@title]");
// cleanup empty categories
@@ -534,10 +534,11 @@ class Opml extends Handler_Protected {
$outlines = $root_node->childNodes;
} else {
- $xpath = new DOMXpath($doc);
+ $xpath = new DOMXPath($doc);
$outlines = $xpath->query("//opml/body/outline");
$cat_id = 0;
+ $cat_title = false;
}
#$this->opml_notice("[CAT] $cat_title id: $cat_id P_id: $parent_id");
@@ -593,7 +594,7 @@ class Opml extends Handler_Protected {
}
if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
- $tmp_file = tempnam(CACHE_DIR . '/upload', 'opml');
+ $tmp_file = (string)tempnam(CACHE_DIR . '/upload', 'opml');
$result = move_uploaded_file($_FILES['opml_file']['tmp_name'],
$tmp_file);
@@ -607,13 +608,15 @@ class Opml extends Handler_Protected {
return;
}
+ $loaded = false;
+
if (is_file($tmp_file)) {
$doc = new DOMDocument();
libxml_disable_entity_loader(false);
$loaded = $doc->load($tmp_file);
libxml_disable_entity_loader(true);
unlink($tmp_file);
- } else if (!$doc) {
+ } else if (empty($doc)) {
print_error(__('Error: unable to find moved OPML file.'));
return;
}
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index e56a237fc..bcde12551 100755
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -390,13 +390,13 @@ class PluginHost {
if ($sth->fetch()) {
$sth = $this->pdo_data->prepare("UPDATE ttrss_plugin_storage SET content = ?
WHERE owner_uid= ? AND name = ?");
- $sth->execute([(string)$content, $this->owner_uid, $plugin]);
+ $sth->execute([$content, $this->owner_uid, $plugin]);
} else {
$sth = $this->pdo_data->prepare("INSERT INTO ttrss_plugin_storage
(name,owner_uid,content) VALUES
(?, ?, ?)");
- $sth->execute([$plugin, $this->owner_uid, (string)$content]);
+ $sth->execute([$plugin, $this->owner_uid, $content]);
}
$this->pdo_data->commit();