Skip to content

Commit 72e77c9

Browse files
flodoloTheoChevalier
authored andcommitted
Fixes #775 and #741 - Run PHP linter on cache files (#776)
* Run PHP linter on cache files Also make sure to always build en-US Gaia cache * Run check also in single locale mode
1 parent 792eae9 commit 72e77c9

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

app/scripts/glossaire.sh

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function updateStandardRepo() {
168168

169169
updated_english=false
170170

171-
# Store md5 of the existing cache before updating the repositories
171+
# Store md5 of the existing en-US cache before updating the repositories
172172
cache_file="${root}TMX/en-US/cache_en-US_${repo_name}.php"
173173
if [ -f $cache_file ]
174174
then
@@ -224,6 +224,14 @@ function updateStandardRepo() {
224224
then
225225
echored "Cache doesn't exist for ${repo_name}/${locale}"
226226
updated_locale=1
227+
else
228+
php -l $cache_file 2>&1 1>/dev/null
229+
if [ $? -ne 0 ]
230+
then
231+
# There are PHP errors, force the rebuild
232+
echored "PHP errors in $cache_file. Forcing rebuild."
233+
updated_locale=1
234+
fi
227235
fi
228236

229237
if [ "$forceTMX" = true -o "$updated_english" = true -o "$updated_locale" -eq 1 ]
@@ -249,6 +257,14 @@ function updateStandardRepo() {
249257
then
250258
echored "Cache doesn't exist for ${repo_name}/${locale_code}"
251259
updated_locale=1
260+
else
261+
php -l $cache_file 2>&1 1>/dev/null
262+
if [ $? -ne 0 ]
263+
then
264+
# There are PHP errors, force the rebuild
265+
echored "PHP errors in $cache_file. Forcing rebuild."
266+
updated_locale=1
267+
fi
252268
fi
253269

254270
if [ "$forceTMX" = true -o "$updated_english" = true -o "$updated_locale" -eq 1 ]
@@ -300,11 +316,12 @@ function updateGaiaRepo() {
300316
existing_md5=0
301317
fi
302318

303-
# Update en-US and build its TMX
319+
# Update en-US, build its TMX and compare md5 hash
304320
if [ "$checkrepo" = true ]
305321
then
306322
updateLocale ${!repo_name} en-US $repo_name/en-US
307323
fi
324+
buildCache en-US
308325
updated_md5=($(md5sum $cache_file))
309326
if [ $existing_md5 != $updated_md5 ]
310327
then
@@ -335,6 +352,14 @@ function updateGaiaRepo() {
335352
then
336353
echored "Cache doesn't exist for ${repo_name}/${locale}"
337354
updated_locale=1
355+
else
356+
php -l $cache_file 2>&1 1>/dev/null
357+
if [ $? -ne 0 ]
358+
then
359+
# There are PHP errors, force the rebuild
360+
echored "PHP errors in $cache_file. Forcing rebuild."
361+
updated_locale=1
362+
fi
338363
fi
339364

340365
if [ "$forceTMX" = true -o "$updated_english" = true -o "$updated_locale" -eq 1 ]
@@ -361,6 +386,14 @@ function updateGaiaRepo() {
361386
then
362387
echored "Cache doesn't exist for ${repo_name}/${locale_code}"
363388
updated_locale=1
389+
else
390+
php -l $cache_file 2>&1 1>/dev/null
391+
if [ $? -ne 0 ]
392+
then
393+
# There are PHP errors, force the rebuild
394+
echored "PHP errors in $cache_file. Forcing rebuild."
395+
updated_locale=1
396+
fi
364397
fi
365398

366399
if [ "$forceTMX" = true -o "$updated_english" = true -o "$updated_locale" -eq 1 ]

0 commit comments

Comments
 (0)