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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

A few checks for null value in PageComment


Go to End


2 Posts   1782 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