diff --git a/.gitmodules b/.gitmodules
index cc54079..e69de29 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,4 +0,0 @@
-[submodule "gh-pages"]
- path = gh-pages
- url = git@github.com:bovender/LinkTitles.git
- branch = gh-pages
diff --git a/README.md b/README.md
index 966a24a..5287f34 100644
--- a/README.md
+++ b/README.md
@@ -452,6 +452,7 @@ master branch if you want to install the extension for your own Wiki.
- @tetsuya-zama, bug fix
- @yoshida3669, namespace-related bug fixes
- Caleb Mingle (@dentafrice), bug fix
+- @paladox, bug fixes
### Testing
diff --git a/gh-pages b/gh-pages
deleted file mode 160000
index 4850111..0000000
--- a/gh-pages
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 48501118d18e30869a8acdd357a6c14772c4c47b
diff --git a/includes/Special.php b/includes/Special.php
index 453e262..72e15c4 100644
--- a/includes/Special.php
+++ b/includes/Special.php
@@ -146,7 +146,7 @@ class Special extends \SpecialPage {
$start += 1;
// Check if the time limit is exceeded
- if ( microtime( true ) - $startTime > $config->specialPageReloadAfter )
+ if ( microtime( true ) - $startTime > $this->config->specialPageReloadAfter )
{
break;
}
diff --git a/tests/phpunit/ConfigTest.php b/tests/phpunit/ConfigTest.php
index a21b38e..0cc03f7 100644
--- a/tests/phpunit/ConfigTest.php
+++ b/tests/phpunit/ConfigTest.php
@@ -29,13 +29,13 @@
*/
class ConfigTest extends LinkTitles\TestCase {
- public function testParseOnEdit() {
- $this->setMwGlobals( [
- 'wgLinkTitlesParseOnEdit' => true,
- 'wgLinkTitlesParseOnRender' => false
- ] );
- $config = new LinkTitles\Config();
- global $wgLinkTitlesParseOnEdit;
- $this->assertSame( $config->parseOnEdit, $wgLinkTitlesParseOnEdit );
- }
+ public function testParseOnEdit() {
+ $this->setMwGlobals( [
+ 'wgLinkTitlesParseOnEdit' => true,
+ 'wgLinkTitlesParseOnRender' => false
+ ] );
+ $config = new LinkTitles\Config();
+ global $wgLinkTitlesParseOnEdit;
+ $this->assertSame( $config->parseOnEdit, $wgLinkTitlesParseOnEdit );
+ }
}
diff --git a/tests/phpunit/ExtensionTest.php b/tests/phpunit/ExtensionTest.php
index e6f8369..bcd40a7 100644
--- a/tests/phpunit/ExtensionTest.php
+++ b/tests/phpunit/ExtensionTest.php
@@ -26,87 +26,87 @@
*/
class ExtensionTest extends LinkTitles\TestCase {
- /**
+ /**
* @dataProvider provideParseOnEditData
- */
- public function testParseOnEdit( $parseOnEdit, $input, $expectedOutput) {
- $this->setMwGlobals( [
- 'wgLinkTitlesParseOnEdit' => $parseOnEdit,
- 'wgLinkTitlesParseOnRender' => !$parseOnEdit
- ] );
- $pageId = $this->insertPage( 'test page', $input )['id'];
- $page = WikiPage::newFromId( $pageId );
- $this->assertSame( $expectedOutput, self::getPageText( $page ) );
- }
+ */
+ public function testParseOnEdit( $parseOnEdit, $input, $expectedOutput) {
+ $this->setMwGlobals( [
+ 'wgLinkTitlesParseOnEdit' => $parseOnEdit,
+ 'wgLinkTitlesParseOnRender' => !$parseOnEdit
+ ] );
+ $pageId = $this->insertPage( 'test page', $input )['id'];
+ $page = WikiPage::newFromId( $pageId );
+ $this->assertSame( $expectedOutput, self::getPageText( $page ) );
+ }
- public function provideParseOnEditData() {
- return [
- [
- true, // parseOnEdit
- 'This page should link to the link target but not to test page',
- 'This page should link to the [[link target]] but not to test page'
- ],
- [
- false, // parseOnEdit
- 'This page should *not* link to the link target',
- 'This page should *not* link to the link target'
- ],
- [
- true, // parseOnEdit
- 'With __NOAUTOLINKS__, this page should not link to the link target',
- 'With __NOAUTOLINKS__, this page should not link to the link target'
- ],
- ];
- }
+ public function provideParseOnEditData() {
+ return [
+ [
+ true, // parseOnEdit
+ 'This page should link to the link target but not to test page',
+ 'This page should link to the [[link target]] but not to test page'
+ ],
+ [
+ false, // parseOnEdit
+ 'This page should *not* link to the link target',
+ 'This page should *not* link to the link target'
+ ],
+ [
+ true, // parseOnEdit
+ 'With __NOAUTOLINKS__, this page should not link to the link target',
+ 'With __NOAUTOLINKS__, this page should not link to the link target'
+ ],
+ ];
+ }
- /**
+ /**
* @dataProvider provideParseOnRenderData
- */
- public function testParseOnRender( $parseOnRender, $input, $expectedOutput) {
- $this->setMwGlobals( [
- 'wgLinkTitlesParseOnEdit' => false, // do not modify the page as we create it
- 'wgLinkTitlesParseOnRender' => $parseOnRender
- ] );
- $title = $this->insertPage( 'test page', $input )['title'];
- $page = new WikiPage( $title );
- $output = $page->getParserOutput( new ParserOptions(), null, true );
- $lines = explode( "\n", $output->getText() );
- $this->assertRegexp( $expectedOutput, $lines[0] );
- }
+ */
+ public function testParseOnRender( $parseOnRender, $input, $expectedOutput) {
+ $this->setMwGlobals( [
+ 'wgLinkTitlesParseOnEdit' => false, // do not modify the page as we create it
+ 'wgLinkTitlesParseOnRender' => $parseOnRender
+ ] );
+ $title = $this->insertPage( 'test page', $input )['title'];
+ $page = new WikiPage( $title );
+ $output = $page->getParserOutput( new ParserOptions(), null, true );
+ $lines = explode( "\n", $output->getText() );
+ $this->assertRegexp( $expectedOutput, $lines[0] );
+ }
- public function provideParseOnRenderData() {
- return [
- [
- true, // parseOnRender
- 'This page should link to the link target but not to the test page',
- '_This page should link to the ]+>link target but not to the test page_'
- ],
- [
- false, // parseOnRender
- 'This page should not link to the link target',
- '_This page should not link to the link target_'
- ],
- [
- true, // parseOnRender
- '__NOAUTOLINKS__With noautolinks magic word, this page should not link to the link target',
- '_With noautolinks magic word, this page should not link to the link target_'
- ],
- [
- true, // parseOnRender
- '__NOAUTOLINKS__With noautolinks magic word, link target in autolinks tag should be linked',
- '_With noautolinks magic word, ]+>link target in autolinks tag should be linked_'
- ],
- [
- true, // parseOnRender
- 'In a noautolinks tag, link target should NOT be linked',
- '_In a noautolinks tag, link target should NOT be linked_'
- ],
- [
- true, // parseOnRender
- 'In a noautolinks tag, link target in autolinks tag should be linked',
- '_In a noautolinks tag, ]+>link target in autolinks tag should be linked_'
- ],
- ];
- }
+ public function provideParseOnRenderData() {
+ return [
+ [
+ true, // parseOnRender
+ 'This page should link to the link target but not to the test page',
+ '_This page should link to the ]+>link target but not to the test page_'
+ ],
+ [
+ false, // parseOnRender
+ 'This page should not link to the link target',
+ '_This page should not link to the link target_'
+ ],
+ [
+ true, // parseOnRender
+ '__NOAUTOLINKS__With noautolinks magic word, this page should not link to the link target',
+ '_With noautolinks magic word, this page should not link to the link target_'
+ ],
+ [
+ true, // parseOnRender
+ '__NOAUTOLINKS__With noautolinks magic word, link target in autolinks tag should be linked',
+ '_With noautolinks magic word, ]+>link target in autolinks tag should be linked_'
+ ],
+ [
+ true, // parseOnRender
+ 'In a noautolinks tag, link target should NOT be linked',
+ '_In a noautolinks tag, link target should NOT be linked_'
+ ],
+ [
+ true, // parseOnRender
+ 'In a noautolinks tag, link target in autolinks tag should be linked',
+ '_In a noautolinks tag, ]+>link target in autolinks tag should be linked_'
+ ],
+ ];
+ }
}
diff --git a/tests/phpunit/LinkerTest.php b/tests/phpunit/LinkerTest.php
index 6314185..31ce2ca 100644
--- a/tests/phpunit/LinkerTest.php
+++ b/tests/phpunit/LinkerTest.php
@@ -41,11 +41,11 @@ class LinkTitlesLinkerTest extends LinkTitles\TestCase {
parent::setUp(); // call last to have the Targets object invalidated after inserting the page
}
- public function addDBData() {
+ public function addDBData() {
$this->title = $this->insertPage( 'source page', 'This page is the test page' )['title'];
- $this->insertPage( 'link target', 'This page serves as a link target' );
+ $this->insertPage( 'link target', 'This page serves as a link target' );
parent::addDBDataOnce(); // call parent after adding page to have targets invalidated
- }
+ }
/**
* @dataProvider provideTestTitleWithNumberData
@@ -54,8 +54,8 @@ class LinkTitlesLinkerTest extends LinkTitles\TestCase {
$config = new LinkTitles\Config();
$config->wordStartOnly = true;
$config->wordEndOnly = true;
- $this->insertPage( 'numbered-1', 'This page serves as a link target with a numbered title' );
- $this->insertPage( 'numbered-101', 'This page serves as a link target with a numbered title' );
+ $this->insertPage( 'numbered-1', 'This page serves as a link target with a numbered title' );
+ $this->insertPage( 'numbered-101', 'This page serves as a link target with a numbered title' );
parent::addDBDataOnce(); // call parent after adding page to have targets invalidated
$source = LinkTitles\Source::createFromTitleAndText( $this->title, $input, $config );
$linker = new LinkTitles\Linker( $config );
@@ -85,6 +85,21 @@ class LinkTitlesLinkerTest extends LinkTitles\TestCase {
];
}
+ /**
+ * Test issue #39, https://github.com/bovender/LinkTitles/issues/39
+ */
+ public function testNoautolinks() {
+ $config = new LinkTitles\Config();
+ $config->firstOnly = false;
+ LinkTitles\Splitter::invalidate();
+ $input = 'This is a text with link target';
+ $source = LinkTitles\Source::createFromTitleAndText( $this->title, $input, $config );
+ $linker = new LinkTitles\Linker( $config );
+ $result = $linker->linkContent( $source );
+ if ( !$result ) { $result = $input; }
+ $this->assertSame( $input, $result );
+ }
+
/**
* @dataProvider provideLinkContentTemplatesData
*/
@@ -294,7 +309,7 @@ class LinkTitlesLinkerTest extends LinkTitles\TestCase {
$config = new LinkTitles\Config();
$config->targetNamespaces = $namespaces;
- $ns = 4000;
+ $ns = 4000;
$nsText = 'customnamespace';
$this->mergeMwGlobalArrayValue( 'wgExtraNamespaces', [ $ns => $nsText ] );
@@ -316,16 +331,16 @@ class LinkTitlesLinkerTest extends LinkTitles\TestCase {
public function provideLinkContentNamespacesData() {
return [
- [
- [], // namespaces
- 'With targetNamespaces = [], page in custom namespace should not be linked',
- 'With targetNamespaces = [], page in custom namespace should not be linked'
- ],
- [
- [ 4000 ], // namespaces
- 'With targetNamespaces = [ 4000 ], page in custom namespace should be linked',
- 'With targetNamespaces = [ 4000 ], page [[customnamespace:In custom namespace|in custom namespace]] should be linked'
- ],
+ [
+ [], // namespaces
+ 'With targetNamespaces = [], page in custom namespace should not be linked',
+ 'With targetNamespaces = [], page in custom namespace should not be linked'
+ ],
+ [
+ [ 4000 ], // namespaces
+ 'With targetNamespaces = [ 4000 ], page in custom namespace should be linked',
+ 'With targetNamespaces = [ 4000 ], page [[customnamespace:In custom namespace|in custom namespace]] should be linked'
+ ],
];
}
}
diff --git a/tests/phpunit/TestCase.php b/tests/phpunit/TestCase.php
index 5ed7dd6..e41fbde 100644
--- a/tests/phpunit/TestCase.php
+++ b/tests/phpunit/TestCase.php
@@ -22,22 +22,22 @@
namespace LinkTitles;
abstract class TestCase extends \MediaWikiTestCase {
- protected function setUp() {
- parent::setUp();
- }
+ protected function setUp() {
+ parent::setUp();
+ }
- protected function tearDown() {
- parent::tearDown();
- }
+ protected function tearDown() {
+ parent::tearDown();
+ }
- public function addDBDataOnce() {
- parent::addDBDataOnce();
- $this->insertPage( 'link target', 'This page serves as a link target' );
- Targets::invalidate(); // force re-querying the pages table
- }
+ public function addDBDataOnce() {
+ parent::addDBDataOnce();
+ $this->insertPage( 'link target', 'This page serves as a link target' );
+ Targets::invalidate(); // force re-querying the pages table
+ }
- protected function getPageText( \WikiPage $page ) {
- $content = $page->getContent();
- return $page->getContentHandler()->serializeContent( $content );
- }
+ protected function getPageText( \WikiPage $page ) {
+ $content = $page->getContent();
+ return $page->getContentHandler()->serializeContent( $content );
+ }
}