aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/FrontpageAction.php1
-rw-r--r--bridges/ArsTechnicaBridge.php9
-rw-r--r--bridges/VkBridge.php2
-rw-r--r--caches/FileCache.php2
-rw-r--r--index.php6
-rw-r--r--lib/Configuration.php15
6 files changed, 18 insertions, 17 deletions
diff --git a/actions/FrontpageAction.php b/actions/FrontpageAction.php
index 64281b1e..ad48927d 100644
--- a/actions/FrontpageAction.php
+++ b/actions/FrontpageAction.php
@@ -31,6 +31,7 @@ final class FrontpageAction implements ActionInterface
}
}
+ // todo: cache this renderered template
return render(__DIR__ . '/../templates/frontpage.html.php', [
'messages' => $messages,
'admin_email' => Configuration::getConfig('admin', 'email'),
diff --git a/bridges/ArsTechnicaBridge.php b/bridges/ArsTechnicaBridge.php
index 5b3283b5..613c1c58 100644
--- a/bridges/ArsTechnicaBridge.php
+++ b/bridges/ArsTechnicaBridge.php
@@ -37,7 +37,14 @@ class ArsTechnicaBridge extends FeedExpander
{
$item_html = getSimpleHTMLDOMCached($item['uri'] . '&amp');
$item_html = defaultLinkTo($item_html, self::URI);
- $item['content'] = $item_html->find('.amp-wp-article-content', 0);
+
+ $item_content = $item_html->find('.article-content.post-page', 0);
+ if (!$item_content) {
+ // The dom selector probably broke. Let's just return the item as-is
+ return $item;
+ }
+
+ $item['content'] = $item_content;
// remove various ars advertising
$item['content']->find('#social-left', 0)->remove();
diff --git a/bridges/VkBridge.php b/bridges/VkBridge.php
index 503bc4d0..980b4154 100644
--- a/bridges/VkBridge.php
+++ b/bridges/VkBridge.php
@@ -523,7 +523,7 @@ class VkBridge extends BridgeAbstract
}
if (!preg_match('#^https?://vk.com/#', $uri)) {
- returnServerError('Unexpected redirect location');
+ returnServerError('Unexpected redirect location: ' . $uri);
}
$redirects++;
diff --git a/caches/FileCache.php b/caches/FileCache.php
index 2f4b3ad5..09d12791 100644
--- a/caches/FileCache.php
+++ b/caches/FileCache.php
@@ -49,8 +49,8 @@ class FileCache implements CacheInterface
{
$item = [
'key' => $key,
- 'value' => $value,
'expiration' => $ttl === null ? 0 : time() + $ttl,
+ 'value' => $value,
];
$cacheFile = $this->createCacheFile($key);
$bytes = file_put_contents($cacheFile, serialize($item), LOCK_EX);
diff --git a/index.php b/index.php
index 123f6ecd..14713e06 100644
--- a/index.php
+++ b/index.php
@@ -6,7 +6,11 @@ if (version_compare(\PHP_VERSION, '7.4.0') === -1) {
require_once __DIR__ . '/lib/bootstrap.php';
-Configuration::verifyInstallation();
+$errors = Configuration::checkInstallation();
+if ($errors) {
+ die('<pre>' . implode("\n", $errors) . '</pre>');
+}
+
$customConfig = [];
if (file_exists(__DIR__ . '/config.ini.php')) {
$customConfig = parse_ini_file(__DIR__ . '/config.ini.php', true, INI_SCANNER_TYPED);
diff --git a/lib/Configuration.php b/lib/Configuration.php
index d699178f..ac7d29bf 100644
--- a/lib/Configuration.php
+++ b/lib/Configuration.php
@@ -15,15 +15,7 @@ final class Configuration
{
}
- /**
- * Verifies the current installation of RSS-Bridge and PHP.
- *
- * Returns an error message and aborts execution if the installation does
- * not satisfy the requirements of RSS-Bridge.
- *
- * @return void
- */
- public static function verifyInstallation()
+ public static function checkInstallation(): array
{
$errors = [];
@@ -57,10 +49,7 @@ final class Configuration
if (!extension_loaded('json')) {
$errors[] = 'json extension not loaded';
}
-
- if ($errors) {
- throw new \Exception(sprintf('Configuration error: %s', implode(', ', $errors)));
- }
+ return $errors;
}
public static function loadConfiguration(array $customConfig = [], array $env = [])