diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php
index 98e090e515..91c8bf2beb 100644
--- a/libraries/Advisor.class.php
+++ b/libraries/Advisor.class.php
@@ -244,9 +244,9 @@ class Advisor
);
// Replaces external Links with PMA_linkURL() generated links
- $rule['recommendation'] = preg_replace(
- '#href=("|\')(https?://[^\1]+)\1#ie',
- '\'href="\' . PMA_linkURL("\2") . \'"\'',
+ $rule['recommendation'] = preg_replace_callback(
+ '#href=("|\')(https?://[^\1]+)\1#i',
+ array($this, '_replaceLinkURL'),
$rule['recommendation']
);
break;
@@ -255,6 +255,18 @@ class Advisor
$this->runResult[$type][] = $rule;
}
+ /**
+ * Callback for wrapping links with PMA_linkURL
+ *
+ * @param array $matches List of matched elements form preg_replace_callback
+ *
+ * @return Replacement value
+ */
+ private function _replaceLinkURL($matches)
+ {
+ return 'href="' . PMA_linkURL($matches[2]) . '"';
+ }
+
/**
* Callback for evaluating fired() condition.
*
diff --git a/test/classes/PMA_Advisor_test.php b/test/classes/PMA_Advisor_test.php
index c3c44186e6..e5cf9bb934 100644
--- a/test/classes/PMA_Advisor_test.php
+++ b/test/classes/PMA_Advisor_test.php
@@ -178,6 +178,22 @@ class Advisor_test extends PHPUnit_Framework_TestCase
array(),
'Failed formatting string for rule \'Failure\'. PHP threw following error: Use of undefined constant fsafdsa - assumed \'fsafdsa\'',
),
+ array(
+ array(
+ 'justification' => 'Version string (%s) | value',
+ 'name' => 'Distribution',
+ 'issue' => 'official MySQL binaries.',
+ 'recommendation' => 'See web',
+ ),
+ array(
+ 'justification' => 'Version string (0)',
+ 'name' => 'Distribution',
+ 'issue' => 'official MySQL binaries.',
+ 'recommendation' => 'See web',
+ 'id' => 'Distribution'
+ ),
+ null,
+ ),
);
}
}