Wez Furlong wrote:



Your fix looks overly magical to me, so let's backtrack:

what does the title

show in the french page?

Look here : http://didou.keliglia.com/php/phpman/fr/faq.com.html


There's a lot of section titled PHP in the menu and you'll notice that the browser title is different from the real title.
Applying my patch fixes the issue and nothing seems magical to me.


The problem I have with the patch is that it doesn't seem related to this
issue; particuarly when I can't replicate the effect using the english docs
(livedocs code is largely language agnostic).

It seems to me that the problem is elsewhere, and I'd like to identify where
it is before fixing it.

Ok, so let's profile it :)

livedocs/livedoc.php, line 96 : adding a var_dump($title); outputs
string(3) "PHP" as you can see it here :

  http://didou.keliglia.com/php/phpman/fr/faq.com.html

$title is returned by do_nav()

do_nav() selects title from idents, when was this record inserted ? during the mktoc.php call.

let's debug mktoc.php :

I modified the start_elem() and end_elem() methods like described in [1]

Let's run ./build.sh and focus on faq.com for the english part :

"
Parse file: faq/com.xml  Parsing file ID 68
O : CHAPTER || ID=faq.com |
D :

D :
O : TITLE ||
D : PHP and COM
C : TITLE
        Added ID faq.com
Data is: PHP and COM
"

What does it mean ?

O : CHAPTER || ID=faq.com |
Here we find an ID, so $this->last_id is !== false from now on.

D : no cdata (2 times)

O : TITLE ||
start_elem() is called for <title>, nothing special happens and

D : $this->cdata takes "PHP and COM"

C : TITLE
end_elem() is called for </title>, as $this->last_id != false, the
data is inserted in the database.

Here, everything is *fine*



Now let's see what happens in Paris :)

(the xml is <title><literal>PHP</literal> et COM</title>

"
Parse file: faq/com.xml  Parsing file ID 67
O : CHAPTER || ID=faq.com |
D :

D :
O : TITLE ||
O : LITERAL ||
D : PHP
C : LITERAL
        Added ID faq.com
Data is: PHP
D :  et COM
C : TITLE
"


What does it mean ?

O : CHAPTER || ID=faq.com |
Here we find an ID, so $this->last_id is !== false from now on.

O : TITLE ||
start_elem() is called for <title>

O : LITERAL ||
start_elem() is called for <literal>

D : PHP
$this->cdata takes "PHP"

C : LITERAL
end_elem() is called for </title>, as $this->last_id != false, the
data is inserted in the database.

        Added ID faq.com
Data is: PHP

Here's the problem. the INSERT in end_elem() should be generated only when the parser reaches the end of <title> (C: TITLE, two lines above)
and also concatenate $this->cdata with the new $data (et COM)


My patches register the opening tag (O: TITLE) right before the tag with an id attribute (O: CHAPTER) and only generates the INSERT when C: TITLE
is reached.


Here's the result of the previous tests with my patch applied.

English :

Parse file: faq/com.xml  Parsing file ID 68
O : CHAPTER || ID=faq.com |
D :

D :
O : TITLE ||
D : PHP and COM
C : TITLE
        Added ID faq.com
Data is:    PHP and COM



French :

Parse file: faq/com.xml  Parsing file ID 67
O : CHAPTER || ID=faq.com |
D :

D :
O : TITLE ||
O : LITERAL ||
D : PHP
C : LITERAL
D :  et COM
C : TITLE
        Added ID faq.com
Data is:    PHP et COM


C : LITERAL doesn't cause the INSERT no more, and only TITLE ($this->tag_name) will do so.


The only problem is (I talked about it in another mail) when you have this figure :

<title>some <title>words</title> here</title>

Got it ? I can't be more clear than that :)

btw, I'm a missing something or is the query executed one more time upon
failure line 180 ? Why ?


Thank you for your appreciated time,

didou



[1]
RCS file: /repository/livedocs/mkindex.php,v
retrieving revision 1.33
diff -u -r1.33 mkindex.php
--- mkindex.php 23 May 2004 08:58:01 -0000      1.33
+++ mkindex.php 23 May 2004 12:08:28 -0000
@@ -86,6 +86,11 @@
        }

        function start_elem($parser, $name, $attrs) {
+           $a = '';
+           foreach ($attrs as $k => $v) {
+                       $a .= "$k=$v | ";
+               }
+               echo "O : $name || $a\n";
                // if there is an ID attribute, record it
                if (isset($attrs['ID'])) {
                        $this->last_id = $attrs['ID'];
@@ -93,8 +98,11 @@
        }

        function end_elem($parser, $name) {
+
+           echo "C : $name\n";
                if ($this->last_id !== false) {
                        echo "\tAdded ID {$this->last_id}\n";
+                       echo "Data is: {$this->cdata}\n";

$this->data .= "INSERT INTO idents VALUES ('" . strtolower($this->last_id) . "', {$this->fileid}, '" . sqlite_escape_string(trim($this->cdata)) . "');";

@@ -103,6 +111,7 @@
        }

        function cdata($parser, $data) {
+               echo "D : $data\n";
                if ($this->last_id !== false) {
                        //small hack for '&'
                        $data = str_replace('||amp||', '&', $data);

Reply via email to