Skip to content

Commit 7b394e8

Browse files
authored
Merge pull request #288 from michitux/librarian
First attempt at fixing compatibility with the Librarian release
2 parents 8c32b23 + 2d0534a commit 7b394e8

File tree

10 files changed

+120
-87
lines changed

10 files changed

+120
-87
lines changed

MoveResolver.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace dokuwiki\plugin\move;
4+
5+
use dokuwiki\File\Resolver;
6+
7+
/**
8+
* We need the "pure" resolver without any special handling for startpages or autoplurals
9+
*/
10+
class MoveResolver extends Resolver {
11+
}

_test/GeneralTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public function testPluginInfo(): void
3131
$this->assertArrayHasKey('url', $info);
3232

3333
$this->assertEquals('move', $info['base']);
34-
$this->assertRegExp('/^https?:\/\//', $info['url']);
34+
$this->assertMatchesRegularExpression('/^https?:\/\//', $info['url']);
3535
$this->assertTrue(mail_isvalid($info['email']));
36-
$this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
36+
$this->assertMatchesRegularExpression('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
3737
$this->assertTrue(false !== strtotime($info['date']));
3838
}
3939

_test/handler.test.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
<?php
2-
// must be run within Dokuwiki
3-
if(!defined('DOKU_INC')) die();
4-
5-
require_once(__DIR__ . '/../helper/handler.php');
62

73
/**
84
* Test cases for the move plugin
@@ -18,8 +14,7 @@ public function setUp(): void {
1814
}
1915

2016
public function test_relativeLink() {
21-
/** @var $handler helper_plugin_move_handler */
22-
$handler = plugin_load('helper', 'move_handler');
17+
$handler = new helper_plugin_move_handler();
2318
$handler->init('deep:namespace:page', 'used:to:be:here', array(), array(), array());
2419

2520
$tests = array(
@@ -40,8 +35,7 @@ public function test_relativeLink() {
4035
}
4136

4237
public function test_resolveMoves() {
43-
/** @var $handler helper_plugin_move_handler */
44-
$handler = plugin_load('helper', 'move_handler');
38+
$handler = new helper_plugin_move_handler();
4539
$handler->init(
4640
'deep:namespace:page',
4741
'used:to:be:here',

_test/namespace_move.test.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function test_move_wiki_namespace() {
6363
$this->assertSame(0, $plan->nextStep(),'done');
6464

6565
$this->assertFileExists(wikiFN('foo:dokuwiki'));
66-
$this->assertFileNotExists(wikiFN('wiki:syntax'));
66+
$this->assertFileDoesNotExist(wikiFN('wiki:syntax'));
6767
$this->assertFileExists(mediaFN('foo:dokuwiki-128.png'));
6868
}
6969

@@ -93,7 +93,7 @@ public function test_move_missing() {
9393
$this->assertSame(0, $plan->nextStep(),'done');
9494

9595
$this->assertFileExists(wikiFN('newspace:page'));
96-
$this->assertFileNotExists(wikiFN('oldspace:page'));
96+
$this->assertFileDoesNotExist(wikiFN('oldspace:page'));
9797

9898
$this->assertEquals('[[missing]]', rawWiki('newspace:page'));
9999
}
@@ -259,8 +259,8 @@ public function test_move_small_namespace_pages() {
259259

260260
$this->assertFileExists(wikiFN('newns:start'));
261261
$this->assertFileExists(wikiFN('newns:page'));
262-
$this->assertFileNotExists(wikiFN('oldns:start'));
263-
$this->assertFileNotExists(wikiFN('oldns:page'));
262+
$this->assertFileDoesNotExist(wikiFN('oldns:start'));
263+
$this->assertFileDoesNotExist(wikiFN('oldns:page'));
264264

265265
$this->assertSame('[[newns:start]] [[newns:page]] [[newns:missing]] [[missing]] [[page]]',rawWiki('newns:start'));
266266
$this->assertSame('[[newns:start]] [[newns:page]] [[newns:missing]] [[missing]] [[start]]',rawWiki('newns:page'));
@@ -300,7 +300,7 @@ public function test_move_small_namespace_media() {
300300
$this->assertSame(0, $plan->nextStep(), 'done');
301301

302302
$this->assertFileExists(mediaFN('newns:oldnsimage.png'));
303-
$this->assertFileNotExists(mediaFN('oldns:oldnsimage.png'));
303+
$this->assertFileDoesNotExist(mediaFN('oldns:oldnsimage.png'));
304304

305305
$this->assertSame('{{newns:oldnsimage.png}} {{newns:oldnsimage_missing.png}} {{image_missing.png}}',rawWiki('start'));
306306
}
@@ -338,7 +338,7 @@ public function test_move_small_namespace_media_affected() {
338338
$this->assertSame(0, $plan->nextStep(), 'done');
339339

340340
$this->assertFileExists(mediaFN('newns:oldnsimage.png'));
341-
$this->assertFileNotExists(mediaFN('oldns:oldnsimage.png'));
341+
$this->assertFileDoesNotExist(mediaFN('oldns:oldnsimage.png'));
342342

343343
$this->assertSame('{{newns:oldnsimage.png}} {{newns:oldnsimage_missing.png}} {{newns:oldnsimage_missing.png}} {{newns:oldnsimage.png}}',rawWiki('oldns:start'));
344344
}
@@ -384,7 +384,7 @@ public function test_move_small_namespace_combi() {
384384
$this->assertSame(0, $plan->nextStep(), 'done');
385385

386386
$this->assertFileExists(mediaFN('newns:oldnsimage.png'));
387-
$this->assertFileNotExists(mediaFN('oldns:oldnsimage.png'));
387+
$this->assertFileDoesNotExist(mediaFN('oldns:oldnsimage.png'));
388388

389389
$this->assertSame("[[newns:start]] [[newns:page]] [[newns:missing]]\n{{newns:oldnsimage.png}} {{newns:oldnsimage_missing.png}} {{oldnsimage_missing.png}}",rawWiki('start'));
390390
}
@@ -425,8 +425,8 @@ public function test_move_small_namespace_subscription_ns() {
425425

426426
$this->assertFileExists(wikiFN('newns:start'));
427427
$this->assertFileExists($newfilepath);
428-
$this->assertFileNotExists(wikiFN('subns:start'));
429-
$this->assertFileNotExists($oldfilepath);
428+
$this->assertFileDoesNotExist(wikiFN('subns:start'));
429+
$this->assertFileDoesNotExist($oldfilepath);
430430

431431
$this->assertSame($subscription,file_get_contents($newfilepath));
432432

@@ -468,8 +468,8 @@ public function test_move_small_namespace_subscription_page() {
468468

469469
$this->assertFileExists(wikiFN('newns:start'));
470470
$this->assertFileExists($newfilepath);
471-
$this->assertFileNotExists(wikiFN('subns:start'));
472-
$this->assertFileNotExists($oldfilepath);
471+
$this->assertFileDoesNotExist(wikiFN('subns:start'));
472+
$this->assertFileDoesNotExist($oldfilepath);
473473

474474
$this->assertSame($subscription,file_get_contents($newfilepath));
475475

action/progress.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public function handle_ajax(Doku_Event $event) {
5959
if($todo === 0) $return['complete'] = true;
6060
}
6161

62-
$json = new JSON();
6362
header('Content-Type: application/json');
64-
echo $json->encode($return);
63+
echo json_encode($return);
6564
}
66-
}
65+
}

action/rename.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,18 @@ public function handle_ajax(Doku_Event $event) {
109109
/** @var helper_plugin_move_op $MoveOperator */
110110
$MoveOperator = plugin_load('helper', 'move_op');
111111

112-
$JSON = new JSON();
113-
114112
header('Content-Type: application/json');
115113

116114
if($this->renameOkay($src) && $MoveOperator->movePage($src, $dst)) {
117115
// all went well, redirect
118-
echo $JSON->encode(array('redirect_url' => wl($dst, '', true, '&')));
116+
echo json_encode(array('redirect_url' => wl($dst, '', true, '&')));
119117
} else {
120118
if(isset($MSG[0])) {
121119
$error = $MSG[0]; // first error
122120
} else {
123121
$error = $this->getLang('cantrename');
124122
}
125-
echo $JSON->encode(array('error' => $error));
123+
echo json_encode(array('error' => $error));
126124
}
127125
}
128126

admin/main.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ protected function createPlanFromInput() {
130130
return true;
131131
} elseif($INPUT->has('json')) {
132132
// input came via JSON from tree manager
133-
$json = new JSON(JSON_LOOSE_TYPE);
134-
$data = $json->decode($INPUT->str('json'));
133+
$data = json_decode($INPUT->str('json'), true);
135134

136135
foreach((array) $data as $entry) {
137136
if($entry['class'] == 'ns') {

0 commit comments

Comments
 (0)