Skip to content

Commit a4884fb

Browse files
authored
Remove backports, alert for insensitive file systems, and bundled file entity for directories (#213)
* Remove backport. * Detect build breakage on case insensitive file systems * Do not generate individual entity files for directories * Setting documentURI cause fails on Windows
1 parent b12b9bb commit a4884fb

File tree

2 files changed

+38
-63
lines changed

2 files changed

+38
-63
lines changed

configure.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,10 +827,7 @@ function xml_configure()
827827
checking('whether to save an invalid .manual.xml');
828828
checkvalue($ac['FORCE_DOM_SAVE']);
829829

830-
831-
$dom = new DOMDocument();
832-
833-
function dom_load( DOMDocument $dom , string $filename ) : bool
830+
function dom_load( DOMDocument $dom , string $filename , string $baseURI = "" ) : bool
834831
{
835832
$filename = realpath( $filename );
836833
$options = LIBXML_NOENT | LIBXML_COMPACT | LIBXML_BIGLINES | LIBXML_PARSEHUGE;
@@ -849,6 +846,7 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string
849846
}
850847

851848
echo "Loading and parsing {$ac["INPUT_FILENAME"]}... ";
849+
$dom = new DOMDocument();
852850

853851
if ( dom_load( $dom , "{$ac['srcdir']}/{$ac["INPUT_FILENAME"]}" ) )
854852
{
@@ -862,7 +860,6 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string
862860
errors_are_bad(1);
863861
}
864862

865-
866863
echo "Running XInclude/XPointer... ";
867864

868865
$total = xinclude_run_byid( $dom );

scripts/file-entities.php

Lines changed: 36 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
This script creates various "file entities", that is, DTD entities that
2121
point to files and file listings, named and composed of:
2222
23-
- dir.dir.file : pulls in a dir/dir/file.xml file
23+
- dir.dir.file : pulls in a dir/dir/file.xml
2424
- dir.dif.entities.dir : pulls in all files of dir/dir/dir/*.xml
2525
2626
In the original file-entities.php.in, the files are created at:
@@ -33,24 +33,8 @@
3333
- doc-base/temp/file-entites.ent
3434
- doc-base/temp/file-entites.dir.dir.ent
3535
36-
# TODO
37-
38-
1. Leave this running in new idempotent mode for a few months, before
39-
erasing the const BACKPORT, that exists only to replicate the old
40-
style build.
41-
42-
2. Istead of creating ~thousand doc-base/temp/file-entites.*.ent files,
43-
output an solid XML grouped file (per github.com/php/doc-base/pull/183)
44-
so it would be possible to detect accidental overwriting of structural
45-
entities, the "list of entities" moved to/as normal entity text. PS: This
46-
will NOT work, with libxml recusing to load .manuxal.xml.in because of an
47-
"Detected an entity reference loop", that does not exist. Sigh. PPS: May
48-
be possible with LIBXML_PARSEHUGE after all.
49-
5036
*/
5137

52-
const BACKPORT = false; // TODO remove, see above.
53-
5438
// Setup
5539

5640
ini_set( 'display_errors' , 1 );
@@ -86,15 +70,15 @@
8670

8771
echo "Creating file-entities.ent... ";
8872

89-
$entities = []; // See pushEntity()
73+
$entities = [];
74+
$mixedCase = [];
9075

9176
generate_file_entities( $root , "en" );
9277
generate_list_entities( $root , "en" );
9378

9479
if ( $lang != "" )
9580
generate_file_entities( $root , $lang );
9681

97-
// TODO BACKPORT: Fixed relative path, move this directly into manual.xml.in
9882
pushEntity( "global.function-index", path: realpain( __DIR__ . "/.." ) . "/funcindex.xml" );
9983

10084
if ( ! $chmonly )
@@ -113,13 +97,7 @@
11397

11498
fputs( $file , "<!-- DON'T TOUCH - AUTOGENERATED BY file-entities.php -->\n\n" );
11599

116-
if ( BACKPORT )
117-
fputs( $file , "\n" );
118-
119-
if ( BACKPORT )
120-
asort( $entities );
121-
else
122-
ksort( $entities );
100+
ksort( $entities );
123101

124102
foreach ( $entities as $ent )
125103
writeEntity( $file , $ent );
@@ -138,6 +116,7 @@ function __construct( public string $name , public string $text , public string
138116
function pushEntity( string $name , string $text = '' , string $path = '' )
139117
{
140118
global $entities;
119+
global $mixedCase;
141120

142121
$name = str_replace( '_' , '-' , $name );
143122
$path = str_replace( '\\' , '/' , $path );
@@ -147,8 +126,25 @@ function pushEntity( string $name , string $text = '' , string $path = '' )
147126
if ( ( $text == "" && $path == "" ) || ( $text != "" && $path != "" ) )
148127
{
149128
echo "Something went wrong on file-entities.php.\n";
150-
exit(-1);
129+
exit( 1 );
151130
}
131+
132+
$lname = strtolower( $name );
133+
if ( isset( $mixedCase[ $lname ] ) && $mixedCase[ $lname ] != $name )
134+
{
135+
echo "\n\n";
136+
echo "BROKEN BUILD on case insensitive file systems!\n";
137+
echo "Detected distinct file entities only by case:\n";
138+
echo " - {$mixedCase[ $lname ]}\n";
139+
echo " - $name \n";
140+
echo "This will PERMANENTLY BRICK manual build on Windows machines!\n";
141+
echo "Avoid committing this on repository, and if it's already committed,\n";
142+
echo "revert and send a heads up on mailinst how to fix the issue.\n\n";
143+
echo "See https://github.com/php/doc-en/pull/4330#issuecomment-2557306828";
144+
echo "\n\n";
145+
exit( 1 );
146+
}
147+
$mixedCase[ $lname ] = $name;
152148
}
153149

154150
function generate_file_entities( string $root , string $lang )
@@ -158,7 +154,7 @@ function generate_file_entities( string $root , string $lang )
158154
if ( $test === false || is_dir( $path ) == false )
159155
{
160156
echo "Language directory not found: $path\n.";
161-
exit(-1);
157+
exit( 1 );
162158
}
163159
$path = $test;
164160

@@ -210,13 +206,10 @@ function generate_list_entities( string $root , string $lang )
210206
if ( $test === false || is_dir( $path ) == false )
211207
{
212208
echo "Language directory not found: $path\n.";
213-
exit(-1);
209+
exit( 1 );
214210
}
215211
$path = $test;
216212

217-
if ( BACKPORT ) // Spurious file generated outside reference/
218-
pushEntity( "language.predefined.entities.weakreference", path: "$root/$lang/language/predefined/entities.weakreference.xml" );
219-
220213
$dirs = [ "reference" ];
221214
list_entities_recurse( $path , $dirs );
222215
}
@@ -235,8 +228,6 @@ function list_entities_recurse( string $root , array $dirs )
235228
continue;
236229
if ( $file[0] == "." )
237230
continue;
238-
if ( BACKPORT && str_starts_with( $file , "entities.") )
239-
continue;
240231

241232
$path = "$dir/$file";
242233

@@ -265,18 +256,15 @@ function list_entities_recurse( string $root , array $dirs )
265256
$text = implode( "\n" , $list );
266257

267258
if ( $text != "" )
268-
{
269-
// pushEntity( $name , text: $text ); // See TODO item 2 // LIBXML_PARSEHUGE
259+
pushEntity( $name , text: $text );
270260

271-
if ( BACKPORT )
272-
$path = "$dir/../entities.$last.xml";
273-
else
274-
$path = __DIR__ . "/../temp/file-entities." . implode( '.' , $dirs ) . ".ent";
275-
276-
file_put_contents( $path , $text );
277-
$path = realpain( $path );
278-
pushEntity( $name , path: $path );
279-
}
261+
// Old style, pre LIBXML_PARSEHUGE, "directory" entity as external file
262+
//
263+
// $path = __DIR__ . "/../temp/file-entities." . implode( '.' , $dirs ) . ".ent";
264+
// file_put_contents( $path , $text );
265+
// $path = realpain( $path );
266+
// pushEntity( $name , path: $path );
267+
//
280268

281269
foreach( $subdirs as $subdir )
282270
{
@@ -292,20 +280,10 @@ function writeEntity( $file , Entity $ent )
292280
$text = $ent->text;
293281
$path = $ent->path;
294282

295-
if ( BACKPORT )
296-
{
297-
if ( $path == "" )
298-
$line = sprintf("<!ENTITY %-40s ''>\n" , $name ); // was on original, possibly unused
299-
else
300-
$line = sprintf("<!ENTITY %-40s SYSTEM 'file:///%s'>\n" , $name , $path );
301-
}
283+
if ( $path == "" )
284+
$line = "<!ENTITY $name '$text'>\n";
302285
else
303-
{
304-
if ( $path == "" )
305-
$line = "<!ENTITY $name '$text'>\n";
306-
else
307-
$line = "<!ENTITY $name SYSTEM '$path'>\n";
308-
}
286+
$line = "<!ENTITY $name SYSTEM '$path'>\n";
309287

310288
fwrite( $file , $line );
311289
}

0 commit comments

Comments
 (0)