Samwilson has uploaded a new change for review. https://gerrit.wikimedia.org/r/321213
Change subject: Invalid page names etc. ...................................................................... Invalid page names etc. Change-Id: Ia46ebd7105fccf8bd729b1a75efe766a3f46270d --- M README.md M src/Person.php M src/Util.php 3 files changed, 13 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Genealogy refs/changes/13/321213/1 diff --git a/README.md b/README.md index 0f982f2..0dda15b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ 1. Define this person's dates. `{{#genealogy:person |birth date=Y-m-d |death date=Y-m-d }}` -2. Define a parent: +2. Define and output a link to a parent: `{{#genealogy:parent | Page Name Here }}` 3. Define a partner (no output produced; use `partners` to list): `{{#genealogy:partner | Page Name Here |start date=Y-m-d |end date=Y-m-d }}` diff --git a/src/Person.php b/src/Person.php index 292d0fe..a3f76b9 100644 --- a/src/Person.php +++ b/src/Person.php @@ -222,6 +222,10 @@ ); foreach ( $results as $result ) { $title = Title::newFromText( $result->pp_value ); + if ( is_null( $title ) ) { + // Do nothing, if this isn't a valid title. + continue; + } $out[$title->getPrefixedDBkey()] = new Person( $title ); } return $out; diff --git a/src/Util.php b/src/Util.php index 688dcbf..6a71126 100644 --- a/src/Util.php +++ b/src/Util.php @@ -32,10 +32,10 @@ * This method is called by the editFormInitialText hook and adds a list of the current page's * Genealogy partners that *aren't* a result of a {{#genealogy:partner}} call in the current * page. - * @param EditPage $editPage + * @param string $formInitialText The existing initial text of the form * @return void */ - public static function onEditFormInitialText( EditPage &$editPage ) { + public static function onEditFormInitialText( &$formInitialText ) { global $wgTitle; $person = new Person( $wgTitle ); $peopleList = []; @@ -44,8 +44,11 @@ .$partner->getTitle()->getText() ."</a>"; } - $editPage = '<p>This person is listed as the partner of the following people: ' - .join( ', ', $peopleList ).'</p>'.$editPage; + if ( count( $peopleList ) > 0 ) { + $formInitialText = + '<p>This person is listed as the partner of the following people: ' . + join( ', ', $peopleList ) . '</p>' . $formInitialText; + } } /** @@ -150,7 +153,7 @@ // Figure out what number we're up to for this property. $propNum = 1; $propVal = $output->getProperty( "genealogy $prop $propNum" ); - while ( $propVal !== $val ) { + while ( $propVal !== false && $propVal !== $val ) { $propNum++; $propVal = $output->getProperty( "genealogy $prop $propNum" ); } -- To view, visit https://gerrit.wikimedia.org/r/321213 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia46ebd7105fccf8bd729b1a75efe766a3f46270d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Genealogy Gerrit-Branch: master Gerrit-Owner: Samwilson <s...@samwilson.id.au> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits