+ if (isset($options["update-schema"])) {
+ Debug::log("checking for updates (" . DB_TYPE . ")...");
+
+ $updater = new DbUpdater(Db::pdo(), DB_TYPE, SCHEMA_VERSION);
+
+ if ($updater->isUpdateRequired()) {
+ Debug::log("schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION);
+ Debug::log("WARNING: please backup your database before continuing.");
+ Debug::log("Type 'yes' to continue.");
+
+ if (read_stdin() != 'yes')
+ exit;
+
+ for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
+ Debug::log("performing update up to version $i...");
+
+ $result = $updater->performUpdateTo($i, false);
+
+ Debug::log($result ? "OK!" : "FAILED!");
+
+ if (!$result) return;
+
+ }
+ } else {
+ Debug::log("update not required.");
+ }
+
+ }
+
+ if (isset($options["gen-search-idx"])) {
+ echo "Generating search index (stemming set to English)...\n";
+
+ $res = $pdo->query("SELECT COUNT(id) AS count FROM ttrss_entries WHERE tsvector_combined IS NULL");
+ $row = $res->fetch();
+ $count = $row['count'];
+
+ print "Articles to process: $count.\n";
+
+ $limit = 500;
+ $processed = 0;
+
+ $sth = $pdo->prepare("SELECT id, title, content FROM ttrss_entries WHERE
+ tsvector_combined IS NULL ORDER BY id LIMIT ?");
+ $sth->execute([$limit]);
+
+ $usth = $pdo->prepare("UPDATE ttrss_entries
+ SET tsvector_combined = to_tsvector('english', ?) WHERE id = ?");
+
+ while (true) {
+
+ while ($line = $sth->fetch()) {
+ $tsvector_combined = mb_substr(strip_tags($line["title"] . " " . $line["content"]), 0, 1000000);
+
+ $usth->execute([$tsvector_combined, $line['id']]);
+
+ $processed++;
+ }
+
+ print "Processed $processed articles...\n";
+
+ if ($processed < $limit) {
+ echo "All done.\n";
+ break;
+ }
+ }
+ }
+
+ if (isset($options["list-plugins"])) {
+ $tmppluginhost = new PluginHost();
+ $tmppluginhost->load_all($tmppluginhost::KIND_ALL, false);
+ $enabled = array_map("trim", explode(",", PLUGINS));
+
+ echo "List of all available plugins:\n";
+
+ foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
+ $about = $plugin->about();
+
+ $status = $about[3] ? "system" : "user";
+
+ if (in_array($name, $enabled)) $name .= "*";
+
+ printf("%-50s %-10s v%.2f (by %s)\n%s\n\n",
+ $name, $status, $about[0], $about[2], $about[1]);
+ }
+
+ echo "Plugins marked by * are currently enabled for all users.\n";