Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Fixes #6730 : close() xml reader on fromFile() and fromString() #6761

Closed
wants to merge 4 commits into from

Conversation

samsonasik
Copy link
Contributor

Fixes #6730

@samsonasik samsonasik changed the title Fixes #6730 : close xml reader on fromFile after it open Fixes #6730 : close xml reader on fromFile() after it open Oct 14, 2014
@DASPRiD
Copy link
Member

DASPRiD commented Oct 14, 2014

Shouldn't the same be done in fromString() then?

@samsonasik
Copy link
Contributor Author

fromString() doesn't have open() that pointed to document, I think it doesn't need close then

@DASPRiD
Copy link
Member

DASPRiD commented Oct 14, 2014

xml() calls also require close() calls, according to the documentation of it ;)

@samsonasik
Copy link
Contributor Author

ok, I've added to fromString() too, thank you.

@samsonasik samsonasik changed the title Fixes #6730 : close xml reader on fromFile() after it open Fixes #6730 : close() xml reader on fromFile() and fromString() Oct 14, 2014
@samsonasik
Copy link
Contributor Author

@Ocramius I think it's merge-able now ;)

@Ocramius Ocramius added the bug label Dec 19, 2014
@Ocramius Ocramius added this to the 2.3.4 milestone Dec 19, 2014
@Ocramius Ocramius self-assigned this Dec 19, 2014
@Ocramius
Copy link
Member

@samsonasik is there no way to test this change?

@samsonasik
Copy link
Contributor Author

@Ocramius $reader is protected property that instantiated via :

$this->reader = new XMLReader();

in fromFile() and fromString. Need public method like getReader to make it testable ?

@Ocramius
Copy link
Member

@samsonasik no, there is no need to make it publicly accessible, but something may be triggering the bug here, no?

@samsonasik
Copy link
Contributor Author

not sure, but fromFile and fromString always instantiate new class. so I think it is ok...

Warm regards,

Abdul Malik Ikhsan

Pada 22 Des 2014, pukul 10.48, Marco Pivetta [email protected] menulis:

@samsonasik no, there is no need to make it publicly accessible, but something may be triggering the bug here, no?


Reply to this email directly or view it on GitHub.

@Ocramius
Copy link
Member

@samsonasik yes, but what is being fixed here? To give you a perspective of what should happen: if I remove this patch later on, will the change be noticed?

@samsonasik
Copy link
Contributor Author

@Ocramius to check this, I think there is should be a function to check $reader->isValid() like this :

$xml = new XmlReader();
$xml->open('foo.xml'); // correct xml
$xml->setParserProperty(XMLReader::VALIDATE, true);

var_dump($xml->isValid()); // will return true
$xml->close();
var_dump($xml->isValid()); // will return false

how ?

@Ocramius
Copy link
Member

Looks more like something that could cause misbehavior on multiple usages of the same reader instances: maybe try that and see if there is unexpected behavior?

@samsonasik
Copy link
Contributor Author

@Ocramius ok, I will try that.

@samsonasik
Copy link
Contributor Author

@Ocramius I've updated the code and added unit tests to test applying setParserProperty after using fromFile() or fromString() get php error warning. please let me know if there is something I missed ;)

*
* @return XMLReader
*/
public function getReader()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to find a test case that doesn't need to access internal deps or check their state...

@Ocramius
Copy link
Member

Pulling locally and attempting to fix the test

Ocramius added a commit that referenced this pull request Dec 31, 2014
Ocramius added a commit that referenced this pull request Dec 31, 2014
…ould-be-closed' into develop

Close #6761
Close #6730
Forward port #6761
Forward port #6730
@Ocramius Ocramius closed this in bfc0eb6 Dec 31, 2014
@Ocramius
Copy link
Member

Rebased and merged, thanks @samsonasik!

master: bfc0eb6
develop: da67b48

@samsonasik samsonasik deleted the hotfix/xml-close branch December 31, 2014 09:58
gianarb pushed a commit to zendframework/zend-config that referenced this pull request May 15, 2015
…onfig reader should disallow opening non existing files
gianarb pushed a commit to zendframework/zend-config that referenced this pull request May 15, 2015
…sing reflection to access the internal config reader
gianarb pushed a commit to zendframework/zend-config that referenced this pull request May 15, 2015
…sing reflection to access the internal config reader
gianarb pushed a commit to zendframework/zend-config that referenced this pull request May 15, 2015
…emoving newly introduced getter (not needed)
gianarb pushed a commit to zendframework/zend-config that referenced this pull request May 15, 2015
…implifying test case for non-existing paths
gianarb pushed a commit to zendframework/zend-config that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-config that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-config that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-config that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zend\Config\Reader\Xml bug with close file after open
4 participants