Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

A few checks for null value in PageComment


Reply


3 Posts   1433 Views

Avatar
xmedeko

Community Member, 94 Posts

18 June 2007 at 3:43pm

Edited: 18/06/2007 3:43pm

Hi,

in the PageComment.php, the $comment should be checked for null value (someone can delete the comment, while the other people view it.)

--- PageComment.php.orig 2007-06-18 15:35:32.000000000 +1200
+++ PageComment.php 2007-06-18 15:38:12.000000000 +1200
@@ -25,8 +25,10 @@
$member = Member::currentUser();
if($member && $member->isCMSUser()) {
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
+ if ($comment) {
$comment->delete();
}
+ }

if(Director::is_ajax()) {
echo "";
@@ -62,6 +64,7 @@
if(SSAkismet::isEnabled() && $member && $member->isCMSUser()) {
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);

+ if ($comment) {
try {
$akismet = new SSAkismet();
$akismet->setCommentAuthor($comment->getField('Name'));
@@ -79,6 +82,7 @@
$comment->delete();
}
}
+ }

if(Director::is_ajax()) {
if(SSAkismet::getSaveSpam()) {
@@ -95,7 +99,7 @@
$member = Member::currentUser();
if(SSAkismet::isEnabled() && $member && $member->isCMSUser()) {
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
-
+ if ($comment) {
try {
$akismet = new SSAkismet();
$akismet->setCommentAuthor($comment->getField('Name'));
@@ -109,6 +113,7 @@
$comment->setField('IsSpam', false);
$comment->write();
}
+ }

if(Director::is_ajax()) {
echo $comment->renderWith('PageCommentInterface_singlecomment');

Avatar
Sean

Forum Moderator, 922 Posts

18 June 2007 at 6:10pm

Thanks for your contribution. :-)

We'll endeavour to put your changes back into the cms module.

Cheers,
Sean

Avatar
Andy

230 Posts

19 June 2007 at 10:06am

Good spotting, this has been applied.