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

Done: Report url dropping #1365

Merged
merged 7 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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