Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » A few checks for null value in PageComment

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

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

Page: 1
Go to End
Author Topic: 1385 Views
  • xmedeko
    Avatar
    Community Member
    94 Posts

    A few checks for null value in PageComment Link to this post

    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');

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: A few checks for null value in PageComment Link to this post

    Thanks for your contribution.

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

    Cheers,
    Sean

  • Andy
    Avatar
    230 Posts

    Re: A few checks for null value in PageComment Link to this post

    Good spotting, this has been applied.

    1385 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.