jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/348674 )
Change subject: Multiple redirects, and graph names
......................................................................
Multiple redirects, and graph names
Change-Id: If943810694102a644c35333053b60c998278d822
---
M src/Person.php
M src/Tree.php
M tests/phpunit/PersonTest.php
3 files changed, 20 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Samwilson: Looks good to me, approved
diff --git a/src/Person.php b/src/Person.php
index ebf3158..4764559 100644
--- a/src/Person.php
+++ b/src/Person.php
@@ -51,8 +51,8 @@
*/
public function getTitle() {
$page = WikiPage::factory( $this->title );
- if ( $page->isRedirect() ) {
- return $page->getRedirectTarget();
+ while ( $page->isRedirect() ) {
+ $page = WikiPage::factory( $page->getRedirectTarget() );
}
return $page->getTitle();
}
diff --git a/src/Tree.php b/src/Tree.php
index e714c9f..3e73dd2 100644
--- a/src/Tree.php
+++ b/src/Tree.php
@@ -208,7 +208,7 @@
$this->out( 'partner', $personId.$parentsId,
$personParentsLine );
$childId = $this->esc( $child->getTitle()->getDBkey() );
$this->out( 'child', $parentsId.$childId, $parentsId.'
-> ' . $childId );
- // Add this child in case they don't .
+ // Add this child in case they don't get included
directly in this tree.
$this->outputPersonLine( $child );
}
}
@@ -238,7 +238,7 @@
* @return string
*/
private function esc( $title ) {
- return strtr( $title, '( )-', '____' );
+ return strtr( $title, '( )-.', '_____' );
}
}
diff --git a/tests/phpunit/PersonTest.php b/tests/phpunit/PersonTest.php
index b719e34..318edb0 100644
--- a/tests/phpunit/PersonTest.php
+++ b/tests/phpunit/PersonTest.php
@@ -108,5 +108,21 @@
'King Charles',
$diana->getPartners()['King_Charles']->getTitle()->getText()
);
+ // Redirect Charles again, and make sure all is okay.
+ $kingChPage->doEditContent( new WikitextContent( '#REDIRECT
[[King Charles III]]' ), '' );
+ $kingCh3Page = new WikiPage( Title::newFromText( 'King Charles
III' ) );
+ $kingCh3Page->doEditContent( new WikitextContent(
'{{#genealogy:partner|Diana}}' ), '' );
+ $this->assertEquals( 'King_Charles_III',
$charles->getTitle()->getPrefixedDBkey() );
+ $this->assertEquals(
+ [ 'Charles', 'King_Charles', 'King_Charles_III' ],
+ array_keys( $charles->getTitles() )
+ );
+ $this->assertCount( 1, $charles->getPartners() );
+ $this->assertEquals( 'Dianna',
$charles->getPartners()['Dianna']->getTitle() );
+ $this->assertCount( 1, $diana->getPartners() );
+ $this->assertEquals(
+ 'King Charles III',
+
$diana->getPartners()['King_Charles_III']->getTitle()->getText()
+ );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/348674
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If943810694102a644c35333053b60c998278d822
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson <[email protected]>
Gerrit-Reviewer: Samwilson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits