Skip to content

MDLSITE-8101: Update tracker links #8

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

Merged
merged 1 commit into from
Jun 16, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions classes/text_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class text_filter extends \core_filters\text_filter {
'moodle themes' => array('<a title="Auto-link" href="https://moodle.org/themes">', false, true, 'Moodle Themes'),
'moodle partners' => array('<a title="Auto-link" href="https://moodle.com/partners">', false, true, 'Moodle Partners'),
'moodle partner' => array('<a title="Auto-link" href="https://moodle.com/partners">', false, true, 'Moodle Partner'),
'moodle tracker' => array('<a title="Auto-link" href="https://tracker.moodle.org">', false, true, 'Moodle Tracker'),
'moodle tracker' => array('<a title="Auto-link" href="https://moodle.atlassian.net">', false, true, 'Moodle Tracker'),
'moodle jobs' => array('<a title="Auto-link" href="https://moodle.org/jobs">', false, true, 'Moodle jobs'),
'moodle books' => array('<a title="Auto-link" href="https://moodle.org/books">', false, true, 'Moodle books'),
'mooch' => array('<a title="MoodleNet - Connecting and empowering educators worldwide" href="https://moodle.net">', false, true),
Expand Down Expand Up @@ -98,7 +98,7 @@ public function filter($text, array $options = array()) {
'(?![^<]*</a>)' . // Try to avoid matching inside another link. Can be fooled by HTML like: <a href="..."><b>MDL-123</b></a>.
'#';
$text = preg_replace($regexp,
'<a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/$0">$0</a>',
'<a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/$0">$0</a>',
$text);

return $text;
Expand Down
30 changes: 15 additions & 15 deletions tests/text_filter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function test_filter_simple() {
'A MOODLE themes.' => 'A <a title="Auto-link" href="https://moodle.org/themes">Moodle Themes</a>.',
'A MOODLE partners,' => 'A <a title="Auto-link" href="https://moodle.com/partners">Moodle Partners</a>,',
'A MOODLE partner:' => 'A <a title="Auto-link" href="https://moodle.com/partners">Moodle Partner</a>:',
'A MOODLE trackeR:' => 'A <a title="Auto-link" href="https://tracker.moodle.org">Moodle Tracker</a>:',
'A MOODLE trackeR:' => 'A <a title="Auto-link" href="https://moodle.atlassian.net">Moodle Tracker</a>:',
'A MOODLE jobs/' => 'A <a title="Auto-link" href="https://moodle.org/jobs">Moodle jobs</a>/',
'.MOODLE books' => '.<a title="Auto-link" href="https://moodle.org/books">Moodle books</a>',
',MoocH' => ',<a title="MoodleNet - Connecting and empowering educators worldwide" href="https://moodle.net">MoocH</a>',
Expand Down Expand Up @@ -98,17 +98,17 @@ function test_filter_tracker() {
'<a href="https://example.com/a/very/very/long/url/containing/MDL-123"><br />MDL-123</a>' => '<a href="https://example.com/a/very/very/long/url/containing/MDL-123"><br />MDL-123</a>',

// A known limit of the regexp, we have to live with it (unless somebody fixes it without breaking the rest)
'search Google for <a href="https://www.google.com.au/"><b>MDLSITE-0</b></a>' => 'search Google for <a href="https://www.google.com.au/"><b><a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDLSITE-0">MDLSITE-0</a></b></a>',
'search Google for <a href="https://www.google.com.au/"><b>MDLSITE-0</b></a>' => 'search Google for <a href="https://www.google.com.au/"><b><a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDLSITE-0">MDLSITE-0</a></b></a>',

// Replaced cases by Tim's regexp
'MDL-123' => '<a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDL-123">MDL-123</a>',
'<b>MDL-123</b>' => '<b><a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDL-123">MDL-123</a></b>',
'See MDL-1 for details!' => 'See <a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDL-1">MDL-1</a> for details!',
'https://www.google.com.au/search?q=MDL-1' => 'https://www.google.com.au/search?q=<a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDL-1">MDL-1</a>',
'<a href="https://example.com">Link</a>https://www.google.com.au/search?q=MDL-123' => '<a href="https://example.com">Link</a>https://www.google.com.au/search?q=<a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDL-123">MDL-123</a>',
'search for MDL-123 on <a href="https://www.google.com.au/">Google</a>' => 'search for <a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDL-123">MDL-123</a> on <a href="https://www.google.com.au/">Google</a>',
'<br /> This should be working - MDL-123. Please vote for it if you\'d like... <br />' => '<br /> This should be working - <a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDL-123">MDL-123</a>. Please vote for it if you\'d like... <br />',
"The bug 'MDL-123' is > (more serious than)" => "The bug '<a title=\"Auto-link to Moodle Tracker\" href=\"https://tracker.moodle.org/browse/MDL-123\">MDL-123</a>' is > (more serious than)",
'MDL-123' => '<a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDL-123">MDL-123</a>',
'<b>MDL-123</b>' => '<b><a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDL-123">MDL-123</a></b>',
'See MDL-1 for details!' => 'See <a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDL-1">MDL-1</a> for details!',
'https://www.google.com.au/search?q=MDL-1' => 'https://www.google.com.au/search?q=<a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDL-1">MDL-1</a>',
'<a href="https://example.com">Link</a>https://www.google.com.au/search?q=MDL-123' => '<a href="https://example.com">Link</a>https://www.google.com.au/search?q=<a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDL-123">MDL-123</a>',
'search for MDL-123 on <a href="https://www.google.com.au/">Google</a>' => 'search for <a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDL-123">MDL-123</a> on <a href="https://www.google.com.au/">Google</a>',
'<br /> This should be working - MDL-123. Please vote for it if you\'d like... <br />' => '<br /> This should be working - <a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDL-123">MDL-123</a>. Please vote for it if you\'d like... <br />',
"The bug 'MDL-123' is > (more serious than)" => "The bug '<a title=\"Auto-link to Moodle Tracker\" href=\"https://moodle.atlassian.net/browse/MDL-123\">MDL-123</a>' is > (more serious than)",

// The texts like 'bug #123' or 'bug 123' should not be processed (MDLSITE-4019).
'Bug 123X' => 'Bug 123X',
Expand All @@ -121,11 +121,11 @@ function test_filter_tracker() {
'https://www.google.com.au/search?q=Bug 123' => 'https://www.google.com.au/search?q=Bug 123',

// Links to other projects (CONTRIB, MDLSITE, MDLQA, MDLTEST, MOBILE)
'CONTRIB-1234567890' => '<a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/CONTRIB-1234567890">CONTRIB-1234567890</a>',
'MDLSITE-0' => '<a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDLSITE-0">MDLSITE-0</a>',
'MDLQA-0' => '<a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDLQA-0">MDLQA-0</a>',
'MDLTEST-0' => '<a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MDLTEST-0">MDLTEST-0</a>',
'MOBILE-1234567890' => '<a title="Auto-link to Moodle Tracker" href="https://tracker.moodle.org/browse/MOBILE-1234567890">MOBILE-1234567890</a>',
'CONTRIB-1234567890' => '<a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/CONTRIB-1234567890">CONTRIB-1234567890</a>',
'MDLSITE-0' => '<a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDLSITE-0">MDLSITE-0</a>',
'MDLQA-0' => '<a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDLQA-0">MDLQA-0</a>',
'MDLTEST-0' => '<a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MDLTEST-0">MDLTEST-0</a>',
'MOBILE-1234567890' => '<a title="Auto-link to Moodle Tracker" href="https://moodle.atlassian.net/browse/MOBILE-1234567890">MOBILE-1234567890</a>',
);

$filter = new testable_filter_moodlelinks();
Expand Down