Re: Issue with PHP 5.1.2, XML_Parser , File_XSPF
| From: | Dan Rossi | Date: | Sun, 05 Feb 2006 14:57:48 +0000 |
| Subject: | Re: Issue with PHP 5.1.2, XML_Parser , File_XSPF | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22796@lists.php.net to get a copy of this message | ||
It looks like indeed file_exists returns true if you pass a string to it.
$string = '<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>electroteques Recent Tracks</title>
<creator>Audioscrobbler</creator>
<info>http://www.last.fm/user/electroteque/</info>
<license>http://creativecommons.org/licenses/by-nc-sa/2.0/uk/</license>
<trackList>
<track>
<title>Sleepy Mimer</title>
<creator>electroteque</creator>
<info>http://www.last.fm/music/electroteque/_/Sleepy+Mimer</info>
</track>
<track>
<title>Looking for Sophie</title>
<creator>doc</creator>
<info>http://www.last.fm/music/doc/_/Looking+for+Sophie</info>
</track>
<track>
<title>Norkhaberg</title>
<creator>KraftiM</creator>
<info>http://www.last.fm/music/KraftiM/_/Norkhaberg</info>
</track>
<track>
<title>Nocturnal Nail Clipping</title>
<creator>frags</creator>
<info>http://www.last.fm/music/frags/_/Nocturnal+Nail+Clipping</info>
</track>
<track>
<title>Climate Changes</title>
<creator>electroteque</creator>
<info>http://www.last.fm/music/electroteque/_/Climate+Changes</info>
</track>
<track>
<title>Tre Komma Fem Procent</title>
<creator>Unknown Forces</creator>
<info>http://www.last.fm/music/Unknown+Forces/_/Tre+Komma+Fem+Procent</info>
</track>
<track>
<title>Airports for Music</title>
<creator>doc</creator>
<info>http://www.last.fm/music/doc/_/Airports+for+Music</info>
</track>
<track>
<title>Mayfirst</title>
<creator>Move D</creator>
<info>http://www.last.fm/music/Move+D/_/Mayfirst</info>
<duration>486000</duration>
</track>
</trackList>
</playlist>';
if (file_exists($string)) die("yes");
exit;
it also seems to be the size of the string matters too. If i take out enough of the track rows its false.
On 06/02/2006, at 12:27 AM, Dan Rossi wrote:
Hi there I think I have found a possible bug with file_exists , but id like to check first. From the feature request File_XSPF now contains a method for passing through xspf playlists as strings. However it uses the setInput method in XML_Parser. However within the setInput method $fp as a string , so not a file to be parsed is returning true at the last point file_exists($fp), so is not making it to the last control statement to return a string to $this->fp. This was pretty much breaking File_XSPF for me so ive asked to change it to setInputString ??. So im asking where is the bug, in PHP 5.1.2 with file_exists returning true for data being passed to it when in fact its not a file at all, or a bug in XML_Parser or both ? Let me know, so i can send the reports thanks. function setInput($fp){ if (is_resource($fp)) { $this->fp = $fp; return true; } // see if it's an absolute URL (has a scheme atthe beginning)elseif (eregi('^[a-z]+://', substr($fp, 0, 10))){return $this->setInputFile($fp); } // see if it's a local file elseif (file_exists($fp)) { die("yes"); return $this->setInputFile($fp); } // it must be a string else { die("yes"); $this->fp = $fp; return true; }