@@ -645,7 +645,7 @@ static int php_brotli_compress_close(php_stream *stream,
645
645
}
646
646
} else {
647
647
php_error_docref (NULL , E_WARNING ,
648
- "brotli compress error " );
648
+ "brotli: failed to clean up compression " );
649
649
}
650
650
}
651
651
@@ -702,7 +702,7 @@ static ssize_t php_brotli_compress_write(php_stream *stream,
702
702
php_stream_write (self -> stream , output , out_size );
703
703
}
704
704
} else {
705
- php_error_docref (NULL , E_WARNING , "brotli compress error " );
705
+ php_error_docref (NULL , E_WARNING , "brotli: failed to compression " );
706
706
#if PHP_VERSION_ID >= 70400
707
707
return -1 ;
708
708
#endif
@@ -784,9 +784,18 @@ php_stream_brotli_opener(
784
784
}
785
785
if (level > BROTLI_MAX_QUALITY ) {
786
786
php_error_docref (NULL , E_WARNING ,
787
- "brotli: compression level (%d) must be less than %d" ,
788
- level , BROTLI_MAX_QUALITY );
787
+ "brotli: set compression level (%d)"
788
+ " to BROTLI_COMPRESS_LEVEL_MAX:"
789
+ " must be within %d..%d" ,
790
+ level , BROTLI_MIN_QUALITY , BROTLI_MAX_QUALITY );
789
791
level = BROTLI_MAX_QUALITY ;
792
+ } else if (level < BROTLI_MIN_QUALITY ) {
793
+ php_error_docref (NULL , E_WARNING ,
794
+ "brotli: set compression level (%d)"
795
+ " to BROTLI_COMPRESS_LEVEL_DEFAULT:"
796
+ " must be within %d..%d" ,
797
+ level , BROTLI_MIN_QUALITY , BROTLI_MAX_QUALITY );
798
+ level = BROTLI_DEFAULT_QUALITY ;
790
799
}
791
800
792
801
self = ecalloc (sizeof (* self ), 1 );
@@ -804,7 +813,7 @@ php_stream_brotli_opener(
804
813
if (php_brotli_context_create_encoder (& self -> ctx ,
805
814
level , 0 , 0 ) != SUCCESS ) {
806
815
php_error_docref (NULL , E_WARNING ,
807
- "brotli: compression context failed " );
816
+ "brotli: failed to prepare compression " );
808
817
php_stream_close (self -> stream );
809
818
efree (self );
810
819
return NULL ;
@@ -814,7 +823,7 @@ php_stream_brotli_opener(
814
823
} else {
815
824
if (php_brotli_context_create_decoder (& self -> ctx ) != SUCCESS ) {
816
825
php_error_docref (NULL , E_WARNING ,
817
- "brotli: decompression context failed " );
826
+ "brotli: failed to prepare decompression " );
818
827
php_stream_close (self -> stream );
819
828
efree (self );
820
829
return NULL ;
@@ -1272,7 +1281,7 @@ static ZEND_FUNCTION(brotli_compress_add)
1272
1281
#endif
1273
1282
if (ctx == NULL || ctx -> encoder == NULL ) {
1274
1283
php_error_docref (NULL , E_WARNING ,
1275
- "Brotli incremental compress resource failed " );
1284
+ "failed to prepare incremental compress " );
1276
1285
RETURN_FALSE ;
1277
1286
}
1278
1287
@@ -1301,7 +1310,7 @@ static ZEND_FUNCTION(brotli_compress_add)
1301
1310
efree (buffer );
1302
1311
smart_string_free (& out );
1303
1312
php_error_docref (NULL , E_WARNING ,
1304
- "Brotli incremental compress failed " );
1313
+ "failed to incremental compress" );
1305
1314
RETURN_FALSE ;
1306
1315
}
1307
1316
}
@@ -1325,7 +1334,7 @@ static ZEND_FUNCTION(brotli_compress_add)
1325
1334
efree (buffer );
1326
1335
smart_string_free (& out );
1327
1336
php_error_docref (NULL , E_WARNING ,
1328
- "Brotli incremental compress failed " );
1337
+ "failed to incremental compress" );
1329
1338
RETURN_FALSE ;
1330
1339
}
1331
1340
}
@@ -1356,8 +1365,7 @@ static ZEND_FUNCTION(brotli_uncompress)
1356
1365
1357
1366
BrotliDecoderState * state = BrotliDecoderCreateInstance (NULL , NULL , NULL );
1358
1367
if (!state ) {
1359
- php_error_docref (NULL , E_WARNING ,
1360
- "Invalid Brotli state" );
1368
+ php_error_docref (NULL , E_WARNING , "failed to prepare uncompress" );
1361
1369
RETURN_FALSE ;
1362
1370
}
1363
1371
@@ -1383,8 +1391,7 @@ static ZEND_FUNCTION(brotli_uncompress)
1383
1391
efree (buffer );
1384
1392
1385
1393
if (result != BROTLI_DECODER_RESULT_SUCCESS ) {
1386
- php_error_docref (NULL , E_WARNING ,
1387
- "Brotli decompress failed" );
1394
+ php_error_docref (NULL , E_WARNING , "failed to uncompress" );
1388
1395
smart_string_free (& out );
1389
1396
RETURN_FALSE ;
1390
1397
}
@@ -1403,7 +1410,7 @@ static ZEND_FUNCTION(brotli_uncompress_init)
1403
1410
1404
1411
if (php_brotli_context_create_decoder (ctx ) != SUCCESS ) {
1405
1412
php_error_docref (NULL , E_WARNING ,
1406
- "Brotli incremental uncompress init failed " );
1413
+ "failed to prepare incremental uncompress " );
1407
1414
RETURN_FALSE ;
1408
1415
}
1409
1416
}
@@ -1452,7 +1459,7 @@ static ZEND_FUNCTION(brotli_uncompress_add)
1452
1459
#endif
1453
1460
if (ctx == NULL || ctx -> decoder == NULL ) {
1454
1461
php_error_docref (NULL , E_WARNING ,
1455
- "Brotli incremental uncompress resource failed " );
1462
+ "failed to prepare incremental uncompress " );
1456
1463
RETURN_FALSE ;
1457
1464
}
1458
1465
0 commit comments