mirror of
https://github.com/php/php-src.git
synced 2024-12-14 12:26:19 +08:00
fix problems found while documenting. Throw consistent exceptions, chmod is not allowed on
temporary directories, but is allowed on regular ones allow uncompressAllFiles() to decompress a gzip/bzipped tar archive fix some protos
This commit is contained in:
parent
9aa889e451
commit
b2412c4568
@ -1923,7 +1923,7 @@ PHP_METHOD(Phar, convertToPhar)
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ proto bool Phar::isCompressed()
|
/* {{{ proto int|false Phar::isCompressed()
|
||||||
* Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so on)
|
* Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so on)
|
||||||
*/
|
*/
|
||||||
PHP_METHOD(Phar, isCompressed)
|
PHP_METHOD(Phar, isCompressed)
|
||||||
@ -1936,7 +1936,7 @@ PHP_METHOD(Phar, isCompressed)
|
|||||||
if (phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSED_BZ2) {
|
if (phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSED_BZ2) {
|
||||||
RETURN_LONG(PHAR_ENT_COMPRESSED_BZ2);
|
RETURN_LONG(PHAR_ENT_COMPRESSED_BZ2);
|
||||||
}
|
}
|
||||||
RETURN_LONG(0);
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
@ -2180,6 +2180,11 @@ PHP_METHOD(Phar, setSignatureAlgorithm)
|
|||||||
"Cannot set signature algorithm, not possible with tar-based phar archives");
|
"Cannot set signature algorithm, not possible with tar-based phar archives");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (phar_obj->arc.archive->is_zip) {
|
||||||
|
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
|
||||||
|
"Cannot set signature algorithm, not possible with zip-based phar archives");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l", &algo) != SUCCESS) {
|
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l", &algo) != SUCCESS) {
|
||||||
return;
|
return;
|
||||||
@ -2201,7 +2206,7 @@ PHP_METHOD(Phar, setSignatureAlgorithm)
|
|||||||
|
|
||||||
phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
|
phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
|
||||||
if (error) {
|
if (error) {
|
||||||
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error);
|
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
|
||||||
efree(error);
|
efree(error);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2407,7 +2412,11 @@ PHP_METHOD(Phar, uncompressAllFiles)
|
|||||||
"Cannot uncompress all files, some are compressed as bzip2 or gzip and cannot be uncompressed");
|
"Cannot uncompress all files, some are compressed as bzip2 or gzip and cannot be uncompressed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (phar_obj->arc.archive->is_tar) {
|
||||||
|
phar_obj->arc.archive->flags &= ~PHAR_FILE_COMPRESSION_MASK;
|
||||||
|
} else {
|
||||||
pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_NONE TSRMLS_CC);
|
pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_NONE TSRMLS_CC);
|
||||||
|
}
|
||||||
phar_obj->arc.archive->is_modified = 1;
|
phar_obj->arc.archive->is_modified = 1;
|
||||||
|
|
||||||
phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
|
phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
|
||||||
@ -2834,6 +2843,10 @@ PHP_METHOD(Phar, setMetadata)
|
|||||||
zval *metadata;
|
zval *metadata;
|
||||||
PHAR_ARCHIVE_OBJECT();
|
PHAR_ARCHIVE_OBJECT();
|
||||||
|
|
||||||
|
if (PHAR_G(readonly)) {
|
||||||
|
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by INI setting");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (phar_obj->arc.archive->is_tar) {
|
if (phar_obj->arc.archive->is_tar) {
|
||||||
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
|
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
|
||||||
"Cannot set metadata, not possible with tar-based phar archives");
|
"Cannot set metadata, not possible with tar-based phar archives");
|
||||||
@ -2859,7 +2872,7 @@ PHP_METHOD(Phar, setMetadata)
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ proto int Phar::delMetaData()
|
/* {{{ proto int Phar::delMetadata()
|
||||||
* Deletes the global metadata of the phar
|
* Deletes the global metadata of the phar
|
||||||
*/
|
*/
|
||||||
PHP_METHOD(Phar, delMetadata)
|
PHP_METHOD(Phar, delMetadata)
|
||||||
@ -2867,6 +2880,10 @@ PHP_METHOD(Phar, delMetadata)
|
|||||||
char *error;
|
char *error;
|
||||||
PHAR_ARCHIVE_OBJECT();
|
PHAR_ARCHIVE_OBJECT();
|
||||||
|
|
||||||
|
if (PHAR_G(readonly)) {
|
||||||
|
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by INI setting");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (phar_obj->arc.archive->metadata) {
|
if (phar_obj->arc.archive->metadata) {
|
||||||
zval_ptr_dtor(&phar_obj->arc.archive->metadata);
|
zval_ptr_dtor(&phar_obj->arc.archive->metadata);
|
||||||
phar_obj->arc.archive->metadata = NULL;
|
phar_obj->arc.archive->metadata = NULL;
|
||||||
@ -3150,6 +3167,10 @@ PHP_METHOD(PharFileInfo, setMetadata)
|
|||||||
zval *metadata;
|
zval *metadata;
|
||||||
PHAR_ENTRY_OBJECT();
|
PHAR_ENTRY_OBJECT();
|
||||||
|
|
||||||
|
if (PHAR_G(readonly)) {
|
||||||
|
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by INI setting");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (entry_obj->ent.entry->is_tar) {
|
if (entry_obj->ent.entry->is_tar) {
|
||||||
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
|
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
|
||||||
"Cannot set metadata, not possible with tar-based phar archives");
|
"Cannot set metadata, not possible with tar-based phar archives");
|
||||||
@ -3188,11 +3209,13 @@ PHP_METHOD(PharFileInfo, delMetadata)
|
|||||||
char *error;
|
char *error;
|
||||||
PHAR_ENTRY_OBJECT();
|
PHAR_ENTRY_OBJECT();
|
||||||
|
|
||||||
if (entry_obj->ent.entry->is_dir) {
|
if (PHAR_G(readonly)) {
|
||||||
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
|
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by INI setting");
|
||||||
"Phar entry is a directory, cannot delete metadata"); \
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (entry_obj->ent.entry->is_temp_dir) {
|
||||||
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
if (entry_obj->ent.entry->metadata) {
|
if (entry_obj->ent.entry->metadata) {
|
||||||
zval_ptr_dtor(&entry_obj->ent.entry->metadata);
|
zval_ptr_dtor(&entry_obj->ent.entry->metadata);
|
||||||
entry_obj->ent.entry->metadata = NULL;
|
entry_obj->ent.entry->metadata = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user