Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Using an alternate query in the content controller to track down a pr…

…oblem on the grails.org server.
  • Loading branch information...
commit 4a6fc75e531ceb6ec3b49d87b8470bc9a18f8487 1 parent 9877ca2
Peter Ledbrook authored
20  grails.org/grails-app/controllers/org/grails/ContentController.groovy
@@ -192,9 +192,13 @@ class ContentController extends BaseWikiController {
192 192
             render(template:"/shared/remoteError", [code:"page.id.missing"])
193 193
         }
194 194
         else {
195  
-            def page = WikiPage.findByTitle(params.id.decodeURL())
  195
+            // WikiPage.findAllByTitle should only return record, but at this time
  196
+            // (2010-06-24) it seems to be returning more on the grails.org server.
  197
+            // This is to help determine whether that's what is in fact happening.
  198
+            def pages = WikiPage.findAllByTitle(params.id.decodeURL(), [sort: "version", order: "desc"])
  199
+            if (pages?.size() > 1) log.warn "[editWikiPage] WikiPage.findAllByTitle() returned more than one record!"
196 200
 
197  
-            render(template:"wikiEdit",model:[wikiPage:page, update: params.update, editFormName: params.editFormName])
  201
+            render(template:"wikiEdit",model:[wikiPage:pages[0], update: params.update, editFormName: params.editFormName])
198 202
         }
199 203
     }
200 204
 
@@ -211,9 +215,9 @@ class ContentController extends BaseWikiController {
211 215
                 render(template:"/shared/remoteError", model:[code:"page.id.missing"])
212 216
             }
213 217
             else {
214  
-                WikiPage page = WikiPage.findByTitle(params.id.decodeURL())
215  
-                if(!page) {
216  
-                    page = new WikiPage(params)
  218
+                def pages = WikiPage.findAllByTitle(params.id.decodeURL(), [sort: "version", order: "desc"])
  219
+                if(!pages) {
  220
+                    def page = new WikiPage(params)
217 221
                     if (page.locked == null) page.locked = false
218 222
                     page.save()
219 223
                     if(page.hasErrors()) {
@@ -231,6 +235,12 @@ class ContentController extends BaseWikiController {
231 235
                     }
232 236
                 }
233 237
                 else {
  238
+                    // WikiPage.findAllByTitle should only return record, but at this time
  239
+                    // (2010-06-24) it seems to be returning more on the grails.org server.
  240
+                    // This is to help determine whether that's what is in fact happening.
  241
+                    if (pages?.size() > 1) log.warn "[saveWikiPage] WikiPage.findAllByTitle() returned more than one record!"
  242
+                    def page = pages[0]
  243
+
234 244
                     if(page.version != params.version.toLong()) {
235 245
                         render(template:"wikiEdit",model:[wikiPage:page, error:"page.optimistic.locking.failure"])
236 246
                     }

0 notes on commit 4a6fc75

Please sign in to comment.
Something went wrong with that request. Please try again.