Skip to content

Commit 8c5b72f

Browse files
committed
fix alias saving
1 parent 9c149d7 commit 8c5b72f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

admin/aliases.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @author Andreas Gohr <gohr@cosmocode.de>
77
*/
88

9+
use dokuwiki\ErrorHandler;
910
use dokuwiki\Utf8\PhpString;
1011

1112
/**
@@ -65,7 +66,8 @@ public function getMenuText($language)
6566
*/
6667
public function handle()
6768
{
68-
if (!is_array($_REQUEST['d']) || !checkSecurityToken()) return;
69+
global $INPUT;
70+
if (!$INPUT->has('d') || !checkSecurityToken()) return;
6971

7072
$sqlite = $this->dthlp->_getDB();
7173
if (!$sqlite) return;
@@ -74,7 +76,7 @@ public function handle()
7476
try {
7577
$sqlite->exec('DELETE FROM aliases');
7678

77-
foreach ($_REQUEST['d'] as $row) {
79+
foreach ($INPUT->arr('d') as $row) {
7880
$row = array_map('trim', $row);
7981
$row['name'] = PHPString::strtolower($row['name']);
8082
$row['name'] = rtrim($row['name'], 's');
@@ -85,13 +87,12 @@ public function handle()
8587
$arr = array_unique($arr);
8688
$row['enum'] = implode(', ', $arr);
8789

88-
$sqlite->exec(
89-
'INSERT INTO aliases (name, type, prefix, postfix, enum) VALUES (?,?,?,?,?)',
90-
$row
91-
);
90+
$sqlite->saveRecord('aliases', $row);
9291
}
9392
$sqlite->getPdo()->commit();
9493
} catch (\Exception $exception) {
94+
msg(hsc($exception->getMessage()), -1);
95+
ErrorHandler::logException($exception);
9596
$sqlite->getPdo()->rollBack();
9697
}
9798
}

0 commit comments

Comments
 (0)