Skip to content

Commit e65a4b0

Browse files
authored
ext/phar: Improve various error messages (#22858)
Safe mode in phar is removed in PHP 5.4, so removing them in error messages. Also fix some obvious typos in the error messages.
1 parent 4983e8b commit e65a4b0

7 files changed

Lines changed: 13 additions & 9 deletions

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ PHP NEWS
3838
. Fixed bug GH-22665 (Out-of-bounds write when the ODBC driver reports a
3939
diagnostic message length beyond the error buffer). (iliaal)
4040

41+
- Phar:
42+
. Fixed grammatical issues and outdated terminology in Phar error messages.
43+
(Weilin Du)
44+
4145
- Reflection:
4246
. Fixed bug GH-22681 (Reflection*::__toString() truncates on null bytes).
4347
(DanielEScherzer)

ext/phar/phar_object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4136,7 +4136,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result phar_extract_file(bool overwrite, phar
41364136
}
41374137

41384138
if (php_check_open_basedir(fullpath)) {
4139-
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", openbasedir/safe mode restrictions in effect", ZSTR_VAL(entry->filename), fullpath);
4139+
spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", open_basedir restrictions in effect", ZSTR_VAL(entry->filename), fullpath);
41404140
efree(fullpath);
41414141
efree(new_state.cwd);
41424142
return FAILURE;

ext/phar/tar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /*
815815

816816
if (sizeof(header) != php_stream_write(fp->new, (const char *) &header, sizeof(header))) {
817817
if (fp->error) {
818-
spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, header for file \"%s\" could not be written", ZSTR_VAL(entry->phar->fname), ZSTR_VAL(entry->filename));
818+
spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, header for file \"%s\" could not be written", ZSTR_VAL(entry->phar->fname), ZSTR_VAL(entry->filename));
819819
}
820820
return ZEND_HASH_APPLY_STOP;
821821
}

ext/phar/tests/dir.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Warning: mkdir(): phar error: cannot create directory "fails" in phar "%sok.phar
7171

7272
Warning: mkdir(): phar error: cannot create directory "sub" in phar "%sok.phar", directory already exists in %sdir.php on line %d
7373

74-
Warning: mkdir(): phar error: cannot create directory "sub/directory.txt" in phar "%sok.phar", phar error: path "sub/directory.txt" exists and is a not a directory in %sdir.php on line %d
74+
Warning: mkdir(): phar error: cannot create directory "sub/directory.txt" in phar "%sok.phar", phar error: path "sub/directory.txt" exists and is not a directory in %sdir.php on line %d
7575

7676
Warning: mkdir(): internal corruption of phar "%soops.phar" (truncated manifest at stub end) in %sdir.php on line %d
7777

ext/phar/tests/mkdir.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ Warning: mkdir(): phar error: cannot create directory "phar://", no phar archive
4242

4343
Warning: mkdir(): phar error: cannot create directory "" in phar "foo.phar", phar error: invalid path "" must not be empty in %smkdir.php on line %d
4444

45-
Warning: mkdir(): phar error: cannot create directory "a" in phar "%smkdir.phar.php", phar error: path "a" exists and is a not a directory in %smkdir.php on line %d
45+
Warning: mkdir(): phar error: cannot create directory "a" in phar "%smkdir.phar.php", phar error: path "a" exists and is not a directory in %smkdir.php on line %d
4646

4747
Warning: rmdir(): phar error: cannot remove directory "phar://", no phar archive specified, or phar archive does not exist in %smkdir.php on line %d
4848

4949
Warning: rmdir(): phar error: cannot remove directory "" in phar "foo.phar", directory does not exist in %smkdir.php on line %d
5050

51-
Warning: rmdir(): phar error: cannot remove directory "a" in phar "%smkdir.phar.php", phar error: path "a" exists and is a not a directory in %smkdir.php on line %d
51+
Warning: rmdir(): phar error: cannot remove directory "a" in phar "%smkdir.phar.php", phar error: path "a" exists and is not a directory in %smkdir.php on line %d
5252
Cannot create a directory in magic ".phar" directory
5353
Cannot create a directory in magic ".phar" directory
5454
bool(true)

ext/phar/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, si
12261226
if (!entry->is_dir && dir == 2) {
12271227
/* user requested a directory, we must return one */
12281228
if (error) {
1229-
spprintf(error, 4096, "phar error: path \"%s\" exists and is a not a directory", path);
1229+
spprintf(error, 4096, "phar error: path \"%s\" exists and is not a directory", path);
12301230
}
12311231
return NULL;
12321232
}
@@ -1290,7 +1290,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, si
12901290
efree(test);
12911291
/* user requested a directory, we must return one */
12921292
if (error) {
1293-
spprintf(error, 4096, "phar error: path \"%s\" exists and is a not a directory", path);
1293+
spprintf(error, 4096, "phar error: path \"%s\" exists and is not a directory", path);
12941294
}
12951295
return NULL;
12961296
}

ext/phar/zip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{
959959
}
960960

961961
if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, false)) {
962-
spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", ZSTR_VAL(entry->filename), ZSTR_VAL(entry->phar->fname));
962+
spprintf(p->error, 0, "unable to seek to start of file \"%s\" while creating zip-based phar \"%s\"", ZSTR_VAL(entry->filename), ZSTR_VAL(entry->phar->fname));
963963
return ZEND_HASH_APPLY_STOP;
964964
}
965965

@@ -1008,7 +1008,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{
10081008

10091009
if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, false)) {
10101010
php_stream_filter_free(filter);
1011-
spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", ZSTR_VAL(entry->filename), ZSTR_VAL(entry->phar->fname));
1011+
spprintf(p->error, 0, "unable to seek to start of file \"%s\" while creating zip-based phar \"%s\"", ZSTR_VAL(entry->filename), ZSTR_VAL(entry->phar->fname));
10121012
return ZEND_HASH_APPLY_STOP;
10131013
}
10141014

0 commit comments

Comments
 (0)