Skip to content

Commit 181ecbe

Browse files
authored
Make broken detection strict, more descriptive messages (#220)
1 parent 0ae92dd commit 181ecbe

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

scripts/broken.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
the test is applied in all .xml files in directory and sub directories.
2121
2222
This tool also cares for directories marked with .xmlfragmentdir, so
23-
theses files are tested in relaxed semantics for XML fragments. */
23+
theses files are tested in relaxed semantics for XML Fragments. */
2424

2525
ini_set( 'display_errors' , 1 );
2626
ini_set( 'display_startup_errors' , 1 );
@@ -78,6 +78,24 @@ function setup( string & $prefix , string & $suffix , string & $extra )
7878

7979
function testFile( string $filename , bool $fragment = false )
8080
{
81+
$contents = file_get_contents( $filename );
82+
83+
if ( str_starts_with( $contents , b"\xEF\xBB\xBF" ) )
84+
{
85+
echo "Wrong XML file:\n";
86+
echo " Path: $filename\n";
87+
echo " Error: XML file with BOM. Several tools may misbehave.\n";
88+
echo "\n";
89+
}
90+
91+
if ( PHP_EOL == "\n" && str_contains( $contents , "\r") )
92+
{
93+
echo "Wrong XML file:\n";
94+
echo " Path: $filename\n";
95+
echo " Error: XML file contains \\r. Several tools may misbehave.\n";
96+
echo "\n";
97+
}
98+
8199
static $prefix = "", $suffix = "", $extra = "";
82100
if ( $extra == "" )
83101
setup( $prefix , $suffix , $extra );
@@ -88,7 +106,6 @@ function testFile( string $filename , bool $fragment = false )
88106
$doc->substituteEntities = false;
89107
libxml_use_internal_errors( true );
90108

91-
$contents = file_get_contents( $filename );
92109
if ( $fragment )
93110
$contents = "<f>{$contents}</f>";
94111
$doc->loadXML( $contents );

scripts/file-entities.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,33 @@ function pushEntity( string $name , string $text = '' , string $path = '' )
147147
$lname = strtolower( $name );
148148
if ( isset( $mixedCase[ $lname ] ) && $mixedCase[ $lname ] != $name )
149149
{
150-
echo "\n\n";
151-
echo "BROKEN BUILD on case insensitive file systems!\n";
152-
echo "Detected distinct file entities only by case:\n";
153-
echo " - {$mixedCase[ $lname ]}\n";
154-
echo " - $name \n";
155-
echo "This will PERMANENTLY BRICK manual build on Windows machines!\n";
156-
echo "Avoid committing this on repository, and if it's already committed,\n";
157-
echo "revert and send a heads up on mailinst how to fix the issue.\n\n";
158-
echo "See https://github.com/php/doc-en/pull/4330#issuecomment-2557306828";
159-
echo "\n\n";
150+
echo <<<END
151+
\n\n
152+
BROKEN BUILD on case insensitive file systems!
153+
154+
Detected file entities names, distinct only by case:
155+
- {$mixedCase[ $lname ]}
156+
- $name
157+
158+
This may PERMANENTLY BRICK manual build on Windows machines!
159+
160+
If you are seeing this message building doc-en, avoid committing any changes
161+
on repository, and if it's already committed, revert and send a heads up on
162+
mail lists, on how to fix the issue (refer to this message).
163+
164+
If you are seeing this message building a translation, this means that the
165+
translation may have files or directories that differ from doc-en only by
166+
upper or lower case letters. Find these differences and fix them at the git
167+
level ('git mv"). After, delete the files and 'git restore' them, to see if
168+
the 'git mv' worked.
169+
170+
This message only may be visible on non-Windows machines. Mixed cases inside
171+
a repository, or between repositories, may only cause difficult to debug build
172+
failures on Windows, without any other information. There is no easy fix for
173+
this than a complete new checkout of the affected repository.
174+
175+
See: https://github.com/php/doc-en/pull/4330#issuecomment-2557306828\n\n
176+
END;
160177
exit( 1 );
161178
}
162179
$mixedCase[ $lname ] = $name;

0 commit comments

Comments
 (0)