@@ -271,7 +271,7 @@ component extends="app.Controllers.Controller" {
271271 private function getBlogsByAuthor (required authorId , numeric page = 1 , numeric perPage = 6 , boolean isInfiniteScroll = false ) {
272272 var result = {
273273 query = model (" Blog" ).findAll (
274- where = " statusid <> 1 AND status = 'Approved' AND isPublished = 'true' AND createdBy = #authorId #" ,
274+ where = " statusid <> 1 AND status = 'Approved' AND isPublished IS TRUE AND createdBy = #authorId #" ,
275275 include = " User" ,
276276 order = " postDate DESC" ,
277277 page = arguments .page ,
@@ -282,7 +282,7 @@ component extends="app.Controllers.Controller" {
282282 };
283283
284284 result .totalCount = model (" Blog" ).count (
285- where = " statusid <> 1 AND status = 'Approved' AND isPublished = 'true' AND createdBy = #authorId #"
285+ where = " statusid <> 1 AND status = 'Approved' AND isPublished IS TRUE AND createdBy = #authorId #"
286286 );
287287 result .hasMore = (page * perPage ) < result .totalCount ;
288288
@@ -324,7 +324,7 @@ component extends="app.Controllers.Controller" {
324324
325325 if (len (trim (searchTerm ))) {
326326 var query = model (" blog" ).findAll (
327- where = " status ='Approved' AND isPublished='true'
327+ where = " status ='Approved' AND isPublished IS TRUE
328328 AND (slug LIKE '%#searchTerm #%' OR title LIKE '%#searchTerm #%' OR content LIKE '%#searchTerm #%' OR fullname LIKE '%#searchTerm #%' OR email LIKE '%#searchTerm #%')" ,
329329 include = " User, PostStatus, PostType" ,
330330 order = " postDate DESC" ,
@@ -335,7 +335,7 @@ component extends="app.Controllers.Controller" {
335335 if (isInfiniteScroll ) {
336336 totalCount = model (" blog" ).count (
337337 include = " User, PostStatus, PostType" ,
338- where = " status ='Approved' AND isPublished='true'
338+ where = " status ='Approved' AND isPublished IS TRUE
339339 AND (slug LIKE '%#searchTerm #%' OR title LIKE '%#searchTerm #%' OR content LIKE '%#searchTerm #%' OR fullname LIKE '%#searchTerm #%' OR email LIKE '%#searchTerm #%')"
340340 );
341341 hasMore = (page * perPage ) < totalCount ;
@@ -363,7 +363,7 @@ component extends="app.Controllers.Controller" {
363363 }
364364 // Function to load categories for the blog list
365365 function categories () {
366- categorylist = model (" Category" ).findAll (where = " isActive='true' " , cache = 60 );
366+ categorylist = model (" Category" ).findAll (where = " isActive IS TRUE " , cache = 60 );
367367 renderPartial (partial = " partials/categorylist" );
368368 }
369369
@@ -517,9 +517,21 @@ component extends="app.Controllers.Controller" {
517517 }
518518
519519 } catch (any e ) {
520- // TEMPORARY: show actual error for debugging
521- writeOutput (" <pre>BLOG SHOW ERROR:#chr (10 ) #Message: #e .message ##chr (10 ) #Detail: #e .detail ##chr (10 ) #</pre>" );
522- abort ;
520+ model (" Log" ).log (
521+ category = " wheels.blog" ,
522+ level = " ERROR" ,
523+ message = " Blog post not found" ,
524+ details = {
525+ " error_message" : e .message ,
526+ " error_detail" : e .detail ,
527+ " slug" : params .slug ,
528+ " ip_address" : cgi .REMOTE_ADDR
529+ },
530+ userId = GetSignedInUserId ()
531+ );
532+ // If an error occurs or blog not found, redirect to blog index
533+ redirectTo (action = " index" );
534+ return ;
523535 }
524536 }
525537
@@ -719,7 +731,7 @@ component extends="app.Controllers.Controller" {
719731 public function feed () {
720732 // Fetch all blogs
721733 blogPosts = model (" Blog" ).findAll (
722- where = " status = 'Approved' AND isPublished = 'true' " ,
734+ where = " status = 'Approved' AND isPublished IS TRUE " ,
723735 include = " User" ,
724736 order = " postDate DESC" ,
725737 cache = 10
@@ -732,7 +744,7 @@ component extends="app.Controllers.Controller" {
732744 public function commentsFeed () {
733745 // Get recent comments with related blog post
734746 comments = model (" Comment" ).findAll (
735- where = " isPublished = 'true' " ,
747+ where = " isPublished IS TRUE " ,
736748 include = " Blog" ,
737749 order = " createdAt DESC" ,
738750 limit = 20 ,
@@ -776,7 +788,7 @@ component extends="app.Controllers.Controller" {
776788 private function getAllBlogs (numeric page = 1 , numeric perPage = 6 , boolean isInfiniteScroll = false ) {
777789 var result = {
778790 query = model (" Blog" ).findAll (
779- where = " statusid <> 1 AND status = 'Approved' AND isPublished = 'true' " ,
791+ where = " statusid <> 1 AND status = 'Approved' AND isPublished IS TRUE " ,
780792 include = " User" ,
781793 order = " postDate DESC" ,
782794 page = arguments .page ,
@@ -788,7 +800,7 @@ component extends="app.Controllers.Controller" {
788800 };
789801
790802 result .totalCount = model (" Blog" ).count (
791- where = " statusid <> 1 AND status = 'Approved' AND isPublished = 'true' " ,
803+ where = " statusid <> 1 AND status = 'Approved' AND isPublished IS TRUE " ,
792804 cache = 5
793805 );
794806 result .hasMore = (page * perPage ) < result .totalCount ;
@@ -803,7 +815,7 @@ component extends="app.Controllers.Controller" {
803815
804816 var result = {
805817 query = model (" Blog" ).findAll (
806- where = " blog_posts.post_created_date BETWEEN '#startdate #' AND '#enddate #' AND blog_posts.status='Approved' AND blog_posts.isPublished='true' " ,
818+ where = " blog_posts.post_created_date BETWEEN '#startdate #' AND '#enddate #' AND blog_posts.status='Approved' AND blog_posts.isPublished IS TRUE " ,
807819 order = " postCreatedDate DESC" ,
808820 include = " User" ,
809821 returnAs = " query" ,
@@ -815,7 +827,7 @@ component extends="app.Controllers.Controller" {
815827 };
816828
817829 result .totalCount = model (" Blog" ).count (
818- where = " blog_posts.post_created_date BETWEEN '#startdate #' AND '#enddate #' AND blog_posts.status='Approved' AND blog_posts.isPublished='true' "
830+ where = " blog_posts.post_created_date BETWEEN '#startdate #' AND '#enddate #' AND blog_posts.status='Approved' AND blog_posts.isPublished IS TRUE "
819831 );
820832 result .hasMore = (page * perPage ) < result .totalCount ;
821833
@@ -838,7 +850,7 @@ component extends="app.Controllers.Controller" {
838850
839851 var result = {
840852 query = model (" Blog" ).findAll (
841- where = " id IN (#arrayToList (blogIds ) #) AND categoryId = '#category .id #' AND status ='Approved' AND isPublished='true' " ,
853+ where = " id IN (#arrayToList (blogIds ) #) AND categoryId = '#category .id #' AND status ='Approved' AND isPublished IS TRUE " ,
842854 order = " createdAt DESC" ,
843855 include = " User,BlogCategory" ,
844856 returnAs = " query" ,
@@ -850,7 +862,7 @@ component extends="app.Controllers.Controller" {
850862 };
851863
852864 result .totalCount = model (" Blog" ).count (
853- where = " id IN (#arrayToList (blogIds ) #) AND categoryId = '#category .id #' AND status ='Approved' AND isPublished='true' " ,
865+ where = " id IN (#arrayToList (blogIds ) #) AND categoryId = '#category .id #' AND status ='Approved' AND isPublished IS TRUE " ,
854866 include = " User,BlogCategory"
855867 );
856868 result .hasMore = (page * perPage ) < result .totalCount ;
@@ -862,7 +874,7 @@ component extends="app.Controllers.Controller" {
862874 private function getAllByTag (required string tag , numeric page = 1 , numeric perPage = 6 , boolean isInfiniteScroll = false ) {
863875 var result = {
864876 query = model (" Blog" ).findAll (
865- where = " name = '#tag #' AND status ='Approved' AND isPublished='true' " ,
877+ where = " name = '#tag #' AND status ='Approved' AND isPublished IS TRUE " ,
866878 order = " createdAt DESC" ,
867879 include = " User,tag" ,
868880 returnAs = " query" ,
@@ -873,7 +885,7 @@ component extends="app.Controllers.Controller" {
873885 totalCount = 0
874886 };
875887
876- result .totalCount = model (" Blog" ).count (where = " name = '#tag #' AND status ='Approved' AND isPublished='true' " , include = " User,tag" );
888+ result .totalCount = model (" Blog" ).count (where = " name = '#tag #' AND status ='Approved' AND isPublished IS TRUE " , include = " User,tag" );
877889 result .hasMore = (page * perPage ) < result .totalCount ;
878890
879891 return result ;
@@ -1238,7 +1250,7 @@ component extends="app.Controllers.Controller" {
12381250 }
12391251
12401252 function getAllCommentsByBlogid (required numeric id ) {
1241- var comments = model (" Comment" ).findAll (include = " User" , where = " isPublished = 'true' AND blogid = '#arguments .id #' AND commentParentId ISNULL " , cache = 5 );
1253+ var comments = model (" Comment" ).findAll (include = " User" , where = " isPublished IS TRUE AND blogid = '#arguments .id #' AND commentParentId ISNULL " , cache = 5 );
12421254
12431255 return comments ;
12441256 }
@@ -1288,7 +1300,7 @@ component extends="app.Controllers.Controller" {
12881300 response = saveComment (params );
12891301 }
12901302 if (structKeyExists (response , " Id" )){
1291- comments = commentModel .findAll (include = " User" , where = " id ='#response .Id #' AND isPublished = 'true' " );
1303+ comments = commentModel .findAll (include = " User" , where = " id ='#response .Id #' AND isPublished IS TRUE " );
12921304 renderPartial (partial = " partials/comment" );
12931305 }
12941306 } catch (any e ) {
0 commit comments