From 4bbb292bbb4ae2bcaded7021b2097e1bf81ed6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 20 Jan 2025 12:15:18 -0300 Subject: [PATCH 1/4] Remove backport. --- scripts/file-entities.php | 44 ++++++--------------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/scripts/file-entities.php b/scripts/file-entities.php index 8b0d697a3..8916973d3 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: @@ -35,10 +35,6 @@ # 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 @@ -49,8 +45,6 @@ */ -const BACKPORT = false; // TODO remove, see above. - // Setup ini_set( 'display_errors' , 1 ); @@ -94,7 +88,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 +106,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 ); @@ -214,9 +201,6 @@ function generate_list_entities( string $root , string $lang ) } $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 +219,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"; @@ -268,11 +250,7 @@ function list_entities_recurse( string $root , array $dirs ) { // pushEntity( $name , text: $text ); // See TODO item 2 // LIBXML_PARSEHUGE - if ( BACKPORT ) - $path = "$dir/../entities.$last.xml"; - else - $path = __DIR__ . "/../temp/file-entities." . implode( '.' , $dirs ) . ".ent"; - + $path = __DIR__ . "/../temp/file-entities." . implode( '.' , $dirs ) . ".ent"; file_put_contents( $path , $text ); $path = realpain( $path ); pushEntity( $name , path: $path ); @@ -292,20 +270,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 ); } From a75f5a0423a6b68147dff5e0f190bda34756a96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 20 Jan 2025 15:52:17 -0300 Subject: [PATCH 2/4] Detect build breakage on case insensitive file systems --- scripts/file-entities.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/scripts/file-entities.php b/scripts/file-entities.php index 8916973d3..83c34dc48 100644 --- a/scripts/file-entities.php +++ b/scripts/file-entities.php @@ -80,7 +80,8 @@ echo "Creating file-entities.ent... "; -$entities = []; // See pushEntity() +$entities = []; +$mixedCase = []; generate_file_entities( $root , "en" ); generate_list_entities( $root , "en" ); @@ -125,6 +126,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 ); @@ -134,8 +136,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 ) @@ -145,7 +164,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; @@ -197,7 +216,7 @@ 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; From f2954edd3761d199b397903d89735a20ceece90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Mon, 20 Jan 2025 16:13:11 -0300 Subject: [PATCH 3/4] Do not generate individual entity files for directories --- configure.php | 20 +++++++++++++------- scripts/file-entities.php | 27 +++++++++------------------ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/configure.php b/configure.php index c7873d339..b391062fa 100755 --- a/configure.php +++ b/configure.php @@ -827,14 +827,19 @@ 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 { + static $documentURI = ""; + if ( $baseURI != "" ) + $documentURI = $baseURI; + $filename = realpath( $filename ); $options = LIBXML_NOENT | LIBXML_COMPACT | LIBXML_BIGLINES | LIBXML_PARSEHUGE; - return $dom->load( $filename , $options ); + $ret = $dom->load( $filename , $options ); + + if ( $documentURI != "" ) + $dom->documentURI = $documentURI; + return $ret; } function dom_saveload( DOMDocument $dom , string $filename = "" ) : string @@ -849,8 +854,10 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string } echo "Loading and parsing {$ac["INPUT_FILENAME"]}... "; +$dom = new DOMDocument(); +$docpath = "{$ac['srcdir']}/{$ac["INPUT_FILENAME"]}"; -if ( dom_load( $dom , "{$ac['srcdir']}/{$ac["INPUT_FILENAME"]}" ) ) +if ( dom_load( $dom , $docpath , $docpath ) ) { dom_saveload( $dom ); // correct file/line/column on error messages echo "done.\n"; @@ -862,7 +869,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 83c34dc48..679dc961c 100644 --- a/scripts/file-entities.php +++ b/scripts/file-entities.php @@ -33,16 +33,6 @@ - doc-base/temp/file-entites.ent - doc-base/temp/file-entites.dir.dir.ent -# TODO - -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. - */ // Setup @@ -266,14 +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 - - $path = __DIR__ . "/../temp/file-entities." . implode( '.' , $dirs ) . ".ent"; - file_put_contents( $path , $text ); - $path = realpain( $path ); - pushEntity( $name , path: $path ); - } + pushEntity( $name , text: $text ); + +// 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 ) { From 519174443e69d219bbe691e42d563327fba3f940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Wed, 22 Jan 2025 15:56:22 -0300 Subject: [PATCH 4/4] Setting documentURI cause fails on Windows --- configure.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/configure.php b/configure.php index b391062fa..c71f8fd62 100755 --- a/configure.php +++ b/configure.php @@ -829,17 +829,9 @@ function xml_configure() function dom_load( DOMDocument $dom , string $filename , string $baseURI = "" ) : bool { - static $documentURI = ""; - if ( $baseURI != "" ) - $documentURI = $baseURI; - $filename = realpath( $filename ); $options = LIBXML_NOENT | LIBXML_COMPACT | LIBXML_BIGLINES | LIBXML_PARSEHUGE; - $ret = $dom->load( $filename , $options ); - - if ( $documentURI != "" ) - $dom->documentURI = $documentURI; - return $ret; + return $dom->load( $filename , $options ); } function dom_saveload( DOMDocument $dom , string $filename = "" ) : string @@ -855,9 +847,8 @@ function dom_saveload( DOMDocument $dom , string $filename = "" ) : string echo "Loading and parsing {$ac["INPUT_FILENAME"]}... "; $dom = new DOMDocument(); -$docpath = "{$ac['srcdir']}/{$ac["INPUT_FILENAME"]}"; -if ( dom_load( $dom , $docpath , $docpath ) ) +if ( dom_load( $dom , "{$ac['srcdir']}/{$ac["INPUT_FILENAME"]}" ) ) { dom_saveload( $dom ); // correct file/line/column on error messages echo "done.\n";