Skip to content

Commit

Permalink
name and email should be set, at least with empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
Klap-in committed Sep 21, 2022
1 parent 64e26cc commit 293f772
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions action/comments.php
Expand Up @@ -65,15 +65,15 @@ function handleCommentSaveAndSubscribeActions(Doku_Event $event, $param) {
// prepare data for comment form
$comment->setSource($INPUT->post->str('comment-source')); //from: comment, pingback or trackback
$name = $INPUT->post->str('comment-name');
$comment->setName($name ? $name : $INFO['userinfo']['name']);
$comment->setName($name ?: $INFO['userinfo']['name'] ?? '');
$mail = $INPUT->post->str('comment-mail');
$comment->setMail($mail ? $mail : $INFO['userinfo']['mail']);
$comment->setMail($mail ?: $INFO['userinfo']['mail'] ?? '');
$web = $INPUT->post->str('comment-web');
//add "http(s)://" to website
if ($web != '' && !preg_match('/^http/', $web)) {
$web = 'https://' . $web;
}
$comment->setWeb($web ? $web : '');
$comment->setWeb($web);
if($INPUT->post->has('wikitext')) {
$text = cleanText($INPUT->post->str('wikitext'));
} else {
Expand Down
8 changes: 4 additions & 4 deletions helper/comments.php
Expand Up @@ -468,7 +468,7 @@ public function close($pid) {
* @param string $tplname
*/
public function tpl_form($page, $pid, $tplname) {
global $BLOGTNG;
global $BLOGTNG; // set in action_plugin_blogtng_comments::handleCommentSaveAndSubscribeActions()

/** @var Comment $comment */
$comment = $BLOGTNG['comment'];
Expand All @@ -489,10 +489,10 @@ public function tpl_form($page, $pid, $tplname) {
} else {
$functionname = "get{$field}";
$input = $form->addTextInput('comment-' . $field , $this->getLang('comment_'.$field))
->val($comment->$functionname())
->id('blogtng__comment_' . $field)
->addClass('edit block')
->useInput(false);
->useInput(false)
->val($comment->$functionname());
if($BLOGTNG['comment_submit_errors'][$field]){
$input->addClass('error'); //old approach was overwrite block with error?
}
Expand Down Expand Up @@ -535,7 +535,7 @@ public function tpl_form($page, $pid, $tplname) {
echo $form->toHTML();

// fallback preview. Normally previewed using AJAX. Only initiate preview if no errors.
if(isset($BLOGTNG['comment_action']) && ($BLOGTNG['comment_action'] == 'preview') && empty($BLOGTNG['comment_submit_errors'])) {
if(isset($BLOGTNG['comment_action']) && $BLOGTNG['comment_action'] == 'preview' && empty($BLOGTNG['comment_submit_errors'])) {
print '<div id="blogtng__comment_preview">' . DOKU_LF;
$comment->setCid('preview');
$comment->output($tplname);
Expand Down

0 comments on commit 293f772

Please sign in to comment.