I am experiencing a weird PHP problem, and I am seeing this on two different web servers. I’m going crazy trying to solve this so I’m hoping someone can help. It’s weird because I’ve used PHP a lot and found it to be reliable, but now I’m a bit worried. Hopefully I am making a stupid mistake somewhere.
I edited the document.parser.class.inc.php to generate a log file to show the execution flow of a specific part of the file.
At the start of the file I added:
function write_to_log($str) {
if($fd = @fopen("/home/andy/public_html/beverleyinpictures/modx.log", "a")) {
fputs($fd, $str);
fclose($fd);
}
}
I then added a call to write_to_log() at the start of the function getDocumentIdentifier:
function getDocumentIdentifier($method) {
write_to_log("method=".$method.", q=".$_REQUEST['q']." id=".$_REQUEST['id']."\n");
// function to test the query and find the retrieval method
$docIdentifier= $this->config['site_start'];
I then added two calls to write_to_log() around the only call to getDocumentIdentifier in the whole file:
write_to_log("here1\n");
$this->documentIdentifier = $this->getDocumentIdentifier($this->documentMethod);
write_to_log("here2\n");
Here is the output of my log file:
here1
method=alias, q=beverleyminster.html id=
here2
here1
method=alias, q=suninn.html id=
here2
method=id, q=suninn.html id=
method=id, q=suninn.html id=0
here1
method=alias, q=map.html id=
here2
What you see here is a successful call of getDocumentIdentifier, with q=beverleyminster.html. Then getDocumentIdentifier is called again with q=suninn.html. This completes then inexplicably it is called twice more. However "here1" and "here2" don’t appear. This means that the second and third times the function was called were not from the only function call that exists. The function doesn’t have a loop in it. Also where is the method "id" coming from for the second and third calls?
This problem is stopping friendly URLs from working for me, so I really hope to get this solved. Here is some server info:
MODx 0.9.2.1 rev 1005
PHP 4.4.0 and 4.4.1
Gentoo Linux 2006.0 (2.6.15)
Apache 2
Thanks for the help!!! regards, Andy