Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search Index Refactoring #3556

Draft
wants to merge 104 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
ddc452a
coding style
ssahara Dec 16, 2019
0fb77e9
encapsulate idx_cleanName()
ssahara Dec 16, 2019
1dad69b
deprecated idx_indexLengths()
ssahara Dec 16, 2019
4316123
encapsulate idx_listIndexLengths()
ssahara Dec 16, 2019
861eb32
deprecated idx_getIndex()
ssahara Dec 16, 2019
e15020b
deprecated idx_tokenizer()
ssahara Dec 16, 2019
abfaea2
deprecated idx_lookup()
ssahara Dec 16, 2019
56d1fe9
encapsulate idx_addPage()
ssahara Dec 16, 2019
8c01949
encapsulate idx_get_version()
ssahara Dec 16, 2019
0af7b62
encapsulate idx_get_stopwords()
ssahara Dec 16, 2019
8896568
encapsulate wordlen() in the Indexer
ssahara Dec 17, 2019
b5daf9f
make Doku_Indexer singleton
ssahara Dec 17, 2019
cd17dbd
encapsulate functions into Classes
ssahara Dec 19, 2019
83198f9
coding style PSR-12
ssahara Dec 20, 2019
d43b19d
deprecated class Doku_Indexer extends \Indexer
ssahara Dec 20, 2019
173bfbc
new namespace dokuwiki\Search
ssahara Dec 21, 2019
c31af4f
use Indexer method instead of idx_get_indexer()
ssahara Dec 27, 2019
fe21229
make public listIndex() and listIndexLengths() method
ssahara Dec 27, 2019
89b6193
remove compatibility idx_ functions that are not used anywhere
ssahara Dec 27, 2019
0a3e25f
remove compatibility ft_ functions that are not used anywhere
ssahara Dec 28, 2019
115f491
updateTuple() 2nd parameter
ssahara Dec 28, 2019
f9c5d30
Revert "updateTuple() 2nd parameter"
ssahara Dec 29, 2019
48b9265
define constants inside namespace
ssahara Dec 30, 2019
3837ea9
create QueryParser class
ssahara Jan 5, 2020
677f78a
move Quicksearch methods into MetaSearch class
ssahara Jan 5, 2020
6b6beca
bug fix and PHP74 warnings
ssahara Jan 5, 2020
fe2d1da
change class name to MetadataSearch
ssahara Jan 5, 2020
f076e3f
Abstraction Index classes
ssahara Jan 7, 2020
86fc728
separate methods into metadata, Pageword, Page index classes
ssahara Jan 7, 2020
5aa57cb
make $pidCache static, refactor getPID()
ssahara Jan 7, 2020
5d3ae62
child class of AbstractIndex must have claer()
ssahara Jan 10, 2020
872fcdc
set $errors when index lock() failed
ssahara Jan 12, 2020
7dcabbd
separate deletePageNoLock() process
ssahara Jan 13, 2020
9dd6e5f
obsolete deletePageNoLock()
ssahara Jan 13, 2020
185796b
allow public access to getIndex(), etc.
ssahara Jan 13, 2020
780c140
define histogram() in PageIndex class
ssahara Jan 13, 2020
489a7bf
Undefined methods dispatcher
ssahara Jan 13, 2020
839557a
fix Undefined methods dispatcher
ssahara Jan 13, 2020
b47a51d
fix $errors static
ssahara Jan 14, 2020
9ad37f3
remove getInstance() from AbstractIndex
ssahara Jan 14, 2020
3f4a342
rewrite deprecated idx_* functions
ssahara Jan 14, 2020
0cba610
rewrite deprecated ft_* functions
ssahara Jan 14, 2020
a991224
remove global FT_SNIPPET_NUMBER
ssahara Jan 15, 2020
efe7080
use ::class for class name resolution
ssahara Jan 15, 2020
166288e
cast int for addIndexKey()
ssahara Jan 15, 2020
196d73d
Merge remote-tracking branch 'upstream/master' into Refactor_Fulltext
ssahara Jan 15, 2020
2cbd2b9
Merge branch 'master' into Refactor_Fulltext
ssahara Jan 16, 2020
46b8351
resolve conflictions, CodeSniffer errors
ssahara Jan 19, 2020
be5c1ea
move lookup() to PagewordIndex class, reduce term 'Indexer'
ssahara Jan 19, 2020
bb38a88
rewrite test files
ssahara Jan 19, 2020
8bff05a
fix _test/tests/inc/indexer_rename.test.php
ssahara Jan 19, 2020
c562873
remove Undefined method dispacher for _test
ssahara Jan 19, 2020
094ebf2
separate Tokenizer class
ssahara Jan 20, 2020
d756b1c
restore accessibility protected for getIndexWords()
ssahara Jan 20, 2020
02361d2
define getPages() in AbstractIndex instead of PageIndex
ssahara Jan 20, 2020
39cb9fc
claer() idx files only created by index class
ssahara Jan 25, 2020
f36fd30
refactor getPID()
ssahara Jan 29, 2020
9a025b5
dispatch indexing request to addPage() or deletePage()
ssahara Jan 30, 2020
4027a91
use Indexer.php instead of PageIndex.php
ssahara Jan 30, 2020
4f93610
fix first argument of dbg_deprecated()
ssahara Jan 30, 2020
8fb944f
change wordlen() to non-static method
ssahara Jan 30, 2020
a2f3916
fix typo
ssahara Jan 30, 2020
e9d278b
Merge remote-tracking branch 'upstream/master' into Refactor_Fulltext
ssahara Jan 31, 2020
4d04b7b
histogram() change args order
ssahara Jan 31, 2020
5237d40
trigger error when lock/unlock index directory failed
ssahara Jan 31, 2020
743c9a2
rename PagewordIndex to FulltextIndex
ssahara Jan 31, 2020
6f58ff6
obsolete fulltext.php and indexer.php files
ssahara Feb 1, 2020
653b91a
AbstractIndex class const INDEX_MARK_DELETED
ssahara Feb 1, 2020
4a90f94
move backlinks() and mediause() into MediaIndex class
ssahara Feb 2, 2020
f2e1d0b
fix set Stopwords property
ssahara Feb 2, 2020
db87936
fix getPID()
ssahara Feb 2, 2020
9329b00
change static methods into instance methods
ssahara Feb 2, 2020
fd9f989
remove unnecessary comment
ssahara Feb 20, 2020
11d2e7d
simplify dispatch()
ssahara Feb 20, 2020
b4c31a2
idx_get_indexer() returns MetadataIndex
ssahara Feb 20, 2020
5f9bd52
Revert "histogram() change args order"
ssahara Feb 20, 2020
51ddbad
move histogram() into MetadataIndex class
ssahara Feb 20, 2020
abb227b
add comment for $requireLock argument
ssahara Mar 13, 2020
22c4cfd
Merge remote-tracking branch 'upstream/master' into Refactor_Fulltext
ssahara Mar 14, 2020
39f31b6
Follow up #2985, fperm seetting
ssahara Mar 14, 2020
e36bcee
Merge branch 'master' into Refactor_Fulltext
ssahara May 25, 2020
9de2ceb
Merge branch 'master' into Refactor_Fulltext
ssahara Jun 7, 2020
558f089
make FulltextIndex::getIndexLengths() public
ssahara Jun 24, 2020
d42a607
fix method name
ssahara Jun 24, 2020
22df765
fix deprecated.php
ssahara Jun 24, 2020
b9c8f03
Merge branch 'master' into Refactor_Fulltext
splitbrain Sep 10, 2020
15f699a
replace user errors with exceptions
splitbrain Sep 10, 2020
265e2c9
throw IndexWriteException in saveIndex()/saveIndexkey()
ssahara Sep 21, 2020
a16bd54
remove unnecessary if blocks
ssahara Sep 21, 2020
89e3dd3
avoid null in addMetaKeys()
ssahara Sep 22, 2020
a32da6d
change Index objects to non-singleton
ssahara Sep 25, 2020
725e8e5
instantiate *Index with numeric page id
ssahara Sep 25, 2020
5792814
fix scrutinizer claims
ssahara Sep 25, 2020
1755450
change Tokenizer static utility
ssahara Sep 26, 2020
cc3a3cd
change MetadataSearch and FulltextSearch to non-singleton
ssahara Sep 26, 2020
72ebc99
dbglog() for SearchException
ssahara Sep 26, 2020
4d69838
add missing namespace to fallbacks
ssahara Sep 28, 2020
9e7aeeb
Merge branch 'master' into Refactor_Fulltext
ssahara Nov 10, 2020
bcd7722
replace deprecated ft_backlinks() in Ui
ssahara Nov 10, 2020
c1803f3
Merge remote-tracking branch 'upstream/master' into Refactor_Fulltext
ssahara Nov 29, 2021
05606ae
fix undefined array in FulltextSearch
ssahara Nov 29, 2021
fab81cc
added missing 'notns' related code
ssahara Nov 29, 2021
a02395a
catch up #3115 Sort with collator
ssahara Nov 29, 2021
3df1553
use Logger::debug() instead of deprecated dbglog()
ssahara Nov 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 22 additions & 14 deletions _test/core/DokuWikiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
use dokuwiki\Extension\PluginController;
use dokuwiki\Extension\Event;
use dokuwiki\Extension\EventHandler;
use dokuwiki\Search\Indexer;

/**
* 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
*
Expand Down Expand Up @@ -80,18 +82,18 @@ public function setUp() : void {
foreach (array('default','local') as $config_group) {
if (empty($config_cascade['license'][$config_group])) continue;
foreach ($config_cascade['license'][$config_group] as $config_file) {
if(file_exists($config_file)){
if (file_exists($config_file)) {
include($config_file);
}
}
}
// reload some settings
$conf['gzip_output'] &= (strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false);

if($conf['compression'] == 'bz2' && !DOKU_HAS_BZIP) {
if ($conf['compression'] == 'bz2' && !DOKU_HAS_BZIP) {
$conf['compression'] = 'gz';
}
if($conf['compression'] == 'gz' && !DOKU_HAS_GZIP) {
if ($conf['compression'] == 'gz' && !DOKU_HAS_GZIP) {
$conf['compression'] = 0;
}
// make real paths and check them
Expand Down Expand Up @@ -144,11 +146,12 @@ public function setUp() : void {
/**
* Reinitialize the data directory for this class run
*/
public static function setupDataDir() {
public static function setupDataDir()
{
// remove any leftovers from the last run
if(is_dir(DOKU_TMP_DATA)) {
// clear indexer data and cache
idx_get_indexer()->clear();
(new Indexer())->clear();
TestUtils::rdelete(DOKU_TMP_DATA);
}

Expand All @@ -159,7 +162,8 @@ public static function setupDataDir() {
/**
* Reinitialize the conf directory for this class run
*/
public static function setupConfDir() {
public static function setupConfDir()
{
$defaults = [
'acronyms.conf',
'dokuwiki.php',
Expand All @@ -177,13 +181,13 @@ public static function setupConfDir() {
];

// clear any leftovers
if(is_dir(DOKU_CONF)) {
if (is_dir(DOKU_CONF)) {
TestUtils::rdelete(DOKU_CONF);
}
mkdir(DOKU_CONF);

// copy defaults
foreach($defaults as $file) {
foreach ($defaults as $file) {
copy(DOKU_INC . '/conf/' . $file, DOKU_CONF . $file);
}

Expand All @@ -201,7 +205,8 @@ public static function setupConfDir() {
* @param bool $init no longer used
* @return int new timestamp
*/
protected function waitForTick($init = false) {
protected function waitForTick($init = false)
{
sleep(1);
return time();
}
Expand All @@ -219,7 +224,8 @@ protected function waitForTick($init = false) {
* @return mixed
* @throws ReflectionException when the given obj/func does not exist
*/
protected static function callInaccessibleMethod($obj, $func, array $args) {
protected static function callInaccessibleMethod($obj, $func, array $args)
{
$class = new \ReflectionClass($obj);
$method = $class->getMethod($func);
$method->setAccessible(true);
Expand All @@ -237,7 +243,8 @@ protected static function callInaccessibleMethod($obj, $func, array $args) {
* @return mixed
* @throws ReflectionException when the given obj/prop does not exist
*/
protected static function getInaccessibleProperty($obj, $prop) {
protected static function getInaccessibleProperty($obj, $prop)
{
$class = new \ReflectionClass($obj);
$property = $class->getProperty($prop);
$property->setAccessible(true);
Expand All @@ -256,7 +263,8 @@ protected static function getInaccessibleProperty($obj, $prop) {
* @return void
* @throws ReflectionException when the given obj/prop does not exist
*/
protected static function setInaccessibleProperty($obj, $prop, $value) {
protected static function setInaccessibleProperty($obj, $prop, $value)
{
$class = new \ReflectionClass($obj);
$property = $class->getProperty($prop);
$property->setAccessible(true);
Expand Down
79 changes: 47 additions & 32 deletions _test/tests/inc/fulltext_backlinks.test.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use dokuwiki\Search\Indexer;
use dokuwiki\Search\MetadataIndex;

// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();

Expand All @@ -8,38 +11,45 @@
*
* @author Michael Hamann <michael@content-space.de>
*/
class fulltext_backlinks_test extends DokuWikiTest {

public function test_internallink() {
class fulltext_backlinks_test extends DokuWikiTest
{
public function test_internallink()
{
saveWikiText('test:internallinks', '[[internälLink]] [[..:internal link]]', 'Test initialization');
idx_addPage('test:internallinks');
(new Indexer('test:internallinks'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('test:internallinks'), ft_backlinks('internal_link'));
$this->assertEquals(array('test:internallinks'), ft_backlinks('test:internaellink'));
$this->assertEquals(array('test:internallinks'), $MetadataIndex->backlinks('internal_link'));
$this->assertEquals(array('test:internallinks'), $MetadataIndex->backlinks('test:internaellink'));
}

public function test_links_in_footnotes() {
public function test_links_in_footnotes()
{
saveWikiText('test:link_footnotes', '(([[footnote]] [[:foÖtnotel]]))', 'Test initialization');
idx_addPage('test:link_footnotes');
(new Indexer('test:link_footnotes'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('test:link_footnotes'), ft_backlinks('test:footnote'));
$this->assertEquals(array('test:link_footnotes'), ft_backlinks('fooetnotel'));
$this->assertEquals(array('test:link_footnotes'), $MetadataIndex->backlinks('test:footnote'));
$this->assertEquals(array('test:link_footnotes'), $MetadataIndex->backlinks('fooetnotel'));
}

public function test_links_in_hidden_pages() {
public function test_links_in_hidden_pages()
{
global $conf;
$conf['hidepages'] = 'hidden:.*';
saveWikiText('hidden:links', '[[wiki:hiddenlink|linktitle]]', 'Test initialization');
idx_addPage('hidden:links');
(new Indexer('hidden:links'))->addPage();
saveWikiText('visible:links', '[[wiki:hiddenlink]]', 'Test initialization');
idx_addPage('visible:links');
(new Indexer('visible:links'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('visible:links'), ft_backlinks('wiki:hiddenlink'));
$this->assertEquals(array('visible:links'), ft_backlinks('wiki:hiddenlink', false));
$this->assertEquals(array('hidden:links', 'visible:links'), ft_backlinks('wiki:hiddenlink', true));
$this->assertEquals(array('visible:links'), $MetadataIndex->backlinks('wiki:hiddenlink'));
$this->assertEquals(array('visible:links'), $MetadataIndex->backlinks('wiki:hiddenlink', false));
$this->assertEquals(array('hidden:links', 'visible:links'), $MetadataIndex->backlinks('wiki:hiddenlink', true));
}

public function test_links_in_protected_pages() {
public function test_links_in_protected_pages()
{
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'alice';
Expand All @@ -53,33 +63,38 @@ public function test_links_in_protected_pages() {
$_SERVER['REMOTE_USER'] = 'eve';

saveWikiText('secret:links', '[[wiki:secretlink]]', 'Test initialization');
idx_addPage('secret:links');
(new Indexer('secret:links'))->addPage();
saveWikiText('public:links', '[[wiki:secretlink]]', 'Test initialization');
idx_addPage('public:links');
(new Indexer('public:links'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('public:links'), ft_backlinks('wiki:secretlink'));
$this->assertEquals(array('public:links'), ft_backlinks('wiki:secretlink', false));
$this->assertEquals(array('public:links', 'secret:links'), ft_backlinks('wiki:secretlink', true));
$this->assertEquals(array('public:links'), $MetadataIndex->backlinks('wiki:secretlink'));
$this->assertEquals(array('public:links'), $MetadataIndex->backlinks('wiki:secretlink', false));
$this->assertEquals(array('public:links', 'secret:links'), $MetadataIndex->backlinks('wiki:secretlink', true));
}

public function test_links_in_deleted_pages() {
public function test_links_in_deleted_pages()
{
saveWikiText('test:internallinks', '[[internallink]] [[..:internal link]]', 'Test initialization');
idx_addPage('test:internallinks');
(new Indexer('test:internallinks'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('test:internallinks'), ft_backlinks('test:internallink'));
$this->assertEquals(array('test:internallinks'), ft_backlinks('internal_link'));
$this->assertEquals(array('test:internallinks'), $MetadataIndex->backlinks('test:internallink'));
$this->assertEquals(array('test:internallinks'), $MetadataIndex->backlinks('internal_link'));

saveWikiText('test:internallinks', '', 'Deleted');

$this->assertEquals(array(), ft_backlinks('test:internallink'));
$this->assertEquals(array(), ft_backlinks('internal_link'));
$this->assertEquals(array(), $MetadataIndex->backlinks('test:internallink'));
$this->assertEquals(array(), $MetadataIndex->backlinks('internal_link'));
}

function test_parameters() {
function test_parameters()
{
saveWikiText('test:links', '[[wiki:syntax?do=export_raw]] [[:web:scripts:add_vhost.sh?do=export_raw]]', 'Init tests');
idx_addPage('test:links');
(new Indexer('test:links'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('test:links'), ft_backlinks('wiki:syntax'));
$this->assertEquals(array('test:links'), ft_backlinks('web:scripts:add_vhost.sh'));
$this->assertEquals(array('test:links'), $MetadataIndex->backlinks('wiki:syntax'));
$this->assertEquals(array('test:links'), $MetadataIndex->backlinks('web:scripts:add_vhost.sh'));
}
}
79 changes: 48 additions & 31 deletions _test/tests/inc/fulltext_mediause.test.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use dokuwiki\Search\Indexer;
use dokuwiki\Search\MetadataIndex;

// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();

Expand All @@ -8,51 +11,62 @@
*
* @author Michael Hamann <michael@content-space.de>
*/
class fultext_mediause_test extends DokuWikiTest {

public function test_internalmedia() {
class fultext_mediause_test extends DokuWikiTest
{
public function test_internalmedia()
{
saveWikiText('test:internalmedia_usage', '{{internalmedia.png}} {{..:internal media.png}}', 'Test initialization');
idx_addPage('test:internalmedia_usage');
(new Indexer('test:internalmedia_usage'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('test:internalmedia_usage'), ft_mediause('internal_media.png'));
$this->assertEquals(array('test:internalmedia_usage'), ft_mediause('test:internalmedia.png'));
$this->assertEquals(array('test:internalmedia_usage'), $MetadataIndex->mediause('internal_media.png'));
$this->assertEquals(array('test:internalmedia_usage'), $MetadataIndex->mediause('test:internalmedia.png'));
}

public function test_media_in_links() {
public function test_media_in_links()
{
saveWikiText('test:medialinks', '[[doku>wiki:dokuwiki|{{wiki:logo.png}}]] [[http://www.example.com|{{example.png?200x800}}]]', 'Test init');
idx_addPage('test:medialinks');
(new Indexer('test:medialinks'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('test:medialinks'), ft_mediause('wiki:logo.png'));
$this->assertEquals(array('test:medialinks'), ft_mediause('test:example.png'));
$this->assertEquals(array('test:medialinks'), $MetadataIndex->mediause('wiki:logo.png'));
$this->assertEquals(array('test:medialinks'), $MetadataIndex->mediause('test:example.png'));
}

public function test_media_in_local_links() {
public function test_media_in_local_links()
{
saveWikiText('test:locallinks', '[[#test|{{wiki:logolocal.png}}]]', 'Test init');
idx_addPage('test:locallinks');
(new Indexer('test:locallinks'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('test:locallinks'), ft_mediause('wiki:logolocal.png'));
$this->assertEquals(array('test:locallinks'), $MetadataIndex->mediause('wiki:logolocal.png'));
}

public function test_media_in_footnotes() {
public function test_media_in_footnotes()
{
saveWikiText('test:media_footnotes', '(({{footnote.png?20x50}} [[foonote|{{:footlink.png}}]]))', 'Test initialization');
idx_addPage('test:media_footnotes');
(new Indexer('test:media_footnotes'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array('test:media_footnotes'), ft_mediause('test:footnote.png'));
$this->assertEquals(array('test:media_footnotes'), ft_mediause('footlink.png'));
$this->assertEquals(array('test:media_footnotes'), $MetadataIndex->mediause('test:footnote.png'));
$this->assertEquals(array('test:media_footnotes'), $MetadataIndex->mediause('footlink.png'));
}

public function test_media_in_hidden_pages() {
public function test_media_in_hidden_pages()
{
global $conf;
$conf['hidepages'] = 'hidden:.*';
saveWikiText('hidden:medias', '[[doku>wiki:dokuwiki|{{wiki:hiddenlogo.png}}]]', 'Test initialization');
idx_addPage('hidden:medias');
(new Indexer('hidden:medias'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array(), ft_mediause('wiki:hiddenlogo.png'));
$this->assertEquals(array(), ft_mediause('wiki:hiddenlogo.png', false));
$this->assertEquals(array('hidden:medias'), ft_mediause('wiki:hiddenlogo.png', true));
$this->assertEquals(array(), $MetadataIndex->mediause('wiki:hiddenlogo.png'));
$this->assertEquals(array(), $MetadataIndex->mediause('wiki:hiddenlogo.png', false));
$this->assertEquals(array('hidden:medias'), $MetadataIndex->mediause('wiki:hiddenlogo.png', true));
}

public function test_media_in_protected_pages() {
public function test_media_in_protected_pages()
{
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'alice';
Expand All @@ -66,19 +80,22 @@ public function test_media_in_protected_pages() {
$_SERVER['REMOTE_USER'] = 'eve';

saveWikiText('secret:medias', '[[doku>wiki:dokuwiki|{{wiki:secretlogo.png}}]]', 'Test initialization');
idx_addPage('secret:medias');
(new Indexer('secret:medias'))->addPage();
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array(), ft_mediause('wiki:secretlogo.png'));
$this->assertEquals(array(), ft_mediause('wiki:secretlogo.png', false));
$this->assertEquals(array('secret:medias'), ft_mediause('wiki:secretlogo.png', true));
$this->assertEquals(array(), $MetadataIndex->mediause('wiki:secretlogo.png'));
$this->assertEquals(array(), $MetadataIndex->mediause('wiki:secretlogo.png', false));
$this->assertEquals(array('secret:medias'), $MetadataIndex->mediause('wiki:secretlogo.png', true));
}

public function test_media_in_deleted_pages() {
public function test_media_in_deleted_pages()
{
saveWikiText('test:internalmedia_usage', '{{internalmedia.png}} {{..:internal media.png}}', 'Test initialization');
idx_addPage('test:internalmedia_usage');
(new Indexer('test:internalmedia_usage'))->addPage();
saveWikiText('test:internalmedia_usage', '', 'Deleted');
$MetadataIndex = new MetadataIndex();

$this->assertEquals(array(), ft_mediause('internal_media.png'));
$this->assertEquals(array(), ft_mediause('test:internalmedia.png'));
$this->assertEquals(array(), $MetadataIndex->mediause('internal_media.png'));
$this->assertEquals(array(), $MetadataIndex->mediause('test:internalmedia.png'));
}
}