From abf3adde012f9e1f6130ca247abb9294b67f0eb9 Mon Sep 17 00:00:00 2001
From: vincent-peugnet
Date: Sun, 20 Oct 2024 14:51:20 +0200
Subject: [PATCH] config param to disable URL checker see #322
---
app/class/Config.php | 11 +++++++++++
app/class/Controllerhome.php | 3 ++-
app/class/Controllerpage.php | 6 ++++--
app/view/templates/admin.php | 11 +++++++++++
app/view/templates/home.php | 3 ++-
5 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/app/class/Config.php b/app/class/Config.php
index ce71abb9..dde7f036 100644
--- a/app/class/Config.php
+++ b/app/class/Config.php
@@ -28,6 +28,7 @@ abstract class Config
protected static bool $externallinkblank = true;
protected static bool $internallinkblank = false;
protected static bool $urllinker = true;
+ protected static bool $urlchecker = true;
protected static bool $deletelinktocache = true;
protected static int $defaultprivacy = 0;
protected static string $homepage = 'default';
@@ -297,6 +298,11 @@ public static function urllinker(): bool
return self::$urllinker;
}
+ public static function urlchecker(): bool
+ {
+ return self::$urlchecker;
+ }
+
public static function deletelinktocache(): bool
{
return self::$deletelinktocache;
@@ -536,6 +542,11 @@ public static function seturllinker($urllinker)
self::$urllinker = boolval($urllinker);
}
+ public static function seturlchecker($urlchecker)
+ {
+ self::$urlchecker = boolval($urlchecker);
+ }
+
public static function setdeletelinktocache($deletelinktocache)
{
self::$deletelinktocache = boolval($deletelinktocache);
diff --git a/app/class/Controllerhome.php b/app/class/Controllerhome.php
index c0513f1e..20ae34d6 100644
--- a/app/class/Controllerhome.php
+++ b/app/class/Controllerhome.php
@@ -94,6 +94,7 @@ public function desktop()
$vars['deepsearch'] = $deepsearch['regex'];
$vars['searchopt'] = $deepsearch['searchopt'];
$vars['display'] = $display;
+ $vars['urlchecker'] = Config::urlchecker();
if ($display === 'graph') {
$vars['layout'] = $_GET['layout'] ?? 'cose-bilkent';
@@ -327,7 +328,7 @@ public function multiedit()
public function multirender(): void
{
$pagelist = $_POST['pagesid'] ?? [];
- $checkurl = boolval($_POST['checkurl']);
+ $checkurl = Config::urlchecker() && boolval($_POST['checkurl']);
$total = count($pagelist);
$pagelist = $this->pagemanager->pagelistbyid($pagelist);
$count = 0;
diff --git a/app/class/Controllerpage.php b/app/class/Controllerpage.php
index 7a889f6e..c48bc67c 100644
--- a/app/class/Controllerpage.php
+++ b/app/class/Controllerpage.php
@@ -75,7 +75,8 @@ public function render(string $page): void
if ($this->importpage() && $this->user->iseditor()) {
try {
- $this->page = $this->pagemanager->renderpage($this->page, $this->router, new Serviceurlchecker(8));
+ $urlchecker = Config::urlchecker() ? new Serviceurlchecker(8) : null;
+ $this->page = $this->pagemanager->renderpage($this->page, $this->router, $urlchecker);
} catch (RuntimeException $e) {
Logger::errorex($e);
}
@@ -186,7 +187,8 @@ public function read(string $page): void
$oldlinkto = $this->page->linkto();
}
try {
- $this->page = $this->pagemanager->renderpage($this->page, $this->router, new Serviceurlchecker(3));
+ $urlchecker = Config::urlchecker() ? new Serviceurlchecker(8) : null;
+ $this->page = $this->pagemanager->renderpage($this->page, $this->router, $urlchecker);
} catch (RuntimeException $e) {
Logger::errorex($e);
}
diff --git a/app/view/templates/admin.php b/app/view/templates/admin.php
index 3affe764..254f7a29 100644
--- a/app/view/templates/admin.php
+++ b/app/view/templates/admin.php
@@ -287,6 +287,17 @@
form="admin">
+
+
+
+ form="admin">
+
+
+
+ URL checker try to reach URLs online to see if they are alives.
+ This may cause longer render time if recently activated.
+
+
Markdown Parser
diff --git a/app/view/templates/home.php b/app/view/templates/home.php
index db26fa35..140d2251 100644
--- a/app/view/templates/home.php
+++ b/app/view/templates/home.php
@@ -32,7 +32,8 @@
'colors' => $colors,
'queryaddress' => $queryaddress,
'matchedbookmarks' => $matchedbookmarks,
- 'editablebookmarks' => $editablebookmarks
+ 'editablebookmarks' => $editablebookmarks,
+ 'urlchecker' => $urlchecker,
]);
?>