mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
SplFileObject::getFilename() should not overwrite SplFileInfo::getFilename()
(Fixes bug where SplFileObject::getFilename() returns relative/path/to/file)
This commit is contained in:
parent
74420e6be6
commit
d98dfdb119
2 changed files with 6 additions and 16 deletions
|
@ -550,7 +550,7 @@ SPL_METHOD(SplFileInfo, getFilename)
|
||||||
{
|
{
|
||||||
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
|
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
|
||||||
|
|
||||||
if (intern->path_len) {
|
if (intern->path_len && intern->path_len < intern->file_name_len) {
|
||||||
RETURN_STRINGL(intern->file_name + intern->path_len + 1, intern->file_name_len - (intern->path_len + 1), 1);
|
RETURN_STRINGL(intern->file_name + intern->path_len + 1, intern->file_name_len - (intern->path_len + 1), 1);
|
||||||
} else {
|
} else {
|
||||||
RETURN_STRINGL(intern->file_name, intern->file_name_len, 1);
|
RETURN_STRINGL(intern->file_name, intern->file_name_len, 1);
|
||||||
|
@ -1654,15 +1654,6 @@ SPL_METHOD(SplFileObject, rewind)
|
||||||
spl_filesystem_file_rewind(getThis(), intern TSRMLS_CC);
|
spl_filesystem_file_rewind(getThis(), intern TSRMLS_CC);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/* {{{ proto string SplFileObject::getFilename()
|
|
||||||
Return the filename */
|
|
||||||
SPL_METHOD(SplFileObject, getFilename)
|
|
||||||
{
|
|
||||||
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
|
|
||||||
|
|
||||||
RETURN_STRINGL(intern->file_name, intern->file_name_len, 1);
|
|
||||||
} /* }}} */
|
|
||||||
|
|
||||||
/* {{{ proto void SplFileObject::eof()
|
/* {{{ proto void SplFileObject::eof()
|
||||||
Return whether end of file is reached */
|
Return whether end of file is reached */
|
||||||
SPL_METHOD(SplFileObject, eof)
|
SPL_METHOD(SplFileObject, eof)
|
||||||
|
@ -2140,7 +2131,6 @@ ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
static zend_function_entry spl_SplFileObject_functions[] = {
|
static zend_function_entry spl_SplFileObject_functions[] = {
|
||||||
SPL_ME(SplFileObject, __construct, arginfo_file_object___construct, ZEND_ACC_PUBLIC)
|
SPL_ME(SplFileObject, __construct, arginfo_file_object___construct, ZEND_ACC_PUBLIC)
|
||||||
SPL_ME(SplFileObject, getFilename, NULL, ZEND_ACC_PUBLIC)
|
|
||||||
SPL_ME(SplFileObject, rewind, NULL, ZEND_ACC_PUBLIC)
|
SPL_ME(SplFileObject, rewind, NULL, ZEND_ACC_PUBLIC)
|
||||||
SPL_ME(SplFileObject, eof, NULL, ZEND_ACC_PUBLIC)
|
SPL_ME(SplFileObject, eof, NULL, ZEND_ACC_PUBLIC)
|
||||||
SPL_ME(SplFileObject, valid, NULL, ZEND_ACC_PUBLIC)
|
SPL_ME(SplFileObject, valid, NULL, ZEND_ACC_PUBLIC)
|
||||||
|
|
|
@ -55,12 +55,12 @@ bool(true)
|
||||||
%s(%d) "%sfileobject_001a.txt"
|
%s(%d) "%sfileobject_001a.txt"
|
||||||
string(%d) "%sfileobject_001a.txt"
|
string(%d) "%sfileobject_001a.txt"
|
||||||
bool(true)
|
bool(true)
|
||||||
string(%d) "%sfileobject_001a.txt"
|
string(19) "fileobject_001a.txt"
|
||||||
bool(true)
|
bool(true)
|
||||||
string(%d) "%stests"
|
string(%d) "%stests"
|
||||||
bool(true)
|
bool(true)
|
||||||
string(%d) "%sfileobject_001a.txt"
|
string(%d) "%sfileobject_001a.txt"
|
||||||
string(%d) "%sfileobject_001a.txt"
|
string(19) "fileobject_001a.txt"
|
||||||
string(%d) "%stests"
|
string(%d) "%stests"
|
||||||
===1===
|
===1===
|
||||||
object(SplFileInfo)#%d (0) {
|
object(SplFileInfo)#%d (0) {
|
||||||
|
@ -73,7 +73,7 @@ bool(true)
|
||||||
%s(%d) "%stests/"
|
%s(%d) "%stests/"
|
||||||
string(%d) "%stests"
|
string(%d) "%stests"
|
||||||
bool(true)
|
bool(true)
|
||||||
string(%d) "%stests"
|
string(5) "tests"
|
||||||
bool(true)
|
bool(true)
|
||||||
string(%d) "%sspl"
|
string(%d) "%sspl"
|
||||||
bool(true)
|
bool(true)
|
||||||
|
@ -91,11 +91,11 @@ bool(true)
|
||||||
%s(%d) "%stests"
|
%s(%d) "%stests"
|
||||||
string(%d) "%stests"
|
string(%d) "%stests"
|
||||||
bool(true)
|
bool(true)
|
||||||
string(%d) "%stests"
|
string(%d) "tests"
|
||||||
bool(true)
|
bool(true)
|
||||||
string(%d) "%sspl"
|
string(%d) "%sspl"
|
||||||
bool(true)
|
bool(true)
|
||||||
string(%d) "%stests"
|
string(%d) "%stests"
|
||||||
string(%d) "%stests"
|
string(5) "tests"
|
||||||
string(%d) "%sspl"
|
string(%d) "%sspl"
|
||||||
===DONE===
|
===DONE===
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue