mirror of
https://github.com/processwire/processwire.git
synced 2025-08-23 14:56:51 +02:00
Fix issue processwire/processwire-issues#1142
This commit is contained in:
@@ -74,7 +74,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
public static function getModuleInfo() {
|
public static function getModuleInfo() {
|
||||||
return array(
|
return array(
|
||||||
'title' => __('Comments', __FILE__),
|
'title' => __('Comments', __FILE__),
|
||||||
'version' => 107,
|
'version' => 108,
|
||||||
'summary' => __('Field that stores user posted comments for a single Page', __FILE__),
|
'summary' => __('Field that stores user posted comments for a single Page', __FILE__),
|
||||||
'installs' => array('InputfieldCommentsAdmin'),
|
'installs' => array('InputfieldCommentsAdmin'),
|
||||||
);
|
);
|
||||||
@@ -196,6 +196,8 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
$sleepValue = array();
|
$sleepValue = array();
|
||||||
if(!$value instanceof CommentArray) return $sleepValue;
|
if(!$value instanceof CommentArray) return $sleepValue;
|
||||||
$schemaVersion = $field->get('schemaVersion');
|
$schemaVersion = $field->get('schemaVersion');
|
||||||
|
$sanitizer = $this->wire('sanitizer'); /** @var Sanitizer $sanitizer */
|
||||||
|
$maxIdxLen = $this->wire('database')->getMaxIndexLength();
|
||||||
|
|
||||||
foreach($value as $comment) {
|
foreach($value as $comment) {
|
||||||
|
|
||||||
@@ -209,12 +211,12 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
'id' => $comment->id,
|
'id' => $comment->id,
|
||||||
'status' => $comment->status,
|
'status' => $comment->status,
|
||||||
'data' => $comment->text,
|
'data' => $comment->text,
|
||||||
'cite' => $comment->cite,
|
'cite' => $sanitizer->maxLength($comment->cite, 128, 128 * 3),
|
||||||
'email' => $comment->email,
|
'email' => $sanitizer->maxLength($comment->email, 128, 128 * 3),
|
||||||
'created' => $comment->created,
|
'created' => $comment->created,
|
||||||
'created_users_id' => $comment->created_users_id,
|
'created_users_id' => $comment->created_users_id,
|
||||||
'ip' => $comment->ip,
|
'ip' => $sanitizer->maxLength($comment->ip, 15),
|
||||||
'user_agent' => $comment->user_agent,
|
'user_agent' => $sanitizer->maxLength($comment->user_agent, $maxIdxLen, $maxIdxLen * 3),
|
||||||
);
|
);
|
||||||
|
|
||||||
if($schemaVersion > 0) $a['website'] = $comment->website;
|
if($schemaVersion > 0) $a['website'] = $comment->website;
|
||||||
@@ -1578,6 +1580,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
|
|
||||||
// use just first item, since only 1 comment
|
// use just first item, since only 1 comment
|
||||||
$value = $value[0];
|
$value = $value[0];
|
||||||
|
$value['sort'] = $nextSort;
|
||||||
|
|
||||||
// determine all values to set
|
// determine all values to set
|
||||||
foreach(array_keys($value) as $key) {
|
foreach(array_keys($value) as $key) {
|
||||||
@@ -1674,7 +1677,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get max 'sort' value for comments field
|
* Get max 'sort' value for comments field or -1 if no rows
|
||||||
*
|
*
|
||||||
* @param Page $page
|
* @param Page $page
|
||||||
* @param Field $field
|
* @param Field $field
|
||||||
@@ -1689,7 +1692,8 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
$query = $database->prepare($sql);
|
$query = $database->prepare($sql);
|
||||||
$query->bindValue(':pages_id', $page->id, \PDO::PARAM_INT);
|
$query->bindValue(':pages_id', $page->id, \PDO::PARAM_INT);
|
||||||
$query->execute();
|
$query->execute();
|
||||||
$value = (int) $query->fetchColumn();
|
$value = $query->fetchColumn();
|
||||||
|
$value = $value === null ? -1 : (int) $value;
|
||||||
$query->closeCursor();
|
$query->closeCursor();
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user