- array( 'Linker', 'formatAutocommentsCallback' ),
- $comment );
- self::$autocommentTitle = null;
- self::$autocommentLocal = null;
- return $comment;
- }
-
- /**
- * Helper function for Linker::formatAutocomments
- * @param array $match
- * @return string
- */
- private static function formatAutocommentsCallback( $match ) {
- global $wgLang;
- $title = self::$autocommentTitle;
- $local = self::$autocommentLocal;
-
- $pre = $match[1];
- $auto = $match[2];
- $post = $match[3];
- $comment = null;
- wfRunHooks( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
- if ( $comment === null ) {
- $link = '';
- if ( $title ) {
- $section = $auto;
-
- # Remove links that a user may have manually put in the autosummary
- # This could be improved by copying as much of Parser::stripSectionName as desired.
- $section = str_replace( '[[:', '', $section );
- $section = str_replace( '[[', '', $section );
- $section = str_replace( ']]', '', $section );
-
- $section = Sanitizer::normalizeSectionNameWhitespace( $section ); # bug 22784
- if ( $local ) {
- $sectionTitle = Title::newFromText( '#' . $section );
- } else {
- $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
- $title->getDBkey(), $section );
- }
- if ( $sectionTitle ) {
- $link = self::link( $sectionTitle,
- $wgLang->getArrow(), array(), array(),
- 'noclasses' );
- } else {
+ function ( $match ) use ( $title, $local ) {
+ global $wgLang;
+
+ $pre = $match[1];
+ $auto = $match[2];
+ $post = $match[3];
+ $comment = null;
+ wfRunHooks( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
+ if ( $comment === null ) {