Fossil SCM
Improvements to TH1 variable setup when processing tickets that use TICKETCHNG.
Commit
cc8a32562239e71f4fc6c7df7bb689cb130813aa
Parent
6a8084abcb24c02…
1 file changed
+9
-19
+9
-19
| --- src/tkt.c | ||
| +++ src/tkt.c | ||
| @@ -143,33 +143,22 @@ | ||
| 143 | 143 | }else if( strncmp(zName, "private_", 8)==0 ){ |
| 144 | 144 | zVal = zRevealed = db_reveal(zVal); |
| 145 | 145 | } |
| 146 | 146 | if( (j = fieldId(zName))>=0 ){ |
| 147 | 147 | aField[j].zValue = mprintf("%s", zVal); |
| 148 | - } | |
| 149 | - if( Th_Fetch(zName, &size)==0 ){ | |
| 148 | + }else if( memcmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){ | |
| 150 | 149 | Th_Store(zName, zVal); |
| 151 | 150 | } |
| 152 | 151 | free(zRevealed); |
| 153 | 152 | } |
| 154 | - }else{ | |
| 155 | - db_finalize(&q); | |
| 156 | - db_prepare(&q, "PRAGMA table_info(ticket)"); | |
| 157 | - if( Th_Fetch("tkt_uuid",&size)==0 ){ | |
| 158 | - Th_Store("tkt_uuid",zName); | |
| 159 | - } | |
| 160 | - while( db_step(&q)==SQLITE_ROW ){ | |
| 161 | - const char *zField = db_column_text(&q, 1); | |
| 162 | - if( Th_Fetch(zField, &size)==0 ){ | |
| 163 | - Th_Store(zField, ""); | |
| 164 | - } | |
| 165 | - } | |
| 166 | - if( Th_Fetch("tkt_datetime",&size)==0 ){ | |
| 167 | - Th_Store("tkt_datetime",""); | |
| 168 | - } | |
| 169 | - } | |
| 170 | - db_finalize(&q); | |
| 153 | + } | |
| 154 | + db_finalize(&q); | |
| 155 | + for(i=0; i<nField; i++){ | |
| 156 | + if( Th_Fetch(aField[i].zName, &size)==0 ){ | |
| 157 | + Th_Store(aField[i].zName, aField[i].zValue); | |
| 158 | + } | |
| 159 | + } | |
| 171 | 160 | } |
| 172 | 161 | |
| 173 | 162 | /* |
| 174 | 163 | ** Transfer all CGI parameters to variables in the interpreter. |
| 175 | 164 | */ |
| @@ -384,10 +373,11 @@ | ||
| 384 | 373 | } |
| 385 | 374 | style_header("View Ticket"); |
| 386 | 375 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1); |
| 387 | 376 | ticket_init(); |
| 388 | 377 | initializeVariablesFromCGI(); |
| 378 | + getAllTicketFields(); | |
| 389 | 379 | initializeVariablesFromDb(); |
| 390 | 380 | zScript = ticket_viewpage_code(); |
| 391 | 381 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW_SCRIPT<br />\n", -1); |
| 392 | 382 | Th_Render(zScript); |
| 393 | 383 | if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1); |
| 394 | 384 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -143,33 +143,22 @@ | |
| 143 | }else if( strncmp(zName, "private_", 8)==0 ){ |
| 144 | zVal = zRevealed = db_reveal(zVal); |
| 145 | } |
| 146 | if( (j = fieldId(zName))>=0 ){ |
| 147 | aField[j].zValue = mprintf("%s", zVal); |
| 148 | } |
| 149 | if( Th_Fetch(zName, &size)==0 ){ |
| 150 | Th_Store(zName, zVal); |
| 151 | } |
| 152 | free(zRevealed); |
| 153 | } |
| 154 | }else{ |
| 155 | db_finalize(&q); |
| 156 | db_prepare(&q, "PRAGMA table_info(ticket)"); |
| 157 | if( Th_Fetch("tkt_uuid",&size)==0 ){ |
| 158 | Th_Store("tkt_uuid",zName); |
| 159 | } |
| 160 | while( db_step(&q)==SQLITE_ROW ){ |
| 161 | const char *zField = db_column_text(&q, 1); |
| 162 | if( Th_Fetch(zField, &size)==0 ){ |
| 163 | Th_Store(zField, ""); |
| 164 | } |
| 165 | } |
| 166 | if( Th_Fetch("tkt_datetime",&size)==0 ){ |
| 167 | Th_Store("tkt_datetime",""); |
| 168 | } |
| 169 | } |
| 170 | db_finalize(&q); |
| 171 | } |
| 172 | |
| 173 | /* |
| 174 | ** Transfer all CGI parameters to variables in the interpreter. |
| 175 | */ |
| @@ -384,10 +373,11 @@ | |
| 384 | } |
| 385 | style_header("View Ticket"); |
| 386 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1); |
| 387 | ticket_init(); |
| 388 | initializeVariablesFromCGI(); |
| 389 | initializeVariablesFromDb(); |
| 390 | zScript = ticket_viewpage_code(); |
| 391 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW_SCRIPT<br />\n", -1); |
| 392 | Th_Render(zScript); |
| 393 | if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1); |
| 394 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -143,33 +143,22 @@ | |
| 143 | }else if( strncmp(zName, "private_", 8)==0 ){ |
| 144 | zVal = zRevealed = db_reveal(zVal); |
| 145 | } |
| 146 | if( (j = fieldId(zName))>=0 ){ |
| 147 | aField[j].zValue = mprintf("%s", zVal); |
| 148 | }else if( memcmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){ |
| 149 | Th_Store(zName, zVal); |
| 150 | } |
| 151 | free(zRevealed); |
| 152 | } |
| 153 | } |
| 154 | db_finalize(&q); |
| 155 | for(i=0; i<nField; i++){ |
| 156 | if( Th_Fetch(aField[i].zName, &size)==0 ){ |
| 157 | Th_Store(aField[i].zName, aField[i].zValue); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /* |
| 163 | ** Transfer all CGI parameters to variables in the interpreter. |
| 164 | */ |
| @@ -384,10 +373,11 @@ | |
| 373 | } |
| 374 | style_header("View Ticket"); |
| 375 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW<br />\n", -1); |
| 376 | ticket_init(); |
| 377 | initializeVariablesFromCGI(); |
| 378 | getAllTicketFields(); |
| 379 | initializeVariablesFromDb(); |
| 380 | zScript = ticket_viewpage_code(); |
| 381 | if( g.thTrace ) Th_Trace("BEGIN_TKTVIEW_SCRIPT<br />\n", -1); |
| 382 | Th_Render(zScript); |
| 383 | if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1); |
| 384 |