Skip to content

Commit

Permalink
MDL-69474 accessibility: page->url can be not set, protect against that
Browse files Browse the repository at this point in the history
Both in unit tests, but also in other areas (say blocks, for example)
it's possible that page->url has not been set yet.

So, let's change current code to always check if we have something
(page->url) to compare.

Note the use of has_set_url() is needed, because page->url is magic
method and it doesn't work as expected. Hate magics!
  • Loading branch information
stronk7 committed Mar 15, 2021
1 parent 695f753 commit f35e3f0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/outputrenderers.php
Expand Up @@ -2579,12 +2579,8 @@ protected function render_user_picture(user_picture $userpicture) {
}

// Then wrap it in link if needed. Also we don't wrap it in link if the link redirects to itself.
// It might not return page url in unit test.
if (PHPUNIT_TEST) {
if (!$userpicture->link ) {
return $output;
}
} else if (!$userpicture->link || $this->page->url == $url) {
if (!$userpicture->link ||
($this->page->has_set_url() && $this->page->url == $url)) { // Protect against unset page->url.
return $output;
}

Expand Down

0 comments on commit f35e3f0

Please sign in to comment.