From 6426ae559aba81b895b556ab2566458b5d3026e6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:14:00 +0300 Subject: dbupdater: unify naming --- update.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'update.php') diff --git a/update.php b/update.php index 56158ca48..cb927e49a 100755 --- a/update.php +++ b/update.php @@ -380,8 +380,8 @@ $updater = new DbUpdater(Db::pdo(), DB_TYPE, SCHEMA_VERSION); - if ($updater->isUpdateRequired()) { - Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); + if ($updater->is_update_required()) { + Debug::log("Schema update required, version " . $updater->get_schema_version() . " to " . SCHEMA_VERSION); if (DB_TYPE == "mysql") Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". @@ -400,10 +400,10 @@ Debug::log("Performing updates to version " . SCHEMA_VERSION . "..."); - for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { + for ($i = $updater->get_schema_version() + 1; $i <= SCHEMA_VERSION; $i++) { Debug::log("* Updating to version $i..."); - $result = $updater->performUpdateTo($i, false); + $result = $updater->update_to($i, false); if ($result) { Debug::log("* Completed."); -- cgit v1.2.3-54-g00ecf From 9f55454f63b11ad8d2b2e0a8264a0f0dae919f6b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:51:35 +0300 Subject: remove the rest of db.php; rename some leftover methods in feeds --- api/index.php | 1 - backend.php | 1 - classes/feeds.php | 12 ++++++------ include/db-prefs.php | 2 -- include/sessions.php | 1 - js/App.js | 3 +-- js/FeedTree.js | 2 +- opml.php | 1 - public.php | 1 - update.php | 1 - update_daemon2.php | 1 - 11 files changed, 8 insertions(+), 18 deletions(-) (limited to 'update.php') diff --git a/api/index.php b/api/index.php index 9e998df84..664e92abe 100644 --- a/api/index.php +++ b/api/index.php @@ -14,7 +14,6 @@ define('NO_SESSION_AUTOSTART', true); require_once "autoload.php"; - require_once "db.php"; require_once "db-prefs.php"; require_once "functions.php"; require_once "sessions.php"; diff --git a/backend.php b/backend.php index e72d97ca4..89b06b7eb 100644 --- a/backend.php +++ b/backend.php @@ -27,7 +27,6 @@ require_once "sessions.php"; require_once "functions.php"; require_once "config.php"; - require_once "db.php"; require_once "db-prefs.php"; $op = (string)clean($op); diff --git a/classes/feeds.php b/classes/feeds.php index 07e3aa455..2a3efdb92 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -438,7 +438,7 @@ class Feeds extends Handler_Protected { * when there's nothing to load - e.g. no stuff in fresh feed */ if ($feed == -5) { - print json_encode($this->generate_dashboard_feed()); + print json_encode($this->_generate_dashboard_feed()); return; } @@ -466,7 +466,7 @@ class Feeds extends Handler_Protected { } if ($sth && !$sth->fetch()) { - print json_encode($this->generate_error_feed(__("Feed not found."))); + print json_encode($this->_generate_error_feed(__("Feed not found."))); return; } @@ -523,7 +523,7 @@ class Feeds extends Handler_Protected { } - private function generate_dashboard_feed() { + private function _generate_dashboard_feed() { $reply = array(); $reply['headlines']['id'] = -5; @@ -565,7 +565,7 @@ class Feeds extends Handler_Protected { return $reply; } - private function generate_error_feed($error) { + private function _generate_error_feed($error) { $reply = array(); $reply['headlines']['id'] = -7; @@ -630,7 +630,7 @@ class Feeds extends Handler_Protected { print ""; } - function update_debugger() { + function updatedebugger() { header("Content-type: text/html"); $xdebug = isset($_REQUEST["xdebug"]) ? (int)$_REQUEST["xdebug"] : 1; @@ -690,7 +690,7 @@ class Feeds extends Handler_Protected {
- + diff --git a/include/db-prefs.php b/include/db-prefs.php index 91235b479..ce5753638 100644 --- a/include/db-prefs.php +++ b/include/db-prefs.php @@ -1,6 +1,4 @@ read($pref_name, $user_id, $die_on_error); } diff --git a/include/sessions.php b/include/sessions.php index 3119a4e07..4de894c95 100644 --- a/include/sessions.php +++ b/include/sessions.php @@ -2,7 +2,6 @@ // Original from http://www.daniweb.com/code/snippet43.html require_once "config.php"; - require_once "classes/db.php"; require_once "autoload.php"; require_once "errorhandler.php"; require_once "lib/gettext/gettext.inc.php"; diff --git a/js/App.js b/js/App.js index 5c2d7726c..4b2adc388 100644 --- a/js/App.js +++ b/js/App.js @@ -998,10 +998,9 @@ const App = { }; this.hotkey_actions["feed_debug_update"] = () => { if (!Feeds.activeIsCat() && parseInt(Feeds.getActive()) > 0) { - //window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + Feeds.getActive()); /* global __csrf_token */ - App.postOpenWindow("backend.php", {op: "feeds", method: "update_debugger", + App.postOpenWindow("backend.php", {op: "feeds", method: "updatedebugger", feed_id: Feeds.getActive(), csrf_token: __csrf_token}); } else { diff --git a/js/FeedTree.js b/js/FeedTree.js index 26c1c916c..694cf8332 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -102,7 +102,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co label: __("Debug feed"), onClick: function() { /* global __csrf_token */ - App.postOpenWindow("backend.php", {op: "feeds", method: "update_debugger", + App.postOpenWindow("backend.php", {op: "feeds", method: "updatedebugger", feed_id: this.getParent().row_id, csrf_token: __csrf_token}); }})); } diff --git a/opml.php b/opml.php index 9b7809e0e..6f13a6f3c 100644 --- a/opml.php +++ b/opml.php @@ -7,7 +7,6 @@ require_once "sessions.php"; require_once "sanity_check.php"; require_once "config.php"; - require_once "db.php"; require_once "db-prefs.php"; if (!init_plugins()) return; diff --git a/public.php b/public.php index dcfc4056e..59b5a499c 100644 --- a/public.php +++ b/public.php @@ -7,7 +7,6 @@ require_once "functions.php"; require_once "sanity_check.php"; require_once "config.php"; - require_once "db.php"; require_once "db-prefs.php"; startup_gettext(); diff --git a/update.php b/update.php index cb927e49a..1f79dccf0 100755 --- a/update.php +++ b/update.php @@ -11,7 +11,6 @@ require_once "functions.php"; require_once "config.php"; require_once "sanity_check.php"; - require_once "db.php"; require_once "db-prefs.php"; function make_stampfile($filename) { diff --git a/update_daemon2.php b/update_daemon2.php index 61cc85617..2a016df48 100755 --- a/update_daemon2.php +++ b/update_daemon2.php @@ -19,7 +19,6 @@ define_default('SPAWN_INTERVAL', DAEMON_SLEEP_INTERVAL); // seconds require_once "sanity_check.php"; - require_once "db.php"; require_once "db-prefs.php"; if (!function_exists('pcntl_fork')) { -- cgit v1.2.3-54-g00ecf From be4e7b13403666fc477d4b563ea8c075d0fd2022 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 14:41:09 +0300 Subject: fix several issues reported by phpstan --- api/index.php | 4 ++-- classes/api.php | 2 +- classes/digest.php | 9 --------- classes/feeds.php | 6 ------ classes/handler/public.php | 10 +++++----- classes/pluginhost.php | 3 ++- classes/pref/prefs.php | 7 ------- include/functions.php | 8 ++++---- include/sanity_check.php | 6 +++--- include/sanity_config.php | 4 ++-- include/sessions.php | 8 ++++---- phpstan.neon | 4 +++- plugins/af_fsckportal/init.php | 5 +---- plugins/af_redditimgur/init.php | 5 ++++- update.php | 4 ++-- utils/regen_config_checks.sh | 4 ++-- 16 files changed, 35 insertions(+), 54 deletions(-) (limited to 'update.php') diff --git a/api/index.php b/api/index.php index eb79422f9..1b713d561 100644 --- a/api/index.php +++ b/api/index.php @@ -18,8 +18,8 @@ require_once "functions.php"; require_once "sessions.php"; - ini_set('session.use_cookies', 0); - ini_set("session.gc_maxlifetime", 86400); + ini_set('session.use_cookies', "0"); + ini_set("session.gc_maxlifetime", "86400"); ob_start(); diff --git a/classes/api.php b/classes/api.php index 03eea1927..5677cb908 100755 --- a/classes/api.php +++ b/classes/api.php @@ -292,7 +292,7 @@ class API extends Handler { $sanitize_content = !isset($_REQUEST["sanitize"]) || self::_param_to_bool($_REQUEST["sanitize"]); - if ($article_ids) { + if (count($article_ids) > 0) { $article_qmarks = arr_qmarks($article_ids); diff --git a/classes/digest.php b/classes/digest.php index 77eb92c54..e0c23d705 100644 --- a/classes/digest.php +++ b/classes/digest.php @@ -1,12 +1,6 @@ addBlock('enclosure'); } } else { - $tpl->setVariable('ARTICLE_ENCLOSURE_URL', null, true); - $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', null, true); - $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', null, true); + $tpl->setVariable('ARTICLE_ENCLOSURE_URL', "", true); + $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', "", true); + $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', "", true); } list ($og_image, $og_stream) = Article::_get_image($enclosures, $line['content'], $feed_site_url); @@ -207,8 +207,8 @@ class Handler_Public extends Handler { $article['content'] = Sanitizer::sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]); $article['updated'] = date('c', strtotime($line["updated"])); - if ($line['note']) $article['note'] = $line['note']; - if ($article['author']) $article['author'] = $line['author']; + if (!empty($line['note'])) $article['note'] = $line['note']; + if (!empty($line['author'])) $article['author'] = $line['author']; if (count($line["tags"]) > 0) { $article['tags'] = array(); diff --git a/classes/pluginhost.php b/classes/pluginhost.php index a05938111..5121c8491 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -108,8 +108,9 @@ class PluginHost { return false; } + // needed for compatibility with API 2 (?) function get_dbh() { - return Db::get(); + return false; } function get_pdo(): PDO { diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index a26281fee..adb249dac 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -311,13 +311,6 @@ class Pref_Prefs extends Handler_Protected { - -
- - -
- -