Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit 1227593

Browse files
committed
wip
1 parent 1a42ef1 commit 1227593

9 files changed

Lines changed: 42 additions & 235 deletions

File tree

app/controllers/Controller.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ component extends="wheels.Controller" {
101101
// Shared business logic across multiple controllers
102102
public function getBlogBySlug(required string slug) {
103103
return model("Blog").findOne(
104-
where="blog_posts.slug = '#arguments.slug#' AND status ='Approved' AND isPublished='true' ",
104+
where="blog_posts.slug = '#arguments.slug#' AND status ='Approved' AND isPublished IS TRUE ",
105105
include="User,PostStatus",
106106
cache=10
107107
);

app/controllers/admin/AdminController.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,8 @@ component extends="app.Controllers.Controller" {
655655
blogJsonData = serializeJSON(blogChartData);
656656

657657
totalComments = model("comment").count();
658-
totalPublishComments = model("comment").count(where="isPublished ='true'");
659-
totalUnPublishComments = model("comment").count(where="isPublished ='false'");
658+
totalPublishComments = model("comment").count(where="isPublished IS TRUE");
659+
totalUnPublishComments = model("comment").count(where="isPublished IS FALSE");
660660

661661
last_7Days_Comments = queryExecute("
662662
SELECT TO_CHAR(d::date, 'YYYY-MM-DD') AS day,

app/controllers/web/BlogController.cfc

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

app/controllers/web/HomeController.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ component extends="app.Controllers.Controller" {
321321
});
322322

323323
// Add blog posts
324-
var blogPosts = model("Blog").findAll(where="statusid <> 1 AND status = 'Approved' AND isPublished = 'true'");
324+
var blogPosts = model("Blog").findAll(where="statusid <> 1 AND status = 'Approved' AND isPublished IS TRUE");
325325
for (var post in blogPosts) {
326326
arrayAppend(urls, {
327327
loc: getBaseUrl() & "/blog/" & post.slug,
@@ -336,7 +336,7 @@ component extends="app.Controllers.Controller" {
336336
select="username",
337337
include="User",
338338
distinct="true",
339-
where="statusid <> 1 AND status = 'Approved' AND isPublished = 'true' AND createdBy IS NOT NULL"
339+
where="statusid <> 1 AND status = 'Approved' AND isPublished IS TRUE AND createdBy IS NOT NULL"
340340
);
341341
for (var author in authors) {
342342
arrayAppend(urls, {

app/controllers/web/NewsController.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ component extends="app.Controllers.Controller" {
4242
try {
4343
var blogQuery = model("Blog").findAll(
4444
select = "title, slug, content, postDate",
45-
where = "statusid <> 1 AND status = 'Approved' AND isPublished = 'true'",
45+
where = "statusid <> 1 AND status = 'Approved' AND isPublished IS TRUE",
4646
order = "createdAt DESC",
4747
cache = 10
4848
);

app/controllers/web/TestimonialController.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ component extends="app.Controllers.Controller" {
1313
*/
1414
public void function publicList() {
1515
testimonials = model("Testimonial").findAll(
16-
where="isApproved = 'true'",
16+
where="isApproved IS TRUE",
1717
include="User",
1818
order="createdAt DESC"
1919
);

app/models/Comment.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ component extends="app.Models.Model" {
3030

3131
// fetch all comments
3232
public function getAllComments(){
33-
var comments = findAll(where="isPublished = 'true'", include="User");
33+
var comments = findAll(where="isPublished IS TRUE", include="User");
3434
return comments;
3535
}
3636
}

app/models/Testimonial.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ component extends="app.Models.Model" {
5050

5151
mergedOptions.append(options, true);
5252

53-
conditions = "isApproved = 'true' AND displayPermission = 'true'";
53+
conditions = "isApproved IS TRUE AND displayPermission IS TRUE";
5454
if (mergedOptions.onlyFeatured) {
55-
conditions &= " AND isFeatured = 'true'";
55+
conditions &= " AND isFeatured IS TRUE";
5656
}
5757

5858
return model("Testimonial").findAll(

0 commit comments

Comments
 (0)