Skip to content

Commit

Permalink
Merge pull request #1365 from ms609/GlazerMann-patch-15
Browse files Browse the repository at this point in the history
Done: Report url dropping
  • Loading branch information
Martin R. Smith committed Feb 25, 2019
2 parents f0cc8a8 + d430fd3 commit 1909168
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,21 @@ public function edit_summary() {
$auto_summary = substr($auto_summary, 0, -2) . '. ';
}
}

if ((count($this->modifications["deletions"]) !== 0)
&& (
(($pos = array_search('url', $this->modifications["deletions"])) !== FALSE)
|| (($pos = array_search('chapter-url', $this->modifications["deletions"])) !== FALSE)
|| (($pos = array_search('chapterurl', $this->modifications["deletions"])) !== FALSE)
)
) {
if (strpos($auto_summary, 'chapter-url') !== FALSE) {
$auto_summary .= "Removed or converted URL. ";
} else {
$auto_summary .= "Removed URL that duplicated unique identifier. ";
}
unset($this->modifications["deletions"][$pos]);
}
if ((count($this->modifications["deletions"]) !== 0)
&& ($pos = array_search('accessdate', $this->modifications["deletions"])) !== FALSE
) {
Expand Down
5 changes: 4 additions & 1 deletion tests/phpunit/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ public function testPageChangeSummary() {
$this->assertEquals('Misc citation tidying. | You can [[WP:UCB|use this bot]] yourself. [[WP:DBUG|Report bugs here]].',$page->edit_summary());
$page = $this->process_page('<ref>http://onlinelibrary.wiley.com/doi/10.1111/j.1475-4983.2012.01203.x</ref>');
$this->assertFalse(strpos($page->parsed_text(), 'onlinelibrary.wiley.com')); // URL is gone
$this->assertEquals('Alter: template type. Add: year, pages, issue, volume, journal, title, doi, author pars. 1-2. Converted bare reference to cite template. Removed parameters. Formatted [[WP:ENDASH|dashes]]. | You can [[WP:UCB|use this bot]] yourself. [[WP:DBUG|Report bugs here]].' ,$page->edit_summary());
$this->assertEquals('Alter: template type. Add: year, pages, issue, volume, journal, title, doi, author pars. 1-2. Removed URL that duplicated unique identifier. Converted bare reference to cite template. Formatted [[WP:ENDASH|dashes]]. | You can [[WP:UCB|use this bot]] yourself. [[WP:DBUG|Report bugs here]].' ,$page->edit_summary());
$page = $this->process_page('{{cite web|<!-- comment --> journal=Journal Name}}'); // Comment BEFORE parameter
$this->assertEquals('Alter: template type. | You can [[WP:UCB|use this bot]] yourself. [[WP:DBUG|Report bugs here]].',$page->edit_summary());
$this->assertEquals('{{cite journal|<!-- comment --> journal=Journal Name}}', $page->parsed_text());
$page = $this->process_page('{{cite web|journal<!-- comment -->=Journal Name}}'); // Comment AFTER parameter
$this->assertEquals('Alter: template type. | You can [[WP:UCB|use this bot]] yourself. [[WP:DBUG|Report bugs here]].',$page->edit_summary());
$this->assertEquals('{{cite journal|journal<!-- comment -->=Journal Name}}', $page->parsed_text());
$page = $this->process_page('{{cite book|url=http://a.fake.url.fake/|chapter=Chap|title=Title}}');
$this->assertEquals('{{cite book|chapter-url=http://a.fake.url.fake/|chapter=Chap|title=Title}}', $page->parsed_text());
$this->assertEquals('Add: chapter-url. Removed or converted URL. | You can [[WP:UCB|use this bot]] yourself. [[WP:DBUG|Report bugs here]].' ,$page->edit_summary());
}

public function testBotRead() {
Expand Down

0 comments on commit 1909168

Please sign in to comment.