OSDN Git Service

BugTrack2/381 Handle failure to add comment - comment plugin
authorumorigu <umorigu@gmail.com>
Sun, 7 Feb 2016 10:17:52 +0000 (19:17 +0900)
committerumorigu <umorigu@gmail.com>
Sun, 7 Feb 2016 11:40:07 +0000 (20:40 +0900)
en.lng.php
ja.lng.php
plugin/comment.inc.php

index b6012d1..7ca3256 100644 (file)
@@ -224,6 +224,8 @@ $_msg_comment = 'Comment: ';
 $_title_comment_collided = 'On updating  $1, a collision has occurred.';
 $_msg_comment_collided   = 'It seems that someone has already updated the page you were editing.<br />
  The comment was added, alhough it may be inserted in the wrong position.<br />';
+$_comment_plugin_fail_msg = 'It seems that someone has already updated the page you were editing.<br />
+ Failed to add the comment.<br />';
 
 ///////////////////////////////////////
 // deleted.inc.php
index d456cbe..43b7af8 100644 (file)
@@ -226,6 +226,8 @@ $_msg_comment = 'コメント: ';
 $_title_comment_collided = '$1 で【更新の衝突】が起きました';
 $_msg_comment_collided   = 'あなたがこのページを編集している間に、他の人が同じページを更新してしまったようです。<br />
 コメントを追加しましたが、違う位置に挿入されているかもしれません。<br />';
+$_comment_plugin_fail_msg = 'あなたがこのページを編集している間に、他の人が同じページを更新してしまったようです。<br />
+コメントの追加に失敗しました。<br />';
 
 ///////////////////////////////////////
 // deleted.inc.php
index 3dcabdb..6ef906f 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone
-// $Id: comment.inc.php,v 1.41 2011/01/25 15:01:01 henoheno Exp $
-// Copyright (C)
-//   2002-2005 PukiWiki Developers Team
+// comment.inc.php
+// Copyright
+//   2002-2016 PukiWiki Development Team
 //   2001-2002 Originally written by yu-ji
 // License: GPL v2 or (at your option) any later version
 //
@@ -22,6 +22,7 @@ function plugin_comment_action()
 {
        global $script, $vars, $now, $_title_updated, $_no_name;
        global $_msg_comment_collided, $_title_comment_collided;
+       global $_comment_plugin_fail_msg;
 
        if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
 
@@ -51,9 +52,11 @@ function plugin_comment_action()
        $postdata    = '';
        $comment_no  = 0;
        $above       = (isset($vars['above']) && $vars['above'] == '1');
+       $comment_added = FALSE;
        foreach (get_source($vars['refer']) as $line) {
                if (! $above) $postdata .= $line;
                if (preg_match('/^#comment/i', $line) && $comment_no++ == $vars['comment_no']) {
+                       $comment_added = TRUE;
                        if ($above) {
                                $postdata = rtrim($postdata) . "\n" .
                                        $comment . "\n" .
@@ -65,21 +68,23 @@ function plugin_comment_action()
                }
                if ($above) $postdata .= $line;
        }
-
        $title = $_title_updated;
        $body = '';
-       if (md5(get_source($vars['refer'], TRUE, TRUE)) !== $vars['digest']) {
+       if ($comment_added) {
+               // new comment added
+               if (md5(get_source($vars['refer'], TRUE, TRUE)) !== $vars['digest']) {
+                       $title = $_title_comment_collided;
+                       $body  = $_msg_comment_collided . make_pagelink($vars['refer']);
+               }
+               page_write($vars['refer'], $postdata);
+       } else {
+               // failed to add the comment
                $title = $_title_comment_collided;
-               $body  = $_msg_comment_collided . make_pagelink($vars['refer']);
+               $body  = $_comment_plugin_fail_msg . make_pagelink($vars['refer']);
        }
-
-       page_write($vars['refer'], $postdata);
-
        $retvars['msg']  = $title;
        $retvars['body'] = $body;
-
        $vars['page'] = $vars['refer'];
-
        return $retvars;
 }
 
@@ -130,4 +135,3 @@ EOD;
 
        return $string;
 }
-?>