Skip to content

Commit 8ea9c3a

Browse files
committed
Prevent doc-lang entities loading when doc-en file removed
1 parent 7a829a4 commit 8ea9c3a

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

scripts/file-entities.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,17 @@
8787

8888
$entities = [];
8989
$mixedCase = [];
90+
$englishEntities = null;
9091

9192
generate_file_entities( $root , "en" );
9293
generate_list_entities( $root , "en" );
9394

94-
if ( $lang != "" )
95-
generate_file_entities( $root , $lang );
96-
9795
pushEntity( "global.function-index", path: realpain( __DIR__ . "/.." ) . "/funcindex.xml" );
9896

97+
$englishEntities = $entities;
98+
if ( $lang && $lang !== "en" )
99+
generate_file_entities( $root , $lang );
100+
99101
if ( ! $chmonly )
100102
foreach( $entities as $ent )
101103
if ( str_starts_with( $ent->name , "chmonly." ) )
@@ -134,9 +136,19 @@ function pushEntity( string $name , string $text = '' , string $path = '' )
134136
{
135137
global $entities;
136138
global $mixedCase;
139+
global $englishEntities;
137140

138141
$name = str_replace( '_' , '-' , $name );
139142
$path = str_replace( '\\' , '/' , $path );
143+
144+
// Prevents doc-en to load entities from doc-lang. Resulting in it rendering
145+
// a different language when the underlying doc-en XML file has been removed.
146+
if ( $englishEntities !== null && ! isset( $englishEntities[ $name ] ) )
147+
{
148+
$text = ' ';
149+
$path = '';
150+
}
151+
140152
$ent = new Entity( $name , $text , $path );
141153
$entities[ $name ] = $ent;
142154

0 commit comments

Comments
 (0)