- if ( $local ) {
- $sectionTitle = new TitleValue( NS_MAIN, '', $section );
- } else {
- $sectionTitle = $title->createFragmentTarget( $section );
- }
- if ( $sectionTitle ) {
+ // 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 !== '' && $section !== false ) {
+ if ( $local ) {
+ $sectionTitle = new TitleValue( NS_MAIN, '', $section );
+ } else {
+ $sectionTitle = $title->createFragmentTarget( $section );
+ }