-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
64 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
|
||
class QuerySaver | ||
{ | ||
|
||
protected $db; | ||
protected $upstream; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?php | ||
|
||
use dokuwiki\Extension\AdminPlugin; | ||
use dokuwiki\Form\Form; | ||
use dokuwiki\Form\InputElement; | ||
use dokuwiki\plugin\sqlite\QuerySaver; | ||
|
@@ -12,13 +13,13 @@ | |
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Andreas Gohr <[email protected]> | ||
*/ | ||
class admin_plugin_sqlite extends DokuWiki_Admin_Plugin | ||
class admin_plugin_sqlite extends AdminPlugin | ||
{ | ||
/** @var SQLiteDB */ | ||
protected $db = null; | ||
protected $db; | ||
|
||
/** @var QuerySaver */ | ||
protected $querySaver = null; | ||
protected $querySaver; | ||
|
||
/** @inheritdoc */ | ||
public function getMenuSort() | ||
|
@@ -148,12 +149,7 @@ public function getTOC() | |
$dbfiles = glob($conf['metadir'] . '/*.sqlite3'); | ||
if (is_array($dbfiles)) foreach ($dbfiles as $file) { | ||
$db = basename($file, '.sqlite3'); | ||
$toc[] = array( | ||
'link' => wl($ID, array('do' => 'admin', 'page' => 'sqlite', 'db' => $db, 'sectok' => getSecurityToken())), | ||
'title' => $db, | ||
'level' => 2, | ||
'type' => 'ul', | ||
); | ||
$toc[] = ['link' => wl($ID, ['do' => 'admin', 'page' => 'sqlite', 'db' => $db, 'sectok' => getSecurityToken()]), 'title' => $db, 'level' => 2, 'type' => 'ul']; | ||
} | ||
|
||
return $toc; | ||
|
@@ -238,7 +234,8 @@ protected function selfLink($form = true, $params = []) | |
'page' => 'sqlite', | ||
'db' => $this->db ? $this->db->getDBName() : '', | ||
'sectok' => getSecurityToken(), | ||
], $params | ||
], | ||
$params | ||
); | ||
|
||
return wl($ID, $params, false, $form ? '&' : '&'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,24 @@ | |
* @noinspection PhpComposerExtensionStubsInspection | ||
*/ | ||
|
||
use dokuwiki\Extension\Plugin; | ||
use dokuwiki\plugin\sqlite\SQLiteDB; | ||
use dokuwiki\plugin\sqlite\Tools; | ||
|
||
|
||
|
||
/** | ||
* For compatibility with previous adapter implementation. | ||
*/ | ||
if(!defined('DOKU_EXT_PDO')) define('DOKU_EXT_PDO', 'pdo'); | ||
if (!defined('DOKU_EXT_PDO')) define('DOKU_EXT_PDO', 'pdo'); | ||
class helper_plugin_sqlite_adapter_dummy | ||
{ | ||
public function getName() { | ||
public function getName() | ||
{ | ||
return DOKU_EXT_PDO; | ||
} | ||
|
||
public function setUseNativeAlter($set) {} | ||
public function setUseNativeAlter($set) | ||
{ | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -31,10 +33,10 @@ public function setUseNativeAlter($set) {} | |
* @author Andreas Gohr <[email protected]> | ||
* @deprecated 2023-03-15 | ||
*/ | ||
class helper_plugin_sqlite extends DokuWiki_Plugin | ||
class helper_plugin_sqlite extends Plugin | ||
{ | ||
/** @var SQLiteDB|null */ | ||
protected $adapter = null; | ||
protected $adapter; | ||
|
||
/** @var array result cache */ | ||
protected $data; | ||
|
@@ -89,7 +91,7 @@ public function existsPDOSqlite() | |
*/ | ||
public function init($dbname, $updatedir) | ||
{ | ||
if(!defined('DOKU_UNITTEST')) { // for now we don't want to trigger the deprecation warning in the tests | ||
if (!defined('DOKU_UNITTEST')) { // for now we don't want to trigger the deprecation warning in the tests | ||
dbg_deprecated(SQLiteDB::class); | ||
} | ||
|
||
|
@@ -108,7 +110,7 @@ public function init($dbname, $updatedir) | |
* @param SQLiteDB $adapter | ||
* @return void | ||
*/ | ||
function setAdapter($adapter) | ||
public function setAdapter($adapter) | ||
{ | ||
$this->adapter = $adapter; | ||
} | ||
|
@@ -182,17 +184,18 @@ public function query() | |
* @return bool|string | ||
* @throws Exception | ||
*/ | ||
public function prepareSql($args) { | ||
public function prepareSql($args) | ||
{ | ||
|
||
$sql = trim(array_shift($args)); | ||
$sql = rtrim($sql, ';'); | ||
|
||
if(!$sql) { | ||
if (!$sql) { | ||
throw new \Exception('No SQL statement given', -1); | ||
} | ||
|
||
$argc = count($args); | ||
if($argc > 0 && is_array($args[0])) { | ||
if ($argc > 0 && is_array($args[0])) { | ||
$args = $args[0]; | ||
$argc = count($args); | ||
} | ||
|
@@ -201,18 +204,18 @@ public function prepareSql($args) { | |
$qmc = substr_count($sql, '?'); | ||
if ($argc < $qmc) { | ||
throw new \Exception('Not enough arguments passed for statement. ' . | ||
'Expected '.$qmc.' got '. $argc.' - '.hsc($sql)); | ||
} elseif($argc > $qmc) { | ||
'Expected ' . $qmc . ' got ' . $argc . ' - ' . hsc($sql)); | ||
} elseif ($argc > $qmc) { | ||
throw new \Exception('Too much arguments passed for statement. ' . | ||
'Expected '.$qmc.' got '. $argc.' - '.hsc($sql)); | ||
'Expected ' . $qmc . ' got ' . $argc . ' - ' . hsc($sql)); | ||
} | ||
|
||
// explode at wildcard, then join again | ||
$parts = explode('?', $sql, $argc + 1); | ||
$args = array_map([$this->adapter->getPdo(), 'quote'], $args); | ||
$sql = ''; | ||
|
||
while(($part = array_shift($parts)) !== null) { | ||
while (($part = array_shift($parts)) !== null) { | ||
$sql .= $part; | ||
$sql .= array_shift($args); | ||
} | ||
|
@@ -356,7 +359,7 @@ public function countChanges($res) | |
public function quote_and_join($vals, $sep = ',') | ||
{ | ||
$vals = array_map([$this->adapter->getPdo(), 'quote'], $vals); | ||
return join($sep, $vals); | ||
return implode($sep, $vals); | ||
} | ||
|
||
/** | ||
|
@@ -391,7 +394,7 @@ public function escape_string($str) | |
*/ | ||
public function SQLstring2array($sql) | ||
{ | ||
if(!DOKU_UNITTEST) { // for now we don't want to trigger the deprecation warning in the tests | ||
if (!DOKU_UNITTEST) { // for now we don't want to trigger the deprecation warning in the tests | ||
dbg_deprecated(Tools::class . '::SQLstring2array'); | ||
} | ||
return Tools::SQLstring2array($sql); | ||
|
@@ -400,7 +403,8 @@ public function SQLstring2array($sql) | |
/** | ||
* @deprecated needs to be fixed in stuct and structpublish | ||
*/ | ||
public function doTransaction($sql, $sqlpreparing = true) { | ||
public function doTransaction($sql, $sqlpreparing = true) | ||
{ | ||
throw new \Exception( | ||
'This method seems to never have done what it suggests. Please use the query() function instead.' | ||
); | ||
|
Oops, something went wrong.