Skip to content

Commit 52a9149

Browse files
committed
stream: re-order some errors and fix test
1 parent c3c270f commit 52a9149

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

ext/standard/file.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ PHP_FUNCTION(file_get_contents)
427427
}
428428

429429
if (offset != 0 && php_stream_seek(stream, offset, ((offset > 0) ? SEEK_SET : SEEK_END)) < 0) {
430-
php_error_docref(NULL, E_WARNING, "Failed to seek to position " ZEND_LONG_FMT " in the stream", offset);
431430
php_stream_close(stream);
432431
php_stream_error_operation_end(context);
432+
php_error_docref(NULL, E_WARNING, "Failed to seek to position " ZEND_LONG_FMT " in the stream", offset);
433433
RETURN_FALSE;
434434
}
435435

@@ -495,8 +495,8 @@ PHP_FUNCTION(file_put_contents)
495495

496496
if ((flags & LOCK_EX) && (!php_stream_supports_lock(stream) || php_stream_lock(stream, LOCK_EX))) {
497497
php_stream_close(stream);
498-
php_error_docref(NULL, E_WARNING, "Exclusive locks are not supported for this stream");
499498
php_stream_error_operation_end(context);
499+
php_error_docref(NULL, E_WARNING, "Exclusive locks are not supported for this stream");
500500
RETURN_FALSE;
501501
}
502502

@@ -1264,20 +1264,20 @@ PHP_FUNCTION(rename)
12641264
wrapper = php_stream_locate_url_wrapper(old_name, NULL, 0);
12651265

12661266
if (!wrapper || !wrapper->wops) {
1267-
php_error_docref(NULL, E_WARNING, "Unable to locate stream wrapper");
12681267
php_stream_error_operation_end(context);
1268+
php_error_docref(NULL, E_WARNING, "Unable to locate stream wrapper");
12691269
RETURN_FALSE;
12701270
}
12711271

12721272
if (!wrapper->wops->rename) {
1273-
php_error_docref(NULL, E_WARNING, "%s wrapper does not support renaming", wrapper->wops->label ? wrapper->wops->label : "Source");
12741273
php_stream_error_operation_end(context);
1274+
php_error_docref(NULL, E_WARNING, "%s wrapper does not support renaming", wrapper->wops->label ? wrapper->wops->label : "Source");
12751275
RETURN_FALSE;
12761276
}
12771277

12781278
if (wrapper != php_stream_locate_url_wrapper(new_name, NULL, 0)) {
1279-
php_error_docref(NULL, E_WARNING, "Cannot rename a file across wrapper types");
12801279
php_stream_error_operation_end(context);
1280+
php_error_docref(NULL, E_WARNING, "Cannot rename a file across wrapper types");
12811281
RETURN_FALSE;
12821282
}
12831283

@@ -1307,14 +1307,14 @@ PHP_FUNCTION(unlink)
13071307
wrapper = php_stream_locate_url_wrapper(filename, NULL, 0);
13081308

13091309
if (!wrapper || !wrapper->wops) {
1310-
php_error_docref(NULL, E_WARNING, "Unable to locate stream wrapper");
13111310
php_stream_error_operation_end(context);
1311+
php_error_docref(NULL, E_WARNING, "Unable to locate stream wrapper");
13121312
RETURN_FALSE;
13131313
}
13141314

13151315
if (!wrapper->wops->unlink) {
1316-
php_error_docref(NULL, E_WARNING, "%s does not allow unlinking", wrapper->wops->label ? wrapper->wops->label : "Wrapper");
13171316
php_stream_error_operation_end(context);
1317+
php_error_docref(NULL, E_WARNING, "%s does not allow unlinking", wrapper->wops->label ? wrapper->wops->label : "Wrapper");
13181318
RETURN_FALSE;
13191319
}
13201320
RETVAL_BOOL(wrapper->wops->unlink(wrapper, filename, REPORT_ERRORS, context));
@@ -1332,8 +1332,8 @@ PHP_FUNCTION(fsync)
13321332

13331333
php_stream_error_operation_begin();
13341334
if (!php_stream_sync_supported(stream)) {
1335-
php_error_docref(NULL, E_WARNING, "Can't fsync this stream!");
13361335
php_stream_error_operation_end_for_stream(stream);
1336+
php_error_docref(NULL, E_WARNING, "Can't fsync this stream!");
13371337
RETURN_FALSE;
13381338
}
13391339

@@ -1351,8 +1351,8 @@ PHP_FUNCTION(fdatasync)
13511351

13521352
php_stream_error_operation_begin();
13531353
if (!php_stream_sync_supported(stream)) {
1354-
php_error_docref(NULL, E_WARNING, "Can't fsync this stream!");
13551354
php_stream_error_operation_end_for_stream(stream);
1355+
php_error_docref(NULL, E_WARNING, "Can't fsync this stream!");
13561356
RETURN_FALSE;
13571357
}
13581358

@@ -1379,8 +1379,8 @@ PHP_FUNCTION(ftruncate)
13791379
php_stream_error_operation_begin();
13801380

13811381
if (!php_stream_truncate_supported(stream)) {
1382-
php_error_docref(NULL, E_WARNING, "Can't truncate this stream!");
13831382
php_stream_error_operation_end_for_stream(stream);
1383+
php_error_docref(NULL, E_WARNING, "Can't truncate this stream!");
13841384
RETURN_FALSE;
13851385
}
13861386

ext/standard/tests/streams/gh14506.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ Warning: fclose(): cannot close the provided stream, as it must not be manually
8686

8787
Warning: fclose(): cannot close the provided stream, as it must not be manually closed in %s on line %d
8888

89-
Warning: stream_select(): Cannot represent a stream of type user-space as a select()able descriptor in %s on line %d
90-
9189
Warning: fclose(): cannot close the provided stream, as it must not be manually closed in %s on line %d
9290

91+
Warning: stream_select(): Cannot represent a stream of type user-space as a select()able descriptor in %s on line %d
92+
9393
Warning: stream_select(): Cannot represent a stream of type user-space as a select()able descriptor in %s on line %d
9494
No stream arrays were passed
9595
fclose(): Argument #1 ($stream) must be an open stream resource

0 commit comments

Comments
 (0)