Fossil SCM

Fixed a logic bug which caused /json/wiki/create to not be able to create a new page.

stephan 2012-03-09 20:16 trunk
Commit 64c2ec012c7889c6ead9a73be9ef84bc623aa821
1 file changed +4 -4
+4 -4
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -262,15 +262,15 @@
262262
** here if it doesn't already exist. With that, save/create would
263263
** become one operation. That said, i expect there are people who
264264
** would categorize such behaviour as "being too clever" or "doing too
265265
** much automatically" (and i would likely agree with them).
266266
**
267
-** If allowCreateIfExists is true then this function will allow a new
267
+** If allowCreateIfNotExists is true then this function will allow a new
268268
** page to be created even if createMode is false.
269269
*/
270270
static cson_value * json_wiki_create_or_save(char createMode,
271
- char allowCreateIfExists){
271
+ char allowCreateIfNotExists){
272272
Blob content = empty_blob; /* wiki page content */
273273
cson_value * nameV; /* wiki page name */
274274
char const * zPageName; /* cstr form of page name */
275275
cson_value * contentV; /* passed-in content */
276276
cson_value * emptyContent = NULL; /* placeholder for empty content. */
@@ -304,20 +304,20 @@
304304
json_set_err(FSL_JSON_E_RESOURCE_ALREADY_EXISTS,
305305
"Wiki page '%s' already exists.",
306306
zPageName);
307307
goto error;
308308
}
309
- }else if(!allowCreateIfExists){
309
+ }else if(!createMode && !allowCreateIfNotExists){
310310
json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND,
311311
"Wiki page '%s' not found.",
312312
zPageName);
313313
goto error;
314314
}
315315
316316
contentV = json_req_payload_get("content");
317317
if( !contentV ){
318
- if( createMode || (!rid && allowCreateIfExists) ){
318
+ if( createMode || (!rid && allowCreateIfNotExists) ){
319319
contentV = emptyContent = cson_value_new_string("",0);
320320
}else{
321321
json_set_err(FSL_JSON_E_MISSING_ARGS,
322322
"'content' parameter is missing.");
323323
goto error;
324324
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -262,15 +262,15 @@
262 ** here if it doesn't already exist. With that, save/create would
263 ** become one operation. That said, i expect there are people who
264 ** would categorize such behaviour as "being too clever" or "doing too
265 ** much automatically" (and i would likely agree with them).
266 **
267 ** If allowCreateIfExists is true then this function will allow a new
268 ** page to be created even if createMode is false.
269 */
270 static cson_value * json_wiki_create_or_save(char createMode,
271 char allowCreateIfExists){
272 Blob content = empty_blob; /* wiki page content */
273 cson_value * nameV; /* wiki page name */
274 char const * zPageName; /* cstr form of page name */
275 cson_value * contentV; /* passed-in content */
276 cson_value * emptyContent = NULL; /* placeholder for empty content. */
@@ -304,20 +304,20 @@
304 json_set_err(FSL_JSON_E_RESOURCE_ALREADY_EXISTS,
305 "Wiki page '%s' already exists.",
306 zPageName);
307 goto error;
308 }
309 }else if(!allowCreateIfExists){
310 json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND,
311 "Wiki page '%s' not found.",
312 zPageName);
313 goto error;
314 }
315
316 contentV = json_req_payload_get("content");
317 if( !contentV ){
318 if( createMode || (!rid && allowCreateIfExists) ){
319 contentV = emptyContent = cson_value_new_string("",0);
320 }else{
321 json_set_err(FSL_JSON_E_MISSING_ARGS,
322 "'content' parameter is missing.");
323 goto error;
324
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -262,15 +262,15 @@
262 ** here if it doesn't already exist. With that, save/create would
263 ** become one operation. That said, i expect there are people who
264 ** would categorize such behaviour as "being too clever" or "doing too
265 ** much automatically" (and i would likely agree with them).
266 **
267 ** If allowCreateIfNotExists is true then this function will allow a new
268 ** page to be created even if createMode is false.
269 */
270 static cson_value * json_wiki_create_or_save(char createMode,
271 char allowCreateIfNotExists){
272 Blob content = empty_blob; /* wiki page content */
273 cson_value * nameV; /* wiki page name */
274 char const * zPageName; /* cstr form of page name */
275 cson_value * contentV; /* passed-in content */
276 cson_value * emptyContent = NULL; /* placeholder for empty content. */
@@ -304,20 +304,20 @@
304 json_set_err(FSL_JSON_E_RESOURCE_ALREADY_EXISTS,
305 "Wiki page '%s' already exists.",
306 zPageName);
307 goto error;
308 }
309 }else if(!createMode && !allowCreateIfNotExists){
310 json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND,
311 "Wiki page '%s' not found.",
312 zPageName);
313 goto error;
314 }
315
316 contentV = json_req_payload_get("content");
317 if( !contentV ){
318 if( createMode || (!rid && allowCreateIfNotExists) ){
319 contentV = emptyContent = cson_value_new_string("",0);
320 }else{
321 json_set_err(FSL_JSON_E_MISSING_ARGS,
322 "'content' parameter is missing.");
323 goto error;
324

Keyboard Shortcuts

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