Fossil SCM

Fix the /forum webpage so that it works even if the forumpost table does not exist in the repository.

drh 2018-08-10 16:51 trunk
Commit d73c5fd27e8af1a91c7b875a6ae9d60552554c2d9cf971e7d969f994a5fcdb62
1 file changed +20 -18
+20 -18
--- src/forum.c
+++ src/forum.c
@@ -925,27 +925,29 @@
925925
}
926926
iLimit = 50;
927927
iOfst = 0;
928928
@ <h1>Recent Threads</h1>
929929
@ <div class='fileage'><table width="100%%">
930
- db_prepare(&q,
931
- "SELECT julianday('now') - max(fmtime),"
932
- " (SELECT uuid FROM blob WHERE rid=fpid),"
933
- " (SELECT substr(comment,instr(comment,':')+2)"
934
- " FROM event WHERE objid=fpid)"
935
- " FROM forumpost"
936
- " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d",
937
- iLimit, iOfst
938
- );
939
- while( db_step(&q)==SQLITE_ROW ){
940
- char *zAge = human_readable_age(db_column_double(&q,0));
941
- const char *zUuid = db_column_text(&q, 1);
942
- const char *zTitle = db_column_text(&q, 2);
943
- @ <tr><td>%h(zAge) ago</td>
944
- @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a>
945
- @ </tr>
946
- fossil_free(zAge);
930
+ if( db_table_exists("repository","forumpost") ){
931
+ db_prepare(&q,
932
+ "SELECT julianday('now') - max(fmtime),"
933
+ " (SELECT uuid FROM blob WHERE rid=fpid),"
934
+ " (SELECT substr(comment,instr(comment,':')+2)"
935
+ " FROM event WHERE objid=fpid)"
936
+ " FROM forumpost"
937
+ " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d",
938
+ iLimit, iOfst
939
+ );
940
+ while( db_step(&q)==SQLITE_ROW ){
941
+ char *zAge = human_readable_age(db_column_double(&q,0));
942
+ const char *zUuid = db_column_text(&q, 1);
943
+ const char *zTitle = db_column_text(&q, 2);
944
+ @ <tr><td>%h(zAge) ago</td>
945
+ @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a>
946
+ @ </tr>
947
+ fossil_free(zAge);
948
+ }
949
+ db_finalize(&q);
947950
}
948951
@ </table></div>
949
- db_finalize(&q);
950952
style_footer();
951953
}
952954
--- src/forum.c
+++ src/forum.c
@@ -925,27 +925,29 @@
925 }
926 iLimit = 50;
927 iOfst = 0;
928 @ <h1>Recent Threads</h1>
929 @ <div class='fileage'><table width="100%%">
930 db_prepare(&q,
931 "SELECT julianday('now') - max(fmtime),"
932 " (SELECT uuid FROM blob WHERE rid=fpid),"
933 " (SELECT substr(comment,instr(comment,':')+2)"
934 " FROM event WHERE objid=fpid)"
935 " FROM forumpost"
936 " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d",
937 iLimit, iOfst
938 );
939 while( db_step(&q)==SQLITE_ROW ){
940 char *zAge = human_readable_age(db_column_double(&q,0));
941 const char *zUuid = db_column_text(&q, 1);
942 const char *zTitle = db_column_text(&q, 2);
943 @ <tr><td>%h(zAge) ago</td>
944 @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a>
945 @ </tr>
946 fossil_free(zAge);
 
 
 
947 }
948 @ </table></div>
949 db_finalize(&q);
950 style_footer();
951 }
952
--- src/forum.c
+++ src/forum.c
@@ -925,27 +925,29 @@
925 }
926 iLimit = 50;
927 iOfst = 0;
928 @ <h1>Recent Threads</h1>
929 @ <div class='fileage'><table width="100%%">
930 if( db_table_exists("repository","forumpost") ){
931 db_prepare(&q,
932 "SELECT julianday('now') - max(fmtime),"
933 " (SELECT uuid FROM blob WHERE rid=fpid),"
934 " (SELECT substr(comment,instr(comment,':')+2)"
935 " FROM event WHERE objid=fpid)"
936 " FROM forumpost"
937 " GROUP BY froot ORDER BY 1 LIMIT %d OFFSET %d",
938 iLimit, iOfst
939 );
940 while( db_step(&q)==SQLITE_ROW ){
941 char *zAge = human_readable_age(db_column_double(&q,0));
942 const char *zUuid = db_column_text(&q, 1);
943 const char *zTitle = db_column_text(&q, 2);
944 @ <tr><td>%h(zAge) ago</td>
945 @ <td>%z(href("%R/forumpost/%S",zUuid))%h(zTitle)</a>
946 @ </tr>
947 fossil_free(zAge);
948 }
949 db_finalize(&q);
950 }
951 @ </table></div>
 
952 style_footer();
953 }
954

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button