diff --git a/NEWS b/NEWS index f3ea846096c..f6bfc5d3565 100644 --- a/NEWS +++ b/NEWS @@ -63,6 +63,8 @@ PHP NEWS - SPL: . Fixed bug #55701 (GlobIterator throws LogicException). (Valentin VÄ‚LCIU) + . Fixed bug #72646 (SplFileObject::getCsvControl does not return the escape + character). (cmb) - SQLite3: . Fixed bug #72571 (SQLite3::bindValue, SQLite3::bindParam crash). (Laruence) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 6a49d973e36..17b9e8fa557 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2657,7 +2657,7 @@ SPL_METHOD(SplFileObject, fputcsv) /* }}} */ /* {{{ proto void SplFileObject::setCsvControl([string delimiter [, string enclosure [, string escape ]]]) - Set the delimiter and enclosure character used in fgetcsv */ + Set the delimiter, enclosure and escape character used in fgetcsv */ SPL_METHOD(SplFileObject, setCsvControl) { spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis()); @@ -2700,11 +2700,11 @@ SPL_METHOD(SplFileObject, setCsvControl) /* }}} */ /* {{{ proto array SplFileObject::getCsvControl() - Get the delimiter and enclosure character used in fgetcsv */ + Get the delimiter, enclosure and escape character used in fgetcsv */ SPL_METHOD(SplFileObject, getCsvControl) { spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis()); - char delimiter[2], enclosure[2]; + char delimiter[2], enclosure[2], escape[2]; array_init(return_value); @@ -2712,9 +2712,12 @@ SPL_METHOD(SplFileObject, getCsvControl) delimiter[1] = '\0'; enclosure[0] = intern->u.file.enclosure; enclosure[1] = '\0'; + escape[0] = intern->u.file.escape; + escape[1] = '\0'; add_next_index_string(return_value, delimiter); add_next_index_string(return_value, enclosure); + add_next_index_string(return_value, escape); } /* }}} */ diff --git a/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt index e21f08fa2de..4e3de4bab2e 100644 --- a/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt +++ b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt @@ -6,10 +6,12 @@ $obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv'); var_dump($obj->getCsvControl()); ?> ---EXPECTF-- -array(2) { +--EXPECT-- +array(3) { [0]=> - %unicode|string%(1) "," + string(1) "," [1]=> - %unicode|string%(1) """ + string(1) """ + [2]=> + string(1) "\" }