Merge pull request #3404 from splitbrain/phpunit8
Switch to phpunit 8 (fixes #2693)
This commit is contained in:
commit
a8b6eaa91e
|
@ -10,7 +10,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ['7.2', '7.3', '7.4']
|
||||
php-versions: ['7.2', '7.3', '7.4', '8.0']
|
||||
fail-fast: false
|
||||
|
||||
services:
|
||||
|
|
|
@ -10,7 +10,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ['7.2', '7.3', '7.4']
|
||||
php-versions: ['7.2', '7.3', '7.4', '8.0']
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
# Editor and temporary files
|
||||
*.swp
|
||||
*.bak
|
||||
*.old
|
||||
*~
|
||||
*.DS_Store
|
||||
*.iml
|
||||
.idea/
|
||||
.buildpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
# DokuWiki
|
||||
.htaccess
|
||||
/conf/*.local.conf
|
||||
/conf/acl.auth.php
|
||||
/conf/local.php
|
||||
|
@ -10,19 +24,6 @@
|
|||
/conf/plugin_lang/*
|
||||
/conf/plugins.local.*
|
||||
/conf/tpl/*
|
||||
.htaccess
|
||||
*.swp
|
||||
*.bak
|
||||
*.old
|
||||
*~
|
||||
*.DS_Store
|
||||
*.iml
|
||||
.idea/
|
||||
# Eclipse IDE
|
||||
.buildpath
|
||||
.project
|
||||
.settings/
|
||||
# DokuWiki
|
||||
/data/attic/*
|
||||
/data/cache/*
|
||||
/data/index/*
|
||||
|
@ -91,3 +92,7 @@ vendor/splitbrain/php-cli/screenshot*
|
|||
vendor/splitbrain/php-cli/generate-api.sh
|
||||
vendor/splitbrain/php-cli/apigen.neon
|
||||
|
||||
# PHPUnit tests
|
||||
phpunit.phar
|
||||
.phpunit.result.cache
|
||||
_test/data/
|
||||
|
|
|
@ -3,33 +3,12 @@
|
|||
use dokuwiki\Extension\PluginController;
|
||||
use dokuwiki\Extension\Event;
|
||||
use dokuwiki\Extension\EventHandler;
|
||||
|
||||
if(!class_exists('PHPUnit_Framework_TestCase')) {
|
||||
/**
|
||||
* phpunit 5/6 compatibility
|
||||
*/
|
||||
class PHPUnit_Framework_TestCase extends PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* setExpectedException is deprecated in PHPUnit 6
|
||||
*
|
||||
* @param string $class
|
||||
* @param null|string $message
|
||||
*/
|
||||
public function setExpectedException($class, $message=null) {
|
||||
$this->expectException($class);
|
||||
if(!is_null($message)) {
|
||||
$this->expectExceptionMessage($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to provide basic functionality for tests
|
||||
*
|
||||
* @uses PHPUnit_Framework_TestCase and thus PHPUnit 5.7+ is required
|
||||
*/
|
||||
abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
|
||||
abstract class DokuWikiTest extends PHPUnit\Framework\TestCase {
|
||||
|
||||
/**
|
||||
* tests can override this
|
||||
|
@ -45,12 +24,25 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
|
|||
*/
|
||||
protected $pluginsDisabled = array();
|
||||
|
||||
/**
|
||||
* setExpectedException was deprecated in PHPUnit 6
|
||||
*
|
||||
* @param string $class
|
||||
* @param null|string $message
|
||||
*/
|
||||
public function setExpectedException($class, $message=null) {
|
||||
$this->expectException($class);
|
||||
if(!is_null($message)) {
|
||||
$this->expectExceptionMessage($message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the data directory
|
||||
*
|
||||
* This is ran before each test class
|
||||
*/
|
||||
public static function setUpBeforeClass() {
|
||||
public static function setUpBeforeClass() : void {
|
||||
// just to be safe not to delete something undefined later
|
||||
if(!defined('TMP_DIR')) die('no temporary directory');
|
||||
if(!defined('DOKU_TMP_DATA')) die('no temporary data directory');
|
||||
|
@ -66,7 +58,7 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
|
|||
* @throws Exception if plugin actions fail
|
||||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp() : void {
|
||||
|
||||
// reload config
|
||||
global $conf, $config_cascade;
|
||||
|
@ -103,6 +95,7 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
|
|||
$conf['compression'] = 0;
|
||||
}
|
||||
// make real paths and check them
|
||||
init_creationmodes();
|
||||
init_paths();
|
||||
init_files();
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ class TestRequest {
|
|||
}
|
||||
|
||||
$params = array();
|
||||
list($uri, $query) = explode('?', $uri, 2);
|
||||
list($uri, $query) = array_pad(explode('?', $uri, 2), 2, null);
|
||||
if($query) parse_str($query, $params);
|
||||
|
||||
$this->script = substr($uri, 1);
|
||||
|
|
|
@ -7,27 +7,16 @@
|
|||
$phpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;
|
||||
print "Running PHP $phpVersion\n";
|
||||
|
||||
switch ($phpVersion) {
|
||||
case '5.6':
|
||||
$phpunit = 'phpunit-5.phar';
|
||||
break;
|
||||
case '7.0':
|
||||
$phpunit = 'phpunit-6.phar';
|
||||
break;
|
||||
case '7.1':
|
||||
case '7.2':
|
||||
case '7.3':
|
||||
$phpunit = 'phpunit-7.phar';
|
||||
break;
|
||||
case '7.4':
|
||||
$phpunit = 'phpunit-7.phar';
|
||||
// PHP 5 backward compatibility lock to PHPUnit 7 (type hinting)
|
||||
break;
|
||||
default:
|
||||
$phpunit = 'phpunit-7.phar';
|
||||
|
||||
if(version_compare($phpVersion, '7.2') < 0) {
|
||||
echo 'we no longer support PHP versions < 7.2 and thus do not support tests on them';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// for now we default to phpunit-8
|
||||
$phpunit = 'phpunit-8.phar';
|
||||
|
||||
|
||||
$url = "https://phar.phpunit.de/$phpunit";
|
||||
$out = __DIR__ . '/phpunit.phar';
|
||||
|
||||
|
|
|
@ -12,15 +12,16 @@ class BulkSubscriptionsSenderTest extends DokuWikiTest
|
|||
|
||||
private $originalSubscriptionConfig;
|
||||
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
global $conf;
|
||||
$this->originalSubscriptionConfig = $conf['subscribers'];
|
||||
$conf['subscribers'] = true;
|
||||
$conf['mailfromnobody'] = 'phpunit@example.com';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown() : void
|
||||
{
|
||||
global $conf;
|
||||
$conf['subscribers'] = $this->originalSubscriptionConfig;
|
||||
|
|
|
@ -9,7 +9,7 @@ class SubscriberManagerTest extends DokuWikiTest
|
|||
{
|
||||
private $originalSubscriptionConfig;
|
||||
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
global $conf;
|
||||
|
@ -17,7 +17,7 @@ class SubscriberManagerTest extends DokuWikiTest
|
|||
$conf['subscribers'] = true;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown() : void
|
||||
{
|
||||
global $conf;
|
||||
$conf['subscribers'] = $this->originalSubscriptionConfig;
|
||||
|
|
|
@ -15,7 +15,7 @@ class XmlRpcServerTest extends DokuWikiTest
|
|||
{
|
||||
protected $server;
|
||||
|
||||
function setUp()
|
||||
function setUp () : void
|
||||
{
|
||||
parent::setUp();
|
||||
global $conf;
|
||||
|
|
|
@ -6,7 +6,7 @@ class auth_acl_test extends DokuWikiTest {
|
|||
|
||||
protected $oldAuthAcl;
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
global $AUTH_ACL;
|
||||
global $auth;
|
||||
|
@ -14,7 +14,7 @@ class auth_acl_test extends DokuWikiTest {
|
|||
$auth = new AuthPlugin();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
global $AUTH_ACL;
|
||||
$AUTH_ACL = $this->oldAuthAcl;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class auth_acl_caseinsensitive_test extends DokuWikiTest {
|
|||
protected $oldAuth;
|
||||
protected $oldAuthAcl;
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
global $auth;
|
||||
global $AUTH_ACL;
|
||||
|
@ -17,7 +17,7 @@ class auth_acl_caseinsensitive_test extends DokuWikiTest {
|
|||
$auth = new AuthCaseInsensitivePlugin();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
global $conf;
|
||||
global $AUTH_ACL;
|
||||
global $auth;
|
||||
|
|
|
@ -8,7 +8,7 @@ class auth_admin_test extends DokuWikiTest
|
|||
|
||||
private $oldauth;
|
||||
|
||||
function setUp()
|
||||
function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
global $auth;
|
||||
|
@ -27,7 +27,7 @@ class auth_admin_test extends DokuWikiTest
|
|||
$auth = new AuthCaseInsensitivePlugin();
|
||||
}
|
||||
|
||||
function teardown()
|
||||
function tearDown() : void
|
||||
{
|
||||
global $auth;
|
||||
global $AUTH_ACL;
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
|
||||
class auth_loadacl_test extends DokuWikiTest {
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
global $USERINFO;
|
||||
parent::setUp();
|
||||
$_SERVER['REMOTE_USER'] = 'testuser';
|
||||
$USERINFO['grps'] = array('foo','bar');
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class auth_nameencode_test extends DokuWikiTest {
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
global $cache_authname;
|
||||
$cache_authname = array();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class cache_use_test extends DokuWikiTest {
|
|||
/** @var CacheRenderer $cache */
|
||||
private $cache;
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
global $ID, $conf;
|
||||
parent::setUp();
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class changelog_getrevisionsaround_test extends DokuWikiTest {
|
|||
);
|
||||
private $pageid = 'mailinglist';
|
||||
|
||||
function setup() {
|
||||
function setup() : void {
|
||||
parent::setup();
|
||||
global $cache_revinfo;
|
||||
$cache =& $cache_revinfo;
|
||||
|
|
|
@ -14,7 +14,7 @@ class changelog_getlastrevisionat_test extends DokuWikiTest {
|
|||
|
||||
private $pageid = 'mailinglist';
|
||||
|
||||
function setup() {
|
||||
function setup() : void {
|
||||
parent::setup();
|
||||
global $cache_revinfo;
|
||||
$cache =& $cache_revinfo;
|
||||
|
@ -140,7 +140,7 @@ class changelog_getlastrevisionat_test extends DokuWikiTest {
|
|||
//save settings
|
||||
$oldSuperUser = $conf['superuser'];
|
||||
$oldUseacl = $conf['useacl'];
|
||||
$oldRemoteUser = $_SERVER['REMOTE_USER'];
|
||||
$oldRemoteUser = isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : null;
|
||||
|
||||
$conf['superuser'] = 'admin';
|
||||
$conf['useacl'] = 1;
|
||||
|
@ -165,7 +165,9 @@ class changelog_getlastrevisionat_test extends DokuWikiTest {
|
|||
$this->assertLessThanOrEqual(time(), $current);
|
||||
|
||||
//restore settings
|
||||
$_SERVER['REMOTE_USER'] = $oldRemoteUser;
|
||||
if ($oldRemoteUser !== null) {
|
||||
$_SERVER['REMOTE_USER'] = $oldRemoteUser;
|
||||
}
|
||||
$conf['superuser'] = $oldSuperUser;
|
||||
$conf['useacl'] = $oldUseacl;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class changelog_getrelativerevision_test extends DokuWikiTest {
|
|||
private $logline = "1362525899 127.0.0.1 E mailinglist pubcie [Data entry] \n";
|
||||
private $pageid = 'mailinglist';
|
||||
|
||||
function setup() {
|
||||
function setup() : void {
|
||||
parent::setup();
|
||||
global $cache_revinfo;
|
||||
$cache =& $cache_revinfo;
|
||||
|
|
|
@ -15,7 +15,7 @@ class changelog_getrevisionsinfo_test extends DokuWikiTest {
|
|||
private $firstlogline = "1374261194 127.0.0.1 E mailinglist pubcie \n";
|
||||
private $pageid = 'mailinglist';
|
||||
|
||||
function setup() {
|
||||
function setup() : void {
|
||||
parent::setup();
|
||||
global $cache_revinfo;
|
||||
$cache =& $cache_revinfo;
|
||||
|
|
|
@ -31,7 +31,7 @@ class changelog_getrevisions_test extends DokuWikiTest {
|
|||
);
|
||||
private $pageid = 'mailinglist';
|
||||
|
||||
function setup() {
|
||||
function setup() : void {
|
||||
parent::setup();
|
||||
global $cache_revinfo;
|
||||
$cache =& $cache_revinfo;
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
|
||||
class cli_options extends DokuWikiTest {
|
||||
|
||||
function test_simpleshort() {
|
||||
$options = new DokuCLI_Options();
|
||||
$options->registerOption('exclude', 'exclude files', 'x', 'file');
|
||||
|
||||
$options->args = array('-x', 'foo', 'bang');
|
||||
$options->parseOptions();
|
||||
|
||||
$this->assertEquals('foo', $options->getOpt('exclude'));
|
||||
$this->assertEquals(array('bang'), $options->args);
|
||||
$this->assertFalse($options->getOpt('nothing'));
|
||||
}
|
||||
|
||||
function test_simplelong1() {
|
||||
$options = new DokuCLI_Options();
|
||||
$options->registerOption('exclude', 'exclude files', 'x', 'file');
|
||||
|
||||
$options->args = array('--exclude', 'foo', 'bang');
|
||||
$options->parseOptions();
|
||||
|
||||
$this->assertEquals('foo', $options->getOpt('exclude'));
|
||||
$this->assertEquals(array('bang'), $options->args);
|
||||
$this->assertFalse($options->getOpt('nothing'));
|
||||
}
|
||||
|
||||
function test_simplelong2() {
|
||||
$options = new DokuCLI_Options();
|
||||
$options->registerOption('exclude', 'exclude files', 'x', 'file');
|
||||
|
||||
$options->args = array('--exclude=foo', 'bang');
|
||||
$options->parseOptions();
|
||||
|
||||
$this->assertEquals('foo', $options->getOpt('exclude'));
|
||||
$this->assertEquals(array('bang'), $options->args);
|
||||
$this->assertFalse($options->getOpt('nothing'));
|
||||
}
|
||||
|
||||
function test_complex() {
|
||||
$options = new DokuCLI_Options();
|
||||
|
||||
$options->registerOption('plugins', 'run on plugins only', 'p');
|
||||
$options->registerCommand('status', 'display status info');
|
||||
$options->registerOption('long', 'display long lines', 'l', false, 'status');
|
||||
|
||||
$options->args = array('-p', 'status', '--long', 'foo');
|
||||
$options->parseOptions();
|
||||
|
||||
$this->assertEquals('status', $options->getCmd());
|
||||
$this->assertTrue($options->getOpt('plugins'));
|
||||
$this->assertTrue($options->getOpt('long'));
|
||||
$this->assertEquals(array('foo'), $options->args);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class common_infofunctions_test extends DokuWikiTest {
|
||||
|
||||
function setup(){
|
||||
function setup() : void {
|
||||
parent::setup();
|
||||
|
||||
global $USERINFO;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class common_clientIP_test extends DokuWikiTest {
|
||||
|
||||
function setup(){
|
||||
function setup() : void {
|
||||
parent::setup();
|
||||
|
||||
global $conf;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
class common_basicinfo_test extends DokuWikiTest {
|
||||
|
||||
function setup(){
|
||||
|
||||
function setup() : void {
|
||||
parent::setup();
|
||||
|
||||
global $USERINFO;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
class common_pageinfo_test extends DokuWikiTest {
|
||||
|
||||
function setup(){
|
||||
function setup() : void {
|
||||
parent::setup();
|
||||
|
||||
global $USERINFO;
|
||||
|
|
|
@ -4,7 +4,7 @@ require_once dirname(__FILE__).'/httpclient_http.test.php';
|
|||
class httpclient_https_test extends httpclient_http_test {
|
||||
protected $server = 'https://eu.httpbin.org/';
|
||||
|
||||
public function setUp(){
|
||||
public function setUp() : void {
|
||||
// skip tests when this PHP has no SSL support
|
||||
$transports = stream_get_transports();
|
||||
if(!in_array('ssl',$transports)){
|
||||
|
|
|
@ -4,7 +4,7 @@ require_once dirname(__FILE__).'/httpclient_http_proxy.test.php';
|
|||
class httpclient_https_proxy_test extends httpclient_http_proxy_test {
|
||||
protected $url = 'https://eu.httpbin.org/user-agent';
|
||||
|
||||
public function setUp(){
|
||||
public function setUp() : void {
|
||||
// skip tests when this PHP has no SSL support
|
||||
$transports = stream_get_transports();
|
||||
if(!in_array('ssl',$transports)){
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* @author Michael Hamann <michael@content-space.de>
|
||||
*/
|
||||
class indexer_indexing_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
public function setUp() : void {
|
||||
parent::setUp();
|
||||
saveWikiText('testpage', 'Foo bar baz.', 'Test initialization');
|
||||
saveWikiText('notfound', 'Foon barn bazn.', 'Test initialization');
|
||||
|
|
|
@ -8,7 +8,7 @@ class indexer_rename_test extends DokuWikiTest {
|
|||
|
||||
private $old_id = 'old_testid';
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
$this->indexer = idx_get_indexer();
|
||||
$this->indexer->clear();
|
||||
|
|
|
@ -227,12 +227,12 @@ class input_test extends DokuWikiTest {
|
|||
$INPUT = new Input();
|
||||
|
||||
$INPUT->remove('string');
|
||||
$this->assertNull($_REQUEST['string']);
|
||||
$this->assertNull($_POST['string']);
|
||||
$this->assertNull($_GET['string']);
|
||||
$this->assertArrayNotHasKey('string', $_REQUEST);
|
||||
$this->assertArrayNotHasKey('string', $_POST);
|
||||
$this->assertArrayNotHasKey('string', $_GET);
|
||||
|
||||
$INPUT->post->remove('int');
|
||||
$this->assertNull($_POST['int']);
|
||||
$this->assertArrayNotHasKey('int', $_POST);
|
||||
$this->assertEquals(17, $_GET['int']);
|
||||
$this->assertEquals(17, $_REQUEST['int']);
|
||||
}
|
||||
|
@ -245,13 +245,13 @@ class input_test extends DokuWikiTest {
|
|||
|
||||
$INPUT->set('test','foo');
|
||||
$this->assertEquals('foo',$_REQUEST['test']);
|
||||
$this->assertNull($_POST['test']);
|
||||
$this->assertNull($_GET['test']);
|
||||
$this->assertArrayNotHasKey('test', $_POST);
|
||||
$this->assertArrayNotHasKey('test', $_GET);
|
||||
|
||||
$INPUT->get->set('test2','foo');
|
||||
$this->assertEquals('foo',$_GET['test2']);
|
||||
$this->assertEquals('foo',$_REQUEST['test2']);
|
||||
$this->assertNull($_POST['test']);
|
||||
$this->assertArrayNotHasKey('test2', $_POST);
|
||||
}
|
||||
|
||||
public function test_ref(){
|
||||
|
|
|
@ -25,10 +25,10 @@ class media_searchlist_test extends DokuWikiTest
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setUp()
|
||||
function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
||||
//create some files to search
|
||||
$png = mediaFN('wiki:kind_zu_katze.png');
|
||||
$ogv = mediaFN('wiki:kind_zu_katze.ogv');
|
||||
|
|
|
@ -4,7 +4,7 @@ class init_clean_id_test extends DokuWikiTest
|
|||
{
|
||||
|
||||
/** @inheritDoc */
|
||||
function teardown()
|
||||
function teardown() : void
|
||||
{
|
||||
global $cache_cleanid;
|
||||
$cache_cleanid = array();
|
||||
|
@ -92,9 +92,9 @@ class init_clean_id_test extends DokuWikiTest
|
|||
|
||||
foreach ($tests as $test) {
|
||||
// defaults
|
||||
$sepchar = $test[2]['sepchar'] ?: '_';
|
||||
$sepchar = isset($test[2]['sepchar']) ? $test[2]['sepchar'] : '_';
|
||||
$deaccent = isset($test[2]['deaccent']) ? $test[2]['deaccent'] : 1;
|
||||
$ascii = $test[2]['ascii'] ?: false;
|
||||
$ascii = isset($test[2]['ascii']) ? $test[2]['ascii'] : false;
|
||||
|
||||
// unless set, test both useslash settings
|
||||
if (isset($test[2]['useslash'])) {
|
||||
|
|
|
@ -6,7 +6,7 @@ class pageutils_findnearest_test extends DokuWikiTest {
|
|||
|
||||
protected $oldAuthAcl;
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
global $AUTH_ACL;
|
||||
global $auth;
|
||||
|
@ -25,7 +25,7 @@ class pageutils_findnearest_test extends DokuWikiTest {
|
|||
);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
global $AUTH_ACL;
|
||||
$AUTH_ACL = $this->oldAuthAcl;
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@ abstract class TestOfDoku_Parser extends DokuWikiTest {
|
|||
/** @var Doku_Handler */
|
||||
protected $H;
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
$this->H = new Doku_Handler();
|
||||
$this->P = new Parser($this->H);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
unset($this->P);
|
||||
unset($this->H);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ require_once 'parser.inc.php';
|
|||
*/
|
||||
class TestOfDoku_Parser_Code extends TestOfDoku_Parser {
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
$this->P->addMode('code',new Code());
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ require_once 'parser.inc.php';
|
|||
|
||||
class TestOfDoku_Parser_File extends TestOfDoku_Parser {
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
$this->P->addMode('file',new File());
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ require_once 'parser.inc.php';
|
|||
|
||||
class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
$this->P->addMode('footnote',new Footnote());
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ require_once 'parser.inc.php';
|
|||
|
||||
class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
global $conf;
|
||||
$conf['typography'] = 2;
|
||||
|
|
|
@ -12,12 +12,12 @@ class renderer_metadata_test extends DokuWikiTest {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
$this->R = new Doku_Renderer_metadata();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
unset($this->R);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@ class renderer_xhtml_test extends DokuWikiTest {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
$this->R = new Doku_Renderer_xhtml();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
unset($this->R);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
class parserutils_set_metadata_during_rendering_test extends DokuWikiTest {
|
||||
class parserutils_set_metadata_during_rendering_test extends DokuWikiTest
|
||||
{
|
||||
// the id used for this test case
|
||||
private $id;
|
||||
// if the test case is currently running
|
||||
|
@ -8,17 +9,35 @@ class parserutils_set_metadata_during_rendering_test extends DokuWikiTest {
|
|||
// the original plugin controller
|
||||
private $plugin_controller;
|
||||
|
||||
// the actual test
|
||||
function test_p_set_metadata_during_rendering() {
|
||||
/**
|
||||
* the actual test
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function test_p_set_metadata_during_rendering()
|
||||
{
|
||||
global $EVENT_HANDLER;
|
||||
$this->id = 'test:p_set_metadata_during_rendering';
|
||||
$this->active = true;
|
||||
|
||||
// write the wiki page so it exists and needs to be rendered
|
||||
saveWikiText($this->id, 'Test '.time(), 'Test data setup');
|
||||
saveWikiText($this->id, 'Test ' . time(), 'Test data setup');
|
||||
|
||||
$EVENT_HANDLER->register_hook('PARSER_METADATA_RENDER', 'BEFORE', $this, 'helper_set_metadata', array('test_before_set' => 'test'));
|
||||
$EVENT_HANDLER->register_hook('PARSER_METADATA_RENDER', 'AFTER', $this, 'helper_set_metadata', array('test_after_set' => 'test'));
|
||||
$EVENT_HANDLER->register_hook(
|
||||
'PARSER_METADATA_RENDER',
|
||||
'BEFORE',
|
||||
$this,
|
||||
'helper_set_metadata',
|
||||
['test_before_set' => 'test']
|
||||
);
|
||||
$EVENT_HANDLER->register_hook(
|
||||
'PARSER_METADATA_RENDER',
|
||||
'AFTER',
|
||||
$this,
|
||||
'helper_set_metadata',
|
||||
['test_after_set' => 'test']
|
||||
);
|
||||
$EVENT_HANDLER->register_hook('PARSER_HANDLER_DONE', 'BEFORE', $this, 'helper_inject_test_instruction');
|
||||
|
||||
// Change the global plugin controller so this test can be a fake syntax plugin
|
||||
|
@ -33,9 +52,9 @@ class parserutils_set_metadata_during_rendering_test extends DokuWikiTest {
|
|||
$plugin_controller = $this->plugin_controller;
|
||||
|
||||
// assert that all three calls to p_set_metadata have been successful
|
||||
$this->assertEquals($newMeta['test_before_set'], 'test');
|
||||
$this->assertEquals($newMeta['test_after_set'], 'test');
|
||||
$this->assertEquals($newMeta['test_during_rendering'], 'test');
|
||||
$this->assertEquals($newMeta[ 'test_before_set' ], 'test');
|
||||
$this->assertEquals($newMeta[ 'test_after_set' ], 'test');
|
||||
$this->assertEquals($newMeta[ 'test_during_rendering' ], 'test');
|
||||
|
||||
// clean up
|
||||
$this->active = false;
|
||||
|
@ -47,40 +66,46 @@ class parserutils_set_metadata_during_rendering_test extends DokuWikiTest {
|
|||
}
|
||||
|
||||
// helper for the action plugin part of the test, tries executing p_set_metadata during rendering
|
||||
function helper_set_metadata($event, $meta) {
|
||||
public function helper_set_metadata($event, $meta)
|
||||
{
|
||||
if ($this->active) {
|
||||
p_set_metadata($this->id, $meta, false, true);
|
||||
$keys = array_keys($meta);
|
||||
$key = array_pop($keys);
|
||||
$this->assertTrue(is_string($meta[$key])); // ensure we really have a key
|
||||
$this->assertTrue(is_string($meta[ $key ])); // ensure we really have a key
|
||||
// ensure that the metadata property hasn't been set previously
|
||||
$this->assertNotEquals($meta[$key], p_get_metadata($this->id, $key));
|
||||
$this->assertNotEquals($meta[ $key ], p_get_metadata($this->id, $key));
|
||||
}
|
||||
}
|
||||
|
||||
// helper for injecting an instruction for this test case
|
||||
function helper_inject_test_instruction($event) {
|
||||
if ($this->active)
|
||||
$event->data->calls[] = array('plugin', array('parserutils_test', array()));
|
||||
public function helper_inject_test_instruction($event)
|
||||
{
|
||||
if ($this->active) {
|
||||
$event->data->calls[] = ['plugin', ['parserutils_test', []], -9000];
|
||||
}
|
||||
}
|
||||
|
||||
// fake syntax plugin rendering method that tries calling p_set_metadata during the actual rendering process
|
||||
function render($format, &$renderer, $data) {
|
||||
public function render($format, &$renderer, $data)
|
||||
{
|
||||
if ($this->active) {
|
||||
$key = 'test_during_rendering';
|
||||
p_set_metadata($this->id, array($key => 'test'), false, true);
|
||||
p_set_metadata($this->id, [$key => 'test'], false, true);
|
||||
// ensure that the metadata property hasn't been set previously
|
||||
$this->assertNotEquals($key, p_get_metadata($this->id, $key));
|
||||
}
|
||||
}
|
||||
|
||||
// wrapper function for the fake plugin controller
|
||||
function getList($type='',$all=false){
|
||||
public function getList($type = '', $all = false)
|
||||
{
|
||||
return $this->plugin_controller->getList();
|
||||
}
|
||||
|
||||
// wrapper function for the fake plugin controller, return $this for the fake syntax of this test
|
||||
function load($type,$name,$new=false,$disabled=false){
|
||||
public function load($type, $name, $new = false, $disabled = false)
|
||||
{
|
||||
if ($name == 'parserutils_test') {
|
||||
return $this;
|
||||
} else {
|
||||
|
|
|
@ -135,7 +135,7 @@ class remote_test extends DokuWikiTest {
|
|||
/** @var Api */
|
||||
protected $remote;
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
parent::setUp();
|
||||
global $plugin_controller;
|
||||
global $conf;
|
||||
|
@ -168,7 +168,7 @@ class remote_test extends DokuWikiTest {
|
|||
$auth = new AuthPlugin();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
global $USERINFO;
|
||||
$USERINFO = $this->userinfo;
|
||||
|
||||
|
@ -196,8 +196,8 @@ class remote_test extends DokuWikiTest {
|
|||
$this->assertEquals(array('string','int','bool','string'), $methods['plugin.testplugin2.commented']['args']);
|
||||
$this->assertEquals('array', $methods['plugin.testplugin2.commented']['return']);
|
||||
$this->assertEquals(0, $methods['plugin.testplugin2.commented']['public']);
|
||||
$this->assertContains('This is a dummy method', $methods['plugin.testplugin2.commented']['doc']);
|
||||
$this->assertContains('string $str some more parameter description', $methods['plugin.testplugin2.commented']['doc']);
|
||||
$this->assertStringContainsString('This is a dummy method', $methods['plugin.testplugin2.commented']['doc']);
|
||||
$this->assertStringContainsString('string $str some more parameter description', $methods['plugin.testplugin2.commented']['doc']);
|
||||
}
|
||||
|
||||
function test_hasAccessSuccess() {
|
||||
|
@ -206,15 +206,13 @@ class remote_test extends DokuWikiTest {
|
|||
$this->assertTrue($this->remote->hasAccess());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException dokuwiki\Remote\AccessDeniedException
|
||||
*/
|
||||
function test_hasAccessFail() {
|
||||
global $conf;
|
||||
$conf['remote'] = 0;
|
||||
// the hasAccess() should throw a Exception to keep the same semantics with xmlrpc.php.
|
||||
// because the user(xmlrpc) check remote before .--> (!$conf['remote']) die('XML-RPC server not enabled.');
|
||||
// so it must be a Exception when get here.
|
||||
$this->expectException(\dokuwiki\Remote\AccessDeniedException::class);
|
||||
$this->remote->hasAccess();
|
||||
}
|
||||
|
||||
|
@ -368,13 +366,12 @@ class remote_test extends DokuWikiTest {
|
|||
global $conf;
|
||||
$conf['remote'] = 1;
|
||||
|
||||
$this->expectException(RemoteException::class);
|
||||
$this->expectExceptionCode(-32603);
|
||||
|
||||
$remoteApi = new Api();
|
||||
try {
|
||||
$remoteApi->call('dose not exist');
|
||||
$this->fail('Expects RemoteException to be raised');
|
||||
} catch (RemoteException $th) {
|
||||
$this->assertEquals(-32603, $th->getCode());
|
||||
}
|
||||
$remoteApi->call('invalid method'); // no '.'
|
||||
$remoteApi->call('does.not exist'); // unknown method type
|
||||
}
|
||||
|
||||
function test_publicCallCore() {
|
||||
|
@ -392,23 +389,19 @@ class remote_test extends DokuWikiTest {
|
|||
$this->assertTrue($remoteApi->call('plugin.testplugin.publicCall'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException dokuwiki\Remote\AccessDeniedException
|
||||
*/
|
||||
function test_publicCallCoreDeny() {
|
||||
global $conf;
|
||||
$conf['useacl'] = 1;
|
||||
$this->expectException(\dokuwiki\Remote\AccessDeniedException::class);
|
||||
$remoteApi = new Api();
|
||||
$remoteApi->getCoreMethods(new RemoteAPICoreTest());
|
||||
$remoteApi->call('wiki.stringTestMethod');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException dokuwiki\Remote\AccessDeniedException
|
||||
*/
|
||||
function test_publicCallPluginDeny() {
|
||||
global $conf;
|
||||
$conf['useacl'] = 1;
|
||||
$this->expectException(\dokuwiki\Remote\AccessDeniedException::class);
|
||||
$remoteApi = new Api();
|
||||
$remoteApi->call('plugin.testplugin.methodString');
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class remoteapicore_test extends DokuWikiTest {
|
|||
/** @var Api */
|
||||
protected $remote;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp() : void {
|
||||
// we need a clean setup before each single test:
|
||||
DokuWikiTest::setUpBeforeClass();
|
||||
|
||||
|
@ -35,7 +35,7 @@ class remoteapicore_test extends DokuWikiTest {
|
|||
$this->remote = new Api();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() : void {
|
||||
parent::tearDown();
|
||||
|
||||
global $USERINFO;
|
||||
|
|
|
@ -21,7 +21,7 @@ class remoteapicore_aclcheck_test extends DokuWikiTest {
|
|||
$auth = new auth_plugin_authplain();
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
public function setUp() : void {
|
||||
global $config_cascade;
|
||||
global $conf;
|
||||
global $USERINFO;
|
||||
|
@ -44,7 +44,7 @@ class remoteapicore_aclcheck_test extends DokuWikiTest {
|
|||
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() : void {
|
||||
global $USERINFO;
|
||||
global $AUTH_ACL;
|
||||
global $config_cascade;
|
||||
|
|
|
@ -15,7 +15,7 @@ class sort_without_collator_test extends sort_with_collator_test
|
|||
/**
|
||||
* Disable the "intl" extension.
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass() : void
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
Sort::useIntl(false);
|
||||
|
@ -24,7 +24,7 @@ class sort_without_collator_test extends sort_with_collator_test
|
|||
/**
|
||||
* Reenable the "intl" extension.
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
public static function tearDownAfterClass() : void
|
||||
{
|
||||
Sort::useIntl(true);
|
||||
parent::tearDownAfterClass();
|
||||
|
|
|
@ -30,9 +30,13 @@ class styleutils_cssstyleini_test extends DokuWikiTest {
|
|||
$this->assertArrayHasKey('print', $actual['stylesheets']);
|
||||
|
||||
// check an original stylesheet and an additional one
|
||||
$this->assertArraySubset($expected['stylesheets']['screen'], $actual['stylesheets']['screen']);
|
||||
$this->assertEmpty(
|
||||
array_diff_assoc($expected['stylesheets']['screen'], $actual['stylesheets']['screen'])
|
||||
);
|
||||
|
||||
// merged config has an original value (text), an overridden value (background) and a new custom replacement (custom_variable)
|
||||
$this->assertArraySubset($expected['replacements'], $actual['replacements']);
|
||||
$this->assertEmpty(
|
||||
array_diff_assoc($expected['replacements'], $actual['replacements'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class template_tpl_get_action_test extends DokuWikiTest {
|
||||
|
||||
public function setUp() {
|
||||
public function setUp() : void {
|
||||
parent::setUp();
|
||||
global $ID;
|
||||
$ID = 'start'; // run all tests on the start page
|
||||
|
|
|
@ -80,7 +80,7 @@ content: @foo;';
|
|||
$this->csstest($in_css, $expected_css, $expected_less);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() : void {
|
||||
unlink($this->file);
|
||||
unlink($this->import);
|
||||
unset($this->file, $this->import);
|
||||
|
|
|
@ -6,7 +6,7 @@ class css_css_loadfile_test extends DokuWikiTest {
|
|||
|
||||
protected $file = '';
|
||||
|
||||
public function setUp() {
|
||||
public function setUp() : void {
|
||||
$this->file = tempnam(TMP_DIR, 'css');
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class css_css_loadfile_test extends DokuWikiTest {
|
|||
}
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() : void {
|
||||
unlink($this->file);
|
||||
unset($this->file);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
class fetch_imagetoken_test extends DokuWikiTest {
|
||||
|
||||
|
||||
private $media = 'wiki:dokuwiki-128.png';
|
||||
private $width = 200;
|
||||
private $height = 0;
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
// check we can carry out these tests
|
||||
if (!file_exists(mediaFN($this->media))) {
|
||||
$this->markTestSkipped('Source image required for test');
|
||||
|
|
|
@ -9,7 +9,7 @@ class fetch_statuscodes_external_test extends DokuWikiTest {
|
|||
private $width = 200;
|
||||
private $height = 0;
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
|
||||
header('X-Test: check headers working');
|
||||
$header_check = function_exists('xdebug_get_headers') ? xdebug_get_headers() : headers_list();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
class InttestsPluginsTest extends DokuWikiTest {
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
$this->pluginsEnabled = array(
|
||||
'testing'
|
||||
);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f43d3a0e0afb925e14da17a3b8323a29",
|
||||
"content-hash": "cd951937a517d2f058327d0429efe7ff",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aziraphale/email-address-validator",
|
||||
|
@ -298,16 +298,16 @@
|
|||
},
|
||||
{
|
||||
"name": "simplepie/simplepie",
|
||||
"version": "1.5.5",
|
||||
"version": "1.5.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/simplepie/simplepie.git",
|
||||
"reference": "ae49e2201b6da9c808e5dac437aca356a11831b4"
|
||||
"reference": "1c68e14ca3ac84346b6e6fe3c5eedf725d0f92c6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/ae49e2201b6da9c808e5dac437aca356a11831b4",
|
||||
"reference": "ae49e2201b6da9c808e5dac437aca356a11831b4",
|
||||
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/1c68e14ca3ac84346b6e6fe3c5eedf725d0f92c6",
|
||||
"reference": "1c68e14ca3ac84346b6e6fe3c5eedf725d0f92c6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -361,7 +361,7 @@
|
|||
"feeds",
|
||||
"rss"
|
||||
],
|
||||
"time": "2020-05-01T12:23:14+00:00"
|
||||
"time": "2020-10-14T07:17:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "splitbrain/php-archive",
|
||||
|
|
|
@ -44,7 +44,10 @@ class Save extends AbstractAction {
|
|||
throw new ActionException('edit');
|
||||
}
|
||||
//conflict check
|
||||
if($DATE != 0 && $INFO['meta']['date']['modified'] > $DATE) {
|
||||
if($DATE != 0
|
||||
&& isset($INFO['meta']['date']['modified'])
|
||||
&& $INFO['meta']['date']['modified'] > $DATE
|
||||
) {
|
||||
throw new ActionException('conflict');
|
||||
}
|
||||
|
||||
|
|
|
@ -178,10 +178,9 @@ class HTTPClient {
|
|||
// parse URL into bits
|
||||
$uri = parse_url($url);
|
||||
$server = $uri['host'];
|
||||
$path = $uri['path'];
|
||||
if(empty($path)) $path = '/';
|
||||
$path = !empty($uri['path']) ? $uri['path'] : '/';
|
||||
$uriPort = !empty($uri['port']) ? $uri['port'] : null;
|
||||
if(!empty($uri['query'])) $path .= '?'.$uri['query'];
|
||||
if(!empty($uri['port'])) $port = $uri['port'];
|
||||
if(isset($uri['user'])) $this->user = $uri['user'];
|
||||
if(isset($uri['pass'])) $this->pass = $uri['pass'];
|
||||
|
||||
|
@ -194,7 +193,7 @@ class HTTPClient {
|
|||
$use_tls = $this->proxy_ssl;
|
||||
}else{
|
||||
$request_url = $path;
|
||||
if (!isset($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80;
|
||||
$port = $uriPort ?: ($uri['scheme'] == 'https' ? 443 : 80);
|
||||
$use_tls = ($uri['scheme'] == 'https');
|
||||
}
|
||||
|
||||
|
@ -209,8 +208,8 @@ class HTTPClient {
|
|||
|
||||
// prepare headers
|
||||
$headers = $this->headers;
|
||||
$headers['Host'] = $uri['host'];
|
||||
if(!empty($uri['port'])) $headers['Host'].= ':'.$uri['port'];
|
||||
$headers['Host'] = $uri['host']
|
||||
. ($uriPort ? ':' . $uriPort : '');
|
||||
$headers['User-Agent'] = $this->agent;
|
||||
$headers['Referer'] = $this->referer;
|
||||
|
||||
|
@ -370,10 +369,10 @@ class HTTPClient {
|
|||
// handle non-RFC-compliant relative redirects
|
||||
if (!preg_match('/^http/i', $this->resp_headers['location'])){
|
||||
if($this->resp_headers['location'][0] != '/'){
|
||||
$this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uri['port'].
|
||||
dirname($uri['path']).'/'.$this->resp_headers['location'];
|
||||
$this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uriPort.
|
||||
dirname($path).'/'.$this->resp_headers['location'];
|
||||
}else{
|
||||
$this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uri['port'].
|
||||
$this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uriPort.
|
||||
$this->resp_headers['location'];
|
||||
}
|
||||
}
|
||||
|
@ -511,7 +510,7 @@ class HTTPClient {
|
|||
if(!$this->useProxyForUrl($requesturl)) return false;
|
||||
$requestinfo = parse_url($requesturl);
|
||||
if($requestinfo['scheme'] != 'https') return false;
|
||||
if(!$requestinfo['port']) $requestinfo['port'] = 443;
|
||||
if(empty($requestinfo['port'])) $requestinfo['port'] = 443;
|
||||
|
||||
// build request
|
||||
$request = "CONNECT {$requestinfo['host']}:{$requestinfo['port']} HTTP/1.0".HTTP_NL;
|
||||
|
|
|
@ -92,7 +92,8 @@ class Api
|
|||
if ($args === null) {
|
||||
$args = array();
|
||||
}
|
||||
list($type, $pluginName, /* $call */) = explode('.', $method, 3);
|
||||
// Ensure we have at least one '.' in $method
|
||||
list($type, $pluginName, /* $call */) = explode('.', $method . '.', 3);
|
||||
if ($type === 'plugin') {
|
||||
return $this->callPlugin($pluginName, $method, $args);
|
||||
}
|
||||
|
@ -128,8 +129,9 @@ class Api
|
|||
if (!array_key_exists($method, $customCalls)) {
|
||||
throw new RemoteException('Method does not exist', -32603);
|
||||
}
|
||||
$customCall = $customCalls[$method];
|
||||
return $this->callPlugin($customCall[0], $customCall[1], $args);
|
||||
list($plugin, $method) = $customCalls[$method];
|
||||
$fullMethod = "plugin.$plugin.$method";
|
||||
return $this->callPlugin($plugin, $fullMethod, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,7 @@ function parseChangelogLine($line) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add's an entry to the changelog and saves the metadata for the page
|
||||
* Adds an entry to the changelog and saves the metadata for the page
|
||||
*
|
||||
* @param int $date Timestamp of the change
|
||||
* @param String $id Name of the affected page
|
||||
|
@ -94,12 +94,12 @@ function addLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extr
|
|||
$wasReverted = ($type===DOKU_CHANGE_TYPE_REVERT);
|
||||
// update metadata
|
||||
if (!$wasRemoved) {
|
||||
$oldmeta = p_read_metadata($id);
|
||||
$oldmeta = p_read_metadata($id)['persistent'];
|
||||
$meta = array();
|
||||
if (
|
||||
$wasCreated && (
|
||||
empty($oldmeta['persistent']['date']['created']) ||
|
||||
$oldmeta['persistent']['date']['created'] === $created
|
||||
empty($oldmeta['date']['created']) ||
|
||||
$oldmeta['date']['created'] === $created
|
||||
)
|
||||
){
|
||||
// newly created
|
||||
|
@ -108,11 +108,11 @@ function addLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', $extr
|
|||
$meta['creator'] = isset($INFO) ? $INFO['userinfo']['name'] : null;
|
||||
$meta['user'] = $user;
|
||||
}
|
||||
} elseif (($wasCreated || $wasReverted) && !empty($oldmeta['persistent']['date']['created'])) {
|
||||
} elseif (($wasCreated || $wasReverted) && !empty($oldmeta['date']['created'])) {
|
||||
// re-created / restored
|
||||
$meta['date']['created'] = $oldmeta['persistent']['date']['created'];
|
||||
$meta['date']['created'] = $oldmeta['date']['created'];
|
||||
$meta['date']['modified'] = $created; // use the files ctime here
|
||||
$meta['creator'] = $oldmeta['persistent']['creator'];
|
||||
$meta['creator'] = isset($oldmeta['creator']) ? $oldmeta['creator'] : null;
|
||||
if ($user) $meta['contributor'][$user] = isset($INFO) ? $INFO['userinfo']['name'] : null;
|
||||
} elseif (!$minor) { // non-minor modification
|
||||
$meta['date']['modified'] = $date;
|
||||
|
|
656
inc/cli.php
656
inc/cli.php
|
@ -1,656 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class DokuCLI
|
||||
*
|
||||
* All DokuWiki commandline scripts should inherit from this class and implement the abstract methods.
|
||||
*
|
||||
* @deprecated 2017-11-10
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
abstract class DokuCLI {
|
||||
/** @var string the executed script itself */
|
||||
protected $bin;
|
||||
/** @var DokuCLI_Options the option parser */
|
||||
protected $options;
|
||||
/** @var DokuCLI_Colors */
|
||||
public $colors;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* Initialize the arguments, set up helper classes and set up the CLI environment
|
||||
*/
|
||||
public function __construct() {
|
||||
set_exception_handler(array($this, 'fatal'));
|
||||
|
||||
$this->options = new DokuCLI_Options();
|
||||
$this->colors = new DokuCLI_Colors();
|
||||
|
||||
dbg_deprecated('use \splitbrain\phpcli\CLI instead');
|
||||
$this->error('DokuCLI is deprecated, use \splitbrain\phpcli\CLI instead.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register options and arguments on the given $options object
|
||||
*
|
||||
* @param DokuCLI_Options $options
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function setup(DokuCLI_Options $options);
|
||||
|
||||
/**
|
||||
* Your main program
|
||||
*
|
||||
* Arguments and options have been parsed when this is run
|
||||
*
|
||||
* @param DokuCLI_Options $options
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function main(DokuCLI_Options $options);
|
||||
|
||||
/**
|
||||
* Execute the CLI program
|
||||
*
|
||||
* Executes the setup() routine, adds default options, initiate the options parsing and argument checking
|
||||
* and finally executes main()
|
||||
*/
|
||||
public function run() {
|
||||
if('cli' != php_sapi_name()) throw new DokuCLI_Exception('This has to be run from the command line');
|
||||
|
||||
// setup
|
||||
$this->setup($this->options);
|
||||
$this->options->registerOption(
|
||||
'no-colors',
|
||||
'Do not use any colors in output. Useful when piping output to other tools or files.'
|
||||
);
|
||||
$this->options->registerOption(
|
||||
'help',
|
||||
'Display this help screen and exit immediately.',
|
||||
'h'
|
||||
);
|
||||
|
||||
// parse
|
||||
$this->options->parseOptions();
|
||||
|
||||
// handle defaults
|
||||
if($this->options->getOpt('no-colors')) {
|
||||
$this->colors->disable();
|
||||
}
|
||||
if($this->options->getOpt('help')) {
|
||||
echo $this->options->help();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// check arguments
|
||||
$this->options->checkArguments();
|
||||
|
||||
// execute
|
||||
$this->main($this->options);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits the program on a fatal error
|
||||
*
|
||||
* @param Exception|string $error either an exception or an error message
|
||||
*/
|
||||
public function fatal($error) {
|
||||
$code = 0;
|
||||
if(is_object($error) && is_a($error, 'Exception')) {
|
||||
/** @var Exception $error */
|
||||
$code = $error->getCode();
|
||||
$error = $error->getMessage();
|
||||
}
|
||||
if(!$code) $code = DokuCLI_Exception::E_ANY;
|
||||
|
||||
$this->error($error);
|
||||
exit($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an error message
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function error($string) {
|
||||
$this->colors->ptln("E: $string", 'red', STDERR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a success message
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function success($string) {
|
||||
$this->colors->ptln("S: $string", 'green', STDERR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an info message
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function info($string) {
|
||||
$this->colors->ptln("I: $string", 'cyan', STDERR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class DokuCLI_Colors
|
||||
*
|
||||
* Handles color output on (Linux) terminals
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
class DokuCLI_Colors {
|
||||
/** @var array known color names */
|
||||
protected $colors = array(
|
||||
'reset' => "\33[0m",
|
||||
'black' => "\33[0;30m",
|
||||
'darkgray' => "\33[1;30m",
|
||||
'blue' => "\33[0;34m",
|
||||
'lightblue' => "\33[1;34m",
|
||||
'green' => "\33[0;32m",
|
||||
'lightgreen' => "\33[1;32m",
|
||||
'cyan' => "\33[0;36m",
|
||||
'lightcyan' => "\33[1;36m",
|
||||
'red' => "\33[0;31m",
|
||||
'lightred' => "\33[1;31m",
|
||||
'purple' => "\33[0;35m",
|
||||
'lightpurple' => "\33[1;35m",
|
||||
'brown' => "\33[0;33m",
|
||||
'yellow' => "\33[1;33m",
|
||||
'lightgray' => "\33[0;37m",
|
||||
'white' => "\33[1;37m",
|
||||
);
|
||||
|
||||
/** @var bool should colors be used? */
|
||||
protected $enabled = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Tries to disable colors for non-terminals
|
||||
*/
|
||||
public function __construct() {
|
||||
if(function_exists('posix_isatty') && !posix_isatty(STDOUT)) {
|
||||
$this->enabled = false;
|
||||
return;
|
||||
}
|
||||
if(!getenv('TERM')) {
|
||||
$this->enabled = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* enable color output
|
||||
*/
|
||||
public function enable() {
|
||||
$this->enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* disable color output
|
||||
*/
|
||||
public function disable() {
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function to print a line in a given color
|
||||
*
|
||||
* @param string $line
|
||||
* @param string $color
|
||||
* @param resource $channel
|
||||
*/
|
||||
public function ptln($line, $color, $channel = STDOUT) {
|
||||
$this->set($color);
|
||||
fwrite($channel, rtrim($line)."\n");
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given color for consecutive output
|
||||
*
|
||||
* @param string $color one of the supported color names
|
||||
* @throws DokuCLI_Exception
|
||||
*/
|
||||
public function set($color) {
|
||||
if(!$this->enabled) return;
|
||||
if(!isset($this->colors[$color])) throw new DokuCLI_Exception("No such color $color");
|
||||
echo $this->colors[$color];
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the terminal color
|
||||
*/
|
||||
public function reset() {
|
||||
$this->set('reset');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class DokuCLI_Options
|
||||
*
|
||||
* Parses command line options passed to the CLI script. Allows CLI scripts to easily register all accepted options and
|
||||
* commands and even generates a help text from this setup.
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
class DokuCLI_Options {
|
||||
/** @var array keeps the list of options to parse */
|
||||
protected $setup;
|
||||
|
||||
/** @var array store parsed options */
|
||||
protected $options = array();
|
||||
|
||||
/** @var string current parsed command if any */
|
||||
protected $command = '';
|
||||
|
||||
/** @var array passed non-option arguments */
|
||||
public $args = array();
|
||||
|
||||
/** @var string the executed script */
|
||||
protected $bin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->setup = array(
|
||||
'' => array(
|
||||
'opts' => array(),
|
||||
'args' => array(),
|
||||
'help' => ''
|
||||
)
|
||||
); // default command
|
||||
|
||||
$this->args = $this->readPHPArgv();
|
||||
$this->bin = basename(array_shift($this->args));
|
||||
|
||||
$this->options = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the help text for the tool itself
|
||||
*
|
||||
* @param string $help
|
||||
*/
|
||||
public function setHelp($help) {
|
||||
$this->setup['']['help'] = $help;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the names of arguments for help generation and number checking
|
||||
*
|
||||
* This has to be called in the order arguments are expected
|
||||
*
|
||||
* @param string $arg argument name (just for help)
|
||||
* @param string $help help text
|
||||
* @param bool $required is this a required argument
|
||||
* @param string $command if theses apply to a sub command only
|
||||
* @throws DokuCLI_Exception
|
||||
*/
|
||||
public function registerArgument($arg, $help, $required = true, $command = '') {
|
||||
if(!isset($this->setup[$command])) throw new DokuCLI_Exception("Command $command not registered");
|
||||
|
||||
$this->setup[$command]['args'][] = array(
|
||||
'name' => $arg,
|
||||
'help' => $help,
|
||||
'required' => $required
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This registers a sub command
|
||||
*
|
||||
* Sub commands have their own options and use their own function (not main()).
|
||||
*
|
||||
* @param string $command
|
||||
* @param string $help
|
||||
* @throws DokuCLI_Exception
|
||||
*/
|
||||
public function registerCommand($command, $help) {
|
||||
if(isset($this->setup[$command])) throw new DokuCLI_Exception("Command $command already registered");
|
||||
|
||||
$this->setup[$command] = array(
|
||||
'opts' => array(),
|
||||
'args' => array(),
|
||||
'help' => $help
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an option for option parsing and help generation
|
||||
*
|
||||
* @param string $long multi character option (specified with --)
|
||||
* @param string $help help text for this option
|
||||
* @param string|null $short one character option (specified with -)
|
||||
* @param bool|string $needsarg does this option require an argument? give it a name here
|
||||
* @param string $command what command does this option apply to
|
||||
* @throws DokuCLI_Exception
|
||||
*/
|
||||
public function registerOption($long, $help, $short = null, $needsarg = false, $command = '') {
|
||||
if(!isset($this->setup[$command])) throw new DokuCLI_Exception("Command $command not registered");
|
||||
|
||||
$this->setup[$command]['opts'][$long] = array(
|
||||
'needsarg' => $needsarg,
|
||||
'help' => $help,
|
||||
'short' => $short
|
||||
);
|
||||
|
||||
if($short) {
|
||||
if(strlen($short) > 1) throw new DokuCLI_Exception("Short options should be exactly one ASCII character");
|
||||
|
||||
$this->setup[$command]['short'][$short] = $long;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the actual number of arguments against the required number
|
||||
*
|
||||
* Throws an exception if arguments are missing. Called from parseOptions()
|
||||
*
|
||||
* @throws DokuCLI_Exception
|
||||
*/
|
||||
public function checkArguments() {
|
||||
$argc = count($this->args);
|
||||
|
||||
$req = 0;
|
||||
foreach($this->setup[$this->command]['args'] as $arg) {
|
||||
if(!$arg['required']) break; // last required arguments seen
|
||||
$req++;
|
||||
}
|
||||
|
||||
if($req > $argc) throw new DokuCLI_Exception("Not enough arguments", DokuCLI_Exception::E_OPT_ARG_REQUIRED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given arguments for known options and command
|
||||
*
|
||||
* The given $args array should NOT contain the executed file as first item anymore! The $args
|
||||
* array is stripped from any options and possible command. All found otions can be accessed via the
|
||||
* getOpt() function
|
||||
*
|
||||
* Note that command options will overwrite any global options with the same name
|
||||
*
|
||||
* @throws DokuCLI_Exception
|
||||
*/
|
||||
public function parseOptions() {
|
||||
$non_opts = array();
|
||||
|
||||
$argc = count($this->args);
|
||||
for($i = 0; $i < $argc; $i++) {
|
||||
$arg = $this->args[$i];
|
||||
|
||||
// The special element '--' means explicit end of options. Treat the rest of the arguments as non-options
|
||||
// and end the loop.
|
||||
if($arg == '--') {
|
||||
$non_opts = array_merge($non_opts, array_slice($this->args, $i + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
// '-' is stdin - a normal argument
|
||||
if($arg == '-') {
|
||||
$non_opts = array_merge($non_opts, array_slice($this->args, $i));
|
||||
break;
|
||||
}
|
||||
|
||||
// first non-option
|
||||
if($arg[0] != '-') {
|
||||
$non_opts = array_merge($non_opts, array_slice($this->args, $i));
|
||||
break;
|
||||
}
|
||||
|
||||
// long option
|
||||
if(strlen($arg) > 1 && $arg[1] == '-') {
|
||||
list($opt, $val) = explode('=', substr($arg, 2), 2);
|
||||
|
||||
if(!isset($this->setup[$this->command]['opts'][$opt])) {
|
||||
throw new DokuCLI_Exception("No such option $arg", DokuCLI_Exception::E_UNKNOWN_OPT);
|
||||
}
|
||||
|
||||
// argument required?
|
||||
if($this->setup[$this->command]['opts'][$opt]['needsarg']) {
|
||||
if(is_null($val) && $i + 1 < $argc && !preg_match('/^--?[\w]/', $this->args[$i + 1])) {
|
||||
$val = $this->args[++$i];
|
||||
}
|
||||
if(is_null($val)) {
|
||||
throw new DokuCLI_Exception("Option $arg requires an argument", DokuCLI_Exception::E_OPT_ARG_REQUIRED);
|
||||
}
|
||||
$this->options[$opt] = $val;
|
||||
} else {
|
||||
$this->options[$opt] = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// short option
|
||||
$opt = substr($arg, 1);
|
||||
if(!isset($this->setup[$this->command]['short'][$opt])) {
|
||||
throw new DokuCLI_Exception("No such option $arg", DokuCLI_Exception::E_UNKNOWN_OPT);
|
||||
} else {
|
||||
$opt = $this->setup[$this->command]['short'][$opt]; // store it under long name
|
||||
}
|
||||
|
||||
// argument required?
|
||||
if($this->setup[$this->command]['opts'][$opt]['needsarg']) {
|
||||
$val = null;
|
||||
if($i + 1 < $argc && !preg_match('/^--?[\w]/', $this->args[$i + 1])) {
|
||||
$val = $this->args[++$i];
|
||||
}
|
||||
if(is_null($val)) {
|
||||
throw new DokuCLI_Exception("Option $arg requires an argument", DokuCLI_Exception::E_OPT_ARG_REQUIRED);
|
||||
}
|
||||
$this->options[$opt] = $val;
|
||||
} else {
|
||||
$this->options[$opt] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// parsing is now done, update args array
|
||||
$this->args = $non_opts;
|
||||
|
||||
// if not done yet, check if first argument is a command and reexecute argument parsing if it is
|
||||
if(!$this->command && $this->args && isset($this->setup[$this->args[0]])) {
|
||||
// it is a command!
|
||||
$this->command = array_shift($this->args);
|
||||
$this->parseOptions(); // second pass
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the given option
|
||||
*
|
||||
* Please note that all options are accessed by their long option names regardless of how they were
|
||||
* specified on commandline.
|
||||
*
|
||||
* Can only be used after parseOptions() has been run
|
||||
*
|
||||
* @param string $option
|
||||
* @param bool|string $default what to return if the option was not set
|
||||
* @return bool|string
|
||||
*/
|
||||
public function getOpt($option, $default = false) {
|
||||
if(isset($this->options[$option])) return $this->options[$option];
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the found command if any
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCmd() {
|
||||
return $this->command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a help screen from the available options. You may want to call it from -h or on error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function help() {
|
||||
$text = '';
|
||||
|
||||
$hascommands = (count($this->setup) > 1);
|
||||
foreach($this->setup as $command => $config) {
|
||||
$hasopts = (bool) $this->setup[$command]['opts'];
|
||||
$hasargs = (bool) $this->setup[$command]['args'];
|
||||
|
||||
if(!$command) {
|
||||
$text .= 'USAGE: '.$this->bin;
|
||||
} else {
|
||||
$text .= "\n$command";
|
||||
}
|
||||
|
||||
if($hasopts) $text .= ' <OPTIONS>';
|
||||
|
||||
foreach($this->setup[$command]['args'] as $arg) {
|
||||
if($arg['required']) {
|
||||
$text .= ' <'.$arg['name'].'>';
|
||||
} else {
|
||||
$text .= ' [<'.$arg['name'].'>]';
|
||||
}
|
||||
}
|
||||
$text .= "\n";
|
||||
|
||||
if($this->setup[$command]['help']) {
|
||||
$text .= "\n";
|
||||
$text .= $this->tableFormat(
|
||||
array(2, 72),
|
||||
array('', $this->setup[$command]['help']."\n")
|
||||
);
|
||||
}
|
||||
|
||||
if($hasopts) {
|
||||
$text .= "\n OPTIONS\n\n";
|
||||
foreach($this->setup[$command]['opts'] as $long => $opt) {
|
||||
|
||||
$name = '';
|
||||
if($opt['short']) {
|
||||
$name .= '-'.$opt['short'];
|
||||
if($opt['needsarg']) $name .= ' <'.$opt['needsarg'].'>';
|
||||
$name .= ', ';
|
||||
}
|
||||
$name .= "--$long";
|
||||
if($opt['needsarg']) $name .= ' <'.$opt['needsarg'].'>';
|
||||
|
||||
$text .= $this->tableFormat(
|
||||
array(2, 20, 52),
|
||||
array('', $name, $opt['help'])
|
||||
);
|
||||
$text .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if($hasargs) {
|
||||
$text .= "\n";
|
||||
foreach($this->setup[$command]['args'] as $arg) {
|
||||
$name = '<'.$arg['name'].'>';
|
||||
|
||||
$text .= $this->tableFormat(
|
||||
array(2, 20, 52),
|
||||
array('', $name, $arg['help'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if($command == '' && $hascommands) {
|
||||
$text .= "\nThis tool accepts a command as first parameter as outlined below:\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely read the $argv PHP array across different PHP configurations.
|
||||
* Will take care on register_globals and register_argc_argv ini directives
|
||||
*
|
||||
* @throws DokuCLI_Exception
|
||||
* @return array the $argv PHP array or PEAR error if not registered
|
||||
*/
|
||||
private function readPHPArgv() {
|
||||
global $argv;
|
||||
if(!is_array($argv)) {
|
||||
if(!@is_array($_SERVER['argv'])) {
|
||||
if(!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) {
|
||||
throw new DokuCLI_Exception(
|
||||
"Could not read cmd args (register_argc_argv=Off?)",
|
||||
DOKU_CLI_OPTS_ARG_READ
|
||||
);
|
||||
}
|
||||
return $GLOBALS['HTTP_SERVER_VARS']['argv'];
|
||||
}
|
||||
return $_SERVER['argv'];
|
||||
}
|
||||
return $argv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays text in multiple word wrapped columns
|
||||
*
|
||||
* @param int[] $widths list of column widths (in characters)
|
||||
* @param string[] $texts list of texts for each column
|
||||
* @return string
|
||||
*/
|
||||
private function tableFormat($widths, $texts) {
|
||||
$wrapped = array();
|
||||
$maxlen = 0;
|
||||
|
||||
foreach($widths as $col => $width) {
|
||||
$wrapped[$col] = explode("\n", wordwrap($texts[$col], $width - 1, "\n", true)); // -1 char border
|
||||
$len = count($wrapped[$col]);
|
||||
if($len > $maxlen) $maxlen = $len;
|
||||
|
||||
}
|
||||
|
||||
$out = '';
|
||||
for($i = 0; $i < $maxlen; $i++) {
|
||||
foreach($widths as $col => $width) {
|
||||
if(isset($wrapped[$col][$i])) {
|
||||
$val = $wrapped[$col][$i];
|
||||
} else {
|
||||
$val = '';
|
||||
}
|
||||
$out .= sprintf('%-'.$width.'s', $val);
|
||||
}
|
||||
$out .= "\n";
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class DokuCLI_Exception
|
||||
*
|
||||
* The code is used as exit code for the CLI tool. This should probably be extended. Many cases just fall back to the
|
||||
* E_ANY code.
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
class DokuCLI_Exception extends Exception {
|
||||
const E_ANY = -1; // no error code specified
|
||||
const E_UNKNOWN_OPT = 1; //Unrecognized option
|
||||
const E_OPT_ARG_REQUIRED = 2; //Option requires argument
|
||||
const E_OPT_ARG_DENIED = 3; //Option not allowed argument
|
||||
const E_OPT_ABIGUOUS = 4; //Option abiguous
|
||||
const E_ARG_READ = 5; //Could not read argv
|
||||
|
||||
/**
|
||||
* @param string $message The Exception message to throw.
|
||||
* @param int $code The Exception code
|
||||
* @param Exception $previous The previous exception used for the exception chaining.
|
||||
*/
|
||||
public function __construct($message = "", $code = 0, Exception $previous = null) {
|
||||
if(!$code) $code = DokuCLI_Exception::E_ANY;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
|
@ -822,7 +822,7 @@ function clientIP($single = false) {
|
|||
if(empty($ip[$i])) unset($ip[$i]);
|
||||
}
|
||||
$ip = array_values(array_unique($ip));
|
||||
if(!$ip[0]) $ip[0] = '0.0.0.0'; // for some strange reason we don't have a IP
|
||||
if(empty($ip) || !$ip[0]) $ip[0] = '0.0.0.0'; // for some strange reason we don't have a IP
|
||||
|
||||
if(!$single) return join(',', $ip);
|
||||
|
||||
|
|
|
@ -80,7 +80,9 @@ function _ft_pageSearch(&$data) {
|
|||
case 'W-:':
|
||||
case 'W_:': // word
|
||||
$word = substr($token, 3);
|
||||
$stack[] = (array) $lookup[$word];
|
||||
if(isset($lookup[$word])) {
|
||||
$stack[] = (array)$lookup[$word];
|
||||
}
|
||||
break;
|
||||
case 'P+:':
|
||||
case 'P-:': // phrase
|
||||
|
|
|
@ -79,11 +79,6 @@ function load_autoload($name){
|
|||
'Doku_Renderer_code' => DOKU_INC.'inc/parser/code.php',
|
||||
'Doku_Renderer_xhtmlsummary' => DOKU_INC.'inc/parser/xhtmlsummary.php',
|
||||
'Doku_Renderer_metadata' => DOKU_INC.'inc/parser/metadata.php',
|
||||
|
||||
'DokuCLI' => DOKU_INC.'inc/cli.php',
|
||||
'DokuCLI_Options' => DOKU_INC.'inc/cli.php',
|
||||
'DokuCLI_Colors' => DOKU_INC.'inc/cli.php',
|
||||
|
||||
);
|
||||
|
||||
if(isset($classes[$name])){
|
||||
|
|
|
@ -889,7 +889,7 @@ abstract class Doku_Renderer extends Plugin {
|
|||
$url = $url.rawurlencode($reference);
|
||||
}
|
||||
//handle as wiki links
|
||||
if($url[0] === ':') {
|
||||
if($url && $url[0] === ':') {
|
||||
$urlparam = null;
|
||||
$id = $url;
|
||||
if (strpos($url, '?') !== false) {
|
||||
|
|
|
@ -1888,7 +1888,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
|
|||
$url = ml($file, '', true, '&');
|
||||
$linkType = 'internalmedia';
|
||||
}
|
||||
$title = $atts['title'] ? $atts['title'] : $this->_xmlEntities(\dokuwiki\Utf8\PhpString::basename(noNS($file)));
|
||||
$title = !empty($atts['title'])
|
||||
? $atts['title']
|
||||
: $this->_xmlEntities(\dokuwiki\Utf8\PhpString::basename(noNS($file)));
|
||||
|
||||
$out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL;
|
||||
// alternative content (just a link to the file)
|
||||
|
|
|
@ -411,7 +411,7 @@ function p_set_metadata($id, $data, $render=false, $persistent=true){
|
|||
function p_purge_metadata($id) {
|
||||
$meta = p_read_metadata($id);
|
||||
foreach($meta['current'] as $key => $value) {
|
||||
if(is_array($meta[$key])) {
|
||||
if(isset($meta[$key]) && is_array($meta[$key])) {
|
||||
$meta['current'][$key] = array();
|
||||
} else {
|
||||
$meta['current'][$key] = '';
|
||||
|
@ -463,7 +463,9 @@ function p_save_metadata($id, $meta) {
|
|||
global $cache_metadata, $INFO;
|
||||
|
||||
if (isset($cache_metadata[$id])) $cache_metadata[$id] = $meta;
|
||||
if (!empty($INFO) && ($id == $INFO['id'])) { $INFO['meta'] = $meta['current']; }
|
||||
if (!empty($INFO) && isset($INFO['id']) && ($id == $INFO['id'])) {
|
||||
$INFO['meta'] = $meta['current'];
|
||||
}
|
||||
|
||||
return io_saveFile(metaFN($id, '.meta'), serialize($meta));
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ function tpl_metaheaders($alt = true) {
|
|||
}
|
||||
}
|
||||
|
||||
// setup robot tags apropriate for different modes
|
||||
// setup robot tags appropriate for different modes
|
||||
if(($ACT == 'show' || $ACT == 'export_xhtml') && !$REV) {
|
||||
if($INFO['exists']) {
|
||||
//delay indexing:
|
||||
|
@ -1008,11 +1008,13 @@ function tpl_img_getTag($tags, $alt = '', $src = null) {
|
|||
global $SRC;
|
||||
|
||||
if(is_null($src)) $src = $SRC;
|
||||
if(is_null($src)) return $alt;
|
||||
|
||||
static $meta = null;
|
||||
if(is_null($meta)) $meta = new JpegMeta($src);
|
||||
if($meta === false) return $alt;
|
||||
$info = cleanText($meta->getField($tags));
|
||||
$meta = null; // garbage collect and close any file handles. See #3404
|
||||
if($info == false) return $alt;
|
||||
return $info;
|
||||
}
|
||||
|
@ -1067,7 +1069,7 @@ function tpl_get_img_meta() {
|
|||
if (!empty($tag[0])) {
|
||||
$t = array($tag[0]);
|
||||
}
|
||||
if(is_array($tag[3])) {
|
||||
if(isset($tag[3]) && is_array($tag[3])) {
|
||||
$t = array_merge($t,$tag[3]);
|
||||
}
|
||||
$value = tpl_img_getTag($t);
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
use dokuwiki\Extension\Event;
|
||||
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');
|
||||
define('DOKU_MEDIADETAIL',1);
|
||||
if(!defined('DOKU_MEDIADETAIL')) define('DOKU_MEDIADETAIL',1);
|
||||
|
||||
// define all DokuWiki globals here (needed within test requests but also helps to keep track)
|
||||
global $INPUT, $IMG, $ID, $REV, $SRC, $ERROR, $AUTH;
|
||||
|
||||
require_once(DOKU_INC.'inc/init.php');
|
||||
|
||||
$IMG = getID('media');
|
||||
|
|
|
@ -15,7 +15,7 @@ class mysql_plugin_authpdo_test extends DokuWikiTest {
|
|||
protected $pass = '';
|
||||
protected $port = '';
|
||||
|
||||
public function setUp() {
|
||||
public function setUp() : void {
|
||||
parent::setUp();
|
||||
$configuration = DOKU_UNITTEST . "{$this->driver}.conf.php";
|
||||
if(!file_exists($configuration)) {
|
||||
|
@ -34,7 +34,7 @@ class mysql_plugin_authpdo_test extends DokuWikiTest {
|
|||
*
|
||||
* it might still be there if something went wrong
|
||||
*/
|
||||
public function tearDown() {
|
||||
public function tearDown() : void {
|
||||
parent::tearDown();
|
||||
$this->dropDatabase();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class sqlite_plugin_authpdo_test extends DokuWikiTest {
|
|||
$this->assertTrue(true); // avoid being marked as risky for having no assertion
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
public function setUp() : void {
|
||||
parent::setUp();
|
||||
$this->dbfile = tempnam('/tmp/', 'pluginpdo_test_');
|
||||
copy(__DIR__ . '/test.sqlite3', $this->dbfile);
|
||||
|
@ -85,7 +85,7 @@ class sqlite_plugin_authpdo_test extends DokuWikiTest {
|
|||
$conf['plugin']['authpdo']['leave-group'] = 'DELETE FROM member WHERE uid = :uid AND gid = :gid';
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown() : void {
|
||||
parent::tearDown();
|
||||
unlink($this->dbfile);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class helper_plugin_authplain_escaping_test extends DokuWikiTest {
|
|||
$this->auth = new auth_plugin_authplainharness();
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
global $config_cascade;
|
||||
parent::setUp();
|
||||
$name = $config_cascade['plainauth.users']['default'];
|
||||
|
@ -32,7 +32,7 @@ class helper_plugin_authplain_escaping_test extends DokuWikiTest {
|
|||
$this->reloadUsers();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
function tearDown() : void {
|
||||
global $config_cascade;
|
||||
parent::tearDown();
|
||||
$name = $config_cascade['plainauth.users']['default'];
|
||||
|
|
|
@ -16,7 +16,7 @@ class userdata_test extends DokuWikiTest
|
|||
* Load auth with test conf
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
global $config_cascade;
|
||||
|
|
|
@ -13,7 +13,7 @@ abstract class AbstractSettingTest extends \DokuWikiTest {
|
|||
* Sets up the proper class to test based on the test's class name
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp() : void {
|
||||
parent::setUp();
|
||||
$class = get_class($this);
|
||||
$class = substr($class, strrpos($class, '\\') + 1, -4);
|
||||
|
|
|
@ -110,7 +110,7 @@ class Writer {
|
|||
'/*',
|
||||
' * ' . $this->header,
|
||||
' * Auto-generated by config plugin',
|
||||
' * Run for user: ' . $_SERVER['REMOTE_USER'],
|
||||
' * Run for user: ' . (isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : 'Unknown'),
|
||||
' * Date: ' . date('r'),
|
||||
' */',
|
||||
'',
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
class TestingDummyPluginIntegrationTest extends DokuWikiTest {
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
$this->pluginsEnabled = array(
|
||||
'testing'
|
||||
);
|
||||
|
|
|
@ -12,7 +12,7 @@ class plugin_usermanager_csv_export_test extends DokuWikiTest {
|
|||
|
||||
protected $usermanager;
|
||||
|
||||
function setUp() {
|
||||
function setUp() : void {
|
||||
$this->usermanager = new admin_mock_usermanager();
|
||||
parent::setUp();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class plugin_usermanager_csv_import_test extends DokuWikiTest
|
|||
protected $usermanager;
|
||||
protected $importfile;
|
||||
|
||||
public function setUp()
|
||||
public function setUp() : void
|
||||
{
|
||||
$this->importfile = tempnam(TMP_DIR, 'csv');
|
||||
|
||||
|
@ -39,7 +39,7 @@ class plugin_usermanager_csv_import_test extends DokuWikiTest
|
|||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown() : void
|
||||
{
|
||||
$_FILES = $this->old_files;
|
||||
parent::tearDown();
|
||||
|
|
|
@ -301,17 +301,17 @@
|
|||
},
|
||||
{
|
||||
"name": "simplepie/simplepie",
|
||||
"version": "1.5.5",
|
||||
"version_normalized": "1.5.5.0",
|
||||
"version": "1.5.6",
|
||||
"version_normalized": "1.5.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/simplepie/simplepie.git",
|
||||
"reference": "ae49e2201b6da9c808e5dac437aca356a11831b4"
|
||||
"reference": "1c68e14ca3ac84346b6e6fe3c5eedf725d0f92c6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/ae49e2201b6da9c808e5dac437aca356a11831b4",
|
||||
"reference": "ae49e2201b6da9c808e5dac437aca356a11831b4",
|
||||
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/1c68e14ca3ac84346b6e6fe3c5eedf725d0f92c6",
|
||||
"reference": "1c68e14ca3ac84346b6e6fe3c5eedf725d0f92c6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -330,7 +330,7 @@
|
|||
"ext-mbstring": "",
|
||||
"mf2/mf2": "Microformat module that allows for parsing HTML for microformats"
|
||||
},
|
||||
"time": "2020-05-01T12:23:14+00:00",
|
||||
"time": "2020-10-14T07:17:22+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
|
|
@ -91,7 +91,7 @@ Authors and contributors
|
|||
* [Michael Shipley][] (Submitter of patches, support)
|
||||
* [Steve Minutillo][] (Submitter of patches)
|
||||
|
||||
[Malcolm Blaney]: https://unicyclic.com/mal
|
||||
[Malcolm Blaney]: https://mblaney.xyz
|
||||
[Ryan McCue]: http://ryanmccue.info
|
||||
[Ryan Parman]: http://ryanparman.com
|
||||
[Sam Sneddon]: https://gsnedders.com
|
||||
|
|
|
@ -374,7 +374,7 @@ class idna_convert
|
|||
$delim_pos = strrpos($encoded, '-');
|
||||
if ($delim_pos > strlen($this->_punycode_prefix)) {
|
||||
for ($k = strlen($this->_punycode_prefix); $k < $delim_pos; ++$k) {
|
||||
$decoded[] = ord($encoded{$k});
|
||||
$decoded[] = ord($encoded[$k]);
|
||||
}
|
||||
} else {
|
||||
$decoded = array();
|
||||
|
@ -390,7 +390,7 @@ class idna_convert
|
|||
|
||||
for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
|
||||
for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) {
|
||||
$digit = $this->_decode_digit($encoded{$enco_idx++});
|
||||
$digit = $this->_decode_digit($encoded[$enco_idx++]);
|
||||
$idx += $digit * $w;
|
||||
$t = ($k <= $bias) ? $this->_tmin :
|
||||
(($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
|
||||
|
@ -793,7 +793,7 @@ class idna_convert
|
|||
$mode = 'next';
|
||||
$test = 'none';
|
||||
for ($k = 0; $k < $inp_len; ++$k) {
|
||||
$v = ord($input{$k}); // Extract byte from input string
|
||||
$v = ord($input[$k]); // Extract byte from input string
|
||||
|
||||
if ($v < 128) { // We found an ASCII char - put into stirng as is
|
||||
$output[$out_len] = $v;
|
||||
|
@ -932,7 +932,7 @@ class idna_convert
|
|||
$out_len++;
|
||||
$output[$out_len] = 0;
|
||||
}
|
||||
$output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
|
||||
$output[$out_len] += ord($input[$i]) << (8 * (3 - ($i % 4) ) );
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @package SimplePie
|
||||
* @version 1.5.5
|
||||
* @version 1.5.6
|
||||
* @copyright 2004-2017 Ryan Parman, Sam Sneddon, Ryan McCue
|
||||
* @author Ryan Parman
|
||||
* @author Sam Sneddon
|
||||
|
@ -50,7 +50,7 @@ define('SIMPLEPIE_NAME', 'SimplePie');
|
|||
/**
|
||||
* SimplePie Version
|
||||
*/
|
||||
define('SIMPLEPIE_VERSION', '1.5.5');
|
||||
define('SIMPLEPIE_VERSION', '1.5.6');
|
||||
|
||||
/**
|
||||
* SimplePie Build
|
||||
|
|
|
@ -150,7 +150,7 @@ class SimplePie_Content_Type_Sniffer
|
|||
}
|
||||
elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body))
|
||||
{
|
||||
return 'application/octect-stream';
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
|
||||
return 'text/plain';
|
||||
|
|
|
@ -109,11 +109,6 @@ class SimplePie_File
|
|||
curl_setopt($fp, CURLOPT_REFERER, $url);
|
||||
curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
|
||||
curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
|
||||
if (!ini_get('open_basedir') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>='))
|
||||
{
|
||||
curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
|
||||
}
|
||||
foreach ($curl_options as $curl_param => $curl_value) {
|
||||
curl_setopt($fp, $curl_param, $curl_value);
|
||||
}
|
||||
|
@ -148,7 +143,7 @@ class SimplePie_File
|
|||
$this->redirects++;
|
||||
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
|
||||
$previousStatusCode = $this->status_code;
|
||||
$this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
|
||||
$this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options);
|
||||
$this->permanent_url = ($previousStatusCode == 301) ? $location : $url;
|
||||
return;
|
||||
}
|
||||
|
@ -233,7 +228,7 @@ class SimplePie_File
|
|||
$this->redirects++;
|
||||
$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
|
||||
$previousStatusCode = $this->status_code;
|
||||
$this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
|
||||
$this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen, $curl_options);
|
||||
$this->permanent_url = ($previousStatusCode == 301) ? $location : $url;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class SimplePie_Locator
|
|||
$this->registry = $registry;
|
||||
}
|
||||
|
||||
public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
|
||||
public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working = null)
|
||||
{
|
||||
if ($this->is_feed($this->file))
|
||||
{
|
||||
|
|
|
@ -364,11 +364,12 @@ class SimplePie_Misc
|
|||
}
|
||||
|
||||
// Check that the encoding is supported
|
||||
if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80")
|
||||
if (!in_array($input, mb_list_encodings()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!in_array($input, mb_list_encodings()))
|
||||
|
||||
if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue