diff --git a/configure.php b/configure.php index 18e680d3f..cc8415c66 100755 --- a/configure.php +++ b/configure.php @@ -827,10 +827,7 @@ function xml_configure() checking('whether to save an invalid .manual.xml'); checkvalue($ac['FORCE_DOM_SAVE']); - -$dom = new DOMDocument(); - -function dom_load( DOMDocument $dom , string $filename ) : bool +function dom_load( DOMDocument $dom , string $filename , string $baseURI = "" ) : bool { $filename = realpath( $filename ); $options = LIBXML_NOENT | LIBXML_COMPACT | LIBXML_BIGLINES | LIBXML_PARSEHUGE; @@ -849,6 +846,7 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string } echo "Loading and parsing {$ac["INPUT_FILENAME"]}... "; +$dom = new DOMDocument(); if ( dom_load( $dom , "{$ac['srcdir']}/{$ac["INPUT_FILENAME"]}" ) ) { @@ -862,7 +860,6 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string errors_are_bad(1); } - echo "Running XInclude/XPointer... "; $total = xinclude_run_byid( $dom ); diff --git a/scripts/file-entities.php b/scripts/file-entities.php index ac77f442d..08a2e2fc4 100644 --- a/scripts/file-entities.php +++ b/scripts/file-entities.php @@ -20,7 +20,7 @@ This script creates various "file entities", that is, DTD entities that point to files and file listings, named and composed of: -- dir.dir.file : pulls in a dir/dir/file.xml file +- dir.dir.file : pulls in a dir/dir/file.xml - dir.dif.entities.dir : pulls in all files of dir/dir/dir/*.xml In the original file-entities.php.in, the files are created at: @@ -33,24 +33,8 @@ - doc-base/temp/file-entites.ent - doc-base/temp/file-entites.dir.dir.ent -# TODO - -1. Leave this running in new idempotent mode for a few months, before -erasing the const BACKPORT, that exists only to replicate the old -style build. - -2. Istead of creating ~thousand doc-base/temp/file-entites.*.ent files, -output an solid XML grouped file (per github.com/php/doc-base/pull/183) -so it would be possible to detect accidental overwriting of structural -entities, the "list of entities" moved to/as normal entity text. PS: This -will NOT work, with libxml recusing to load .manuxal.xml.in because of an -"Detected an entity reference loop", that does not exist. Sigh. PPS: May -be possible with LIBXML_PARSEHUGE after all. - */ -const BACKPORT = false; // TODO remove, see above. - // Setup ini_set( 'display_errors' , 1 ); @@ -86,7 +70,8 @@ echo "Creating file-entities.ent... "; -$entities = []; // See pushEntity() +$entities = []; +$mixedCase = []; generate_file_entities( $root , "en" ); generate_list_entities( $root , "en" ); @@ -94,7 +79,6 @@ if ( $lang != "" ) generate_file_entities( $root , $lang ); -// TODO BACKPORT: Fixed relative path, move this directly into manual.xml.in pushEntity( "global.function-index", path: realpain( __DIR__ . "/.." ) . "/funcindex.xml" ); if ( ! $chmonly ) @@ -113,13 +97,7 @@ fputs( $file , "\n\n" ); -if ( BACKPORT ) - fputs( $file , "\n" ); - -if ( BACKPORT ) - asort( $entities ); -else - ksort( $entities ); +ksort( $entities ); foreach ( $entities as $ent ) writeEntity( $file , $ent ); @@ -138,6 +116,7 @@ function __construct( public string $name , public string $text , public string function pushEntity( string $name , string $text = '' , string $path = '' ) { global $entities; + global $mixedCase; $name = str_replace( '_' , '-' , $name ); $path = str_replace( '\\' , '/' , $path ); @@ -147,8 +126,25 @@ function pushEntity( string $name , string $text = '' , string $path = '' ) if ( ( $text == "" && $path == "" ) || ( $text != "" && $path != "" ) ) { echo "Something went wrong on file-entities.php.\n"; - exit(-1); + exit( 1 ); } + + $lname = strtolower( $name ); + if ( isset( $mixedCase[ $lname ] ) && $mixedCase[ $lname ] != $name ) + { + echo "\n\n"; + echo "BROKEN BUILD on case insensitive file systems!\n"; + echo "Detected distinct file entities only by case:\n"; + echo " - {$mixedCase[ $lname ]}\n"; + echo " - $name \n"; + echo "This will PERMANENTLY BRICK manual build on Windows machines!\n"; + echo "Avoid committing this on repository, and if it's already committed,\n"; + echo "revert and send a heads up on mailinst how to fix the issue.\n\n"; + echo "See https://github.com/php/doc-en/pull/4330#issuecomment-2557306828"; + echo "\n\n"; + exit( 1 ); + } + $mixedCase[ $lname ] = $name; } function generate_file_entities( string $root , string $lang ) @@ -158,7 +154,7 @@ function generate_file_entities( string $root , string $lang ) if ( $test === false || is_dir( $path ) == false ) { echo "Language directory not found: $path\n."; - exit(-1); + exit( 1 ); } $path = $test; @@ -210,13 +206,10 @@ function generate_list_entities( string $root , string $lang ) if ( $test === false || is_dir( $path ) == false ) { echo "Language directory not found: $path\n."; - exit(-1); + exit( 1 ); } $path = $test; - if ( BACKPORT ) // Spurious file generated outside reference/ - pushEntity( "language.predefined.entities.weakreference", path: "$root/$lang/language/predefined/entities.weakreference.xml" ); - $dirs = [ "reference" ]; list_entities_recurse( $path , $dirs ); } @@ -235,8 +228,6 @@ function list_entities_recurse( string $root , array $dirs ) continue; if ( $file[0] == "." ) continue; - if ( BACKPORT && str_starts_with( $file , "entities.") ) - continue; $path = "$dir/$file"; @@ -265,18 +256,15 @@ function list_entities_recurse( string $root , array $dirs ) $text = implode( "\n" , $list ); if ( $text != "" ) - { - // pushEntity( $name , text: $text ); // See TODO item 2 // LIBXML_PARSEHUGE + pushEntity( $name , text: $text ); - if ( BACKPORT ) - $path = "$dir/../entities.$last.xml"; - else - $path = __DIR__ . "/../temp/file-entities." . implode( '.' , $dirs ) . ".ent"; - - file_put_contents( $path , $text ); - $path = realpain( $path ); - pushEntity( $name , path: $path ); - } +// Old style, pre LIBXML_PARSEHUGE, "directory" entity as external file +// +// $path = __DIR__ . "/../temp/file-entities." . implode( '.' , $dirs ) . ".ent"; +// file_put_contents( $path , $text ); +// $path = realpain( $path ); +// pushEntity( $name , path: $path ); +// foreach( $subdirs as $subdir ) { @@ -292,20 +280,10 @@ function writeEntity( $file , Entity $ent ) $text = $ent->text; $path = $ent->path; - if ( BACKPORT ) - { - if ( $path == "" ) - $line = sprintf("\n" , $name ); // was on original, possibly unused - else - $line = sprintf("\n" , $name , $path ); - } + if ( $path == "" ) + $line = "\n"; else - { - if ( $path == "" ) - $line = "\n"; - else - $line = "\n"; - } + $line = "\n"; fwrite( $file , $line ); }