Merge "Enable configuration to supply options for Special:Search form"
[lhc/web/wiklou.git] / includes / Linker.php
index ff4c786..4d684b5 100644 (file)
@@ -1232,6 +1232,14 @@ class Linker {
                                                $sectionText = str_replace( '[[', '[[', $auto );
 
                                                $section = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 );
+                                               // Support: HHVM (T222857)
+                                               // The guessSectionNameFromStrippedText method returns a non-empty string
+                                               // that starts with "#". Before PHP 7 (and still on HHVM) substr() would
+                                               // return false if the start offset is the end of the string.
+                                               // On PHP 7+, it gracefully returns empty string instead.
+                                               if ( $section === false ) {
+                                                       $section = '';
+                                               }
                                                if ( $local ) {
                                                        $sectionTitle = new TitleValue( NS_MAIN, '', $section );
                                                } else {