|
20 | 20 | This script creates various "file entities", that is, DTD entities that |
21 | 21 | point to files and file listings, named and composed of: |
22 | 22 |
|
23 | | -- dir.dir.file : pulls in a dir/dir/file.xml |
24 | | -- dir.dif.entities.dir : pulls in all files of dir/dir/dir/*.xml |
| 23 | +- dir.dir.file : pulls in a dir/dir/file.xml |
| 24 | +- dir.dif.entities.dir : pulls in XML files from dir/dir/dir/*.xml |
25 | 25 |
|
26 | 26 | In the original file-entities.php.in, the files are created at: |
27 | 27 |
|
|
31 | 31 | In new idempotent mode, files are created at: |
32 | 32 |
|
33 | 33 | - doc-base/temp/file-entites.ent |
34 | | -- doc-base/temp/file-entites.dir.dir.ent |
| 34 | +- doc-base/temp/file-entites/dir.dir.ent |
| 35 | +
|
| 36 | +The file entity for directories (file listings) are keep as individual |
| 37 | +files instead to avoid these libxml errors, in some OS/versions: |
| 38 | +
|
| 39 | +- Detected an entity reference loop [1] |
| 40 | +- Maximum entity amplification factor exceeded [2] |
| 41 | +
|
| 42 | +See LIBXML_LIMITS_HACK below. This workaround creates about a thousand |
| 43 | +files per running, that slowsdows even more the manual building on HDD |
| 44 | +systems. |
| 45 | +
|
| 46 | +[1] https://github.com/php/doc-base/pull/183 |
| 47 | +[2] https://github.com/php/doc-en/pull/4330 |
35 | 48 |
|
36 | 49 | */ |
37 | 50 |
|
|
43 | 56 | set_time_limit( 0 ); |
44 | 57 | ob_implicit_flush(); |
45 | 58 |
|
| 59 | +const LIBXML_LIMITS_HACK = true; |
| 60 | + |
46 | 61 | // Usage |
47 | 62 |
|
48 | 63 | $root = realpain( __DIR__ . "/../.." ); |
@@ -256,15 +271,20 @@ function list_entities_recurse( string $root , array $dirs ) |
256 | 271 | $text = implode( "\n" , $list ); |
257 | 272 |
|
258 | 273 | if ( $text != "" ) |
259 | | - pushEntity( $name , text: $text ); |
260 | | - |
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 | | -// |
| 274 | + { |
| 275 | + if ( LIBXML_LIMITS_HACK ) |
| 276 | + { |
| 277 | + static $entityDir = ""; |
| 278 | + if ( $entityDir == "" ) |
| 279 | + $entityDir = realpain( __DIR__ . "/../temp/file-entities" , mkdir: true ); |
| 280 | + |
| 281 | + $path = $entityDir . "/" . implode( '.' , $dirs ) . ".ent"; |
| 282 | + file_put_contents( $path , $text ); |
| 283 | + pushEntity( $name , path: $path ); |
| 284 | + } |
| 285 | + else |
| 286 | + pushEntity( $name , text: $text ); |
| 287 | + } |
268 | 288 |
|
269 | 289 | foreach( $subdirs as $subdir ) |
270 | 290 | { |
|
0 commit comments