updated core from 8.4 to 8.5 : bug with login_destination
This commit is contained in:
@@ -8,8 +8,8 @@ dependencies:
|
||||
- text
|
||||
configure: comment.admin
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457826
|
||||
|
||||
@@ -6,5 +6,5 @@ dependencies:
|
||||
id: comment_publish_action
|
||||
label: 'Publish comment'
|
||||
type: comment
|
||||
plugin: comment_publish_action
|
||||
plugin: entity:publish_action:comment
|
||||
configuration: { }
|
||||
|
||||
@@ -6,5 +6,5 @@ dependencies:
|
||||
id: comment_save_action
|
||||
label: 'Save comment'
|
||||
type: comment
|
||||
plugin: comment_save_action
|
||||
plugin: entity:save_action:comment
|
||||
configuration: { }
|
||||
|
||||
@@ -6,5 +6,5 @@ dependencies:
|
||||
id: comment_unpublish_action
|
||||
label: 'Unpublish comment'
|
||||
type: comment
|
||||
plugin: comment_unpublish_action
|
||||
plugin: entity:unpublish_action:comment
|
||||
configuration: { }
|
||||
|
||||
@@ -15,10 +15,14 @@ field.widget.settings.comment_default:
|
||||
type: mapping
|
||||
label: 'Comment display format settings'
|
||||
|
||||
# @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
|
||||
# @see https://www.drupal.org/node/2919303
|
||||
action.configuration.comment_publish_action:
|
||||
type: action_configuration_default
|
||||
label: 'Publish comment configuration'
|
||||
|
||||
# @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
|
||||
# @see https://www.drupal.org/node/2919303
|
||||
action.configuration.comment_save_action:
|
||||
type: action_configuration_default
|
||||
label: 'Save comment configuration'
|
||||
@@ -34,6 +38,8 @@ action.configuration.comment_unpublish_by_keyword_action:
|
||||
type: string
|
||||
label: 'Keyword'
|
||||
|
||||
# @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
|
||||
# @see https://www.drupal.org/node/2919303
|
||||
action.configuration.comment_unpublish_action:
|
||||
type: action_configuration_default
|
||||
label: 'Unpublish comment configuration'
|
||||
@@ -105,7 +111,7 @@ field.field_settings.comment:
|
||||
label: 'Mode'
|
||||
form_location:
|
||||
type: boolean
|
||||
label: ' Allow comment title'
|
||||
label: 'Allow comment title'
|
||||
preview:
|
||||
type: integer
|
||||
label: 'Preview comment'
|
||||
|
||||
@@ -66,9 +66,11 @@
|
||||
// Find the parent <li>.
|
||||
.closest('.comment-new-comments')
|
||||
// Find the preceding <li>, if any, and give it the 'last' class.
|
||||
.prev().addClass('last')
|
||||
.prev()
|
||||
.addClass('last')
|
||||
// Go back to the parent <li> and hide it.
|
||||
.end().hide();
|
||||
.end()
|
||||
.hide();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,9 +97,11 @@
|
||||
// Find the parent <li>.
|
||||
.closest('.comment-new-comments')
|
||||
// Find the preceding <li>, if any, and remove its 'last' class, if any.
|
||||
.prev().removeClass('last')
|
||||
.prev()
|
||||
.removeClass('last')
|
||||
// Go back to the parent <li> and show it.
|
||||
.end().show();
|
||||
.end()
|
||||
.show();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,15 +149,15 @@
|
||||
* Data about new comment links indexed by nodeID.
|
||||
*/
|
||||
function render(results) {
|
||||
for (const nodeID in results) {
|
||||
if (results.hasOwnProperty(nodeID) && $placeholdersToUpdate.hasOwnProperty(nodeID)) {
|
||||
Object.keys(results || {}).forEach((nodeID) => {
|
||||
if ($placeholdersToUpdate.hasOwnProperty(nodeID)) {
|
||||
$placeholdersToUpdate[nodeID]
|
||||
.attr('href', results[nodeID].first_new_comment_link)
|
||||
.text(Drupal.formatPlural(results[nodeID].new_comment_count, '1 new comment', '@count new comments'))
|
||||
.removeClass('hidden');
|
||||
show($placeholdersToUpdate[nodeID]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (drupalSettings.comment && drupalSettings.comment.newCommentsLinks) {
|
||||
|
||||
@@ -70,12 +70,12 @@
|
||||
}
|
||||
|
||||
function render(results) {
|
||||
for (var nodeID in results) {
|
||||
if (results.hasOwnProperty(nodeID) && $placeholdersToUpdate.hasOwnProperty(nodeID)) {
|
||||
Object.keys(results || {}).forEach(function (nodeID) {
|
||||
if ($placeholdersToUpdate.hasOwnProperty(nodeID)) {
|
||||
$placeholdersToUpdate[nodeID].attr('href', results[nodeID].first_new_comment_link).text(Drupal.formatPlural(results[nodeID].new_comment_count, '1 new comment', '@count new comments')).removeClass('hidden');
|
||||
show($placeholdersToUpdate[nodeID]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (drupalSettings.comment && drupalSettings.comment.newCommentsLinks) {
|
||||
|
||||
+2
@@ -1,7 +1,9 @@
|
||||
id: d6_comment
|
||||
label: Comments
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Content
|
||||
source:
|
||||
plugin: d6_comment
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d6_comment_entity_display
|
||||
label: Comment display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d6_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d6_comment_entity_form_display
|
||||
label: Comment field form display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d6_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d6_comment_entity_form_display_subject
|
||||
label: Comment subject form display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d6_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d6_comment_field
|
||||
label: Comment field configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d6_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d6_comment_field_instance
|
||||
label: Comment field instance configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d6_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d6_comment_type
|
||||
label: Comment type
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d6_node_type
|
||||
constants:
|
||||
+2
@@ -1,7 +1,9 @@
|
||||
id: d7_comment
|
||||
label: Comments
|
||||
audit: true
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Content
|
||||
source:
|
||||
plugin: d7_comment
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d7_comment_entity_display
|
||||
label: Comment display configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d7_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d7_comment_entity_form_display
|
||||
label: Comment field form display configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d7_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d7_comment_entity_form_display_subject
|
||||
label: Comment subject form display configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d7_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d7_comment_field
|
||||
label: Comment field configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d7_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d7_comment_field_instance
|
||||
label: Comment field instance configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d7_node_type
|
||||
constants:
|
||||
+1
@@ -2,6 +2,7 @@ id: d7_comment_type
|
||||
label: Comment type
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
source:
|
||||
plugin: d7_node_type
|
||||
constants:
|
||||
@@ -18,6 +18,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Base handler for comment forms.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CommentForm extends ContentEntityForm {
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Base form handler for comment type edit forms.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CommentTypeForm extends EntityForm {
|
||||
|
||||
|
||||
@@ -279,9 +279,12 @@ class CommentController extends ControllerBase {
|
||||
// Check if the user has the proper permissions.
|
||||
$access = AccessResult::allowedIfHasPermission($account, 'post comments');
|
||||
|
||||
// If commenting is open on the entity.
|
||||
$status = $entity->{$field_name}->status;
|
||||
$access = $access->andIf(AccessResult::allowedIf($status == CommentItemInterface::OPEN)
|
||||
->addCacheableDependency($entity));
|
||||
->addCacheableDependency($entity))
|
||||
// And if user has access to the host entity.
|
||||
->andIf(AccessResult::allowedIf($entity->access('view')));
|
||||
|
||||
// $pid indicates that this is a reply to a comment.
|
||||
if ($pid) {
|
||||
|
||||
@@ -9,11 +9,13 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\user\PrivateTempStoreFactory;
|
||||
use Drupal\Core\TempStore\PrivateTempStoreFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Provides the comments overview administration form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CommentAdminOverview extends FormBase {
|
||||
|
||||
@@ -48,7 +50,7 @@ class CommentAdminOverview extends FormBase {
|
||||
/**
|
||||
* The tempstore factory.
|
||||
*
|
||||
* @var \Drupal\user\PrivateTempStoreFactory
|
||||
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
|
||||
*/
|
||||
protected $tempStoreFactory;
|
||||
|
||||
@@ -61,7 +63,7 @@ class CommentAdminOverview extends FormBase {
|
||||
* The date formatter service.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler.
|
||||
* @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
|
||||
* The tempstore factory.
|
||||
*/
|
||||
public function __construct(EntityTypeManagerInterface $entity_type_manager, DateFormatterInterface $date_formatter, ModuleHandlerInterface $module_handler, PrivateTempStoreFactory $temp_store_factory) {
|
||||
@@ -80,7 +82,7 @@ class CommentAdminOverview extends FormBase {
|
||||
$container->get('entity_type.manager'),
|
||||
$container->get('date.formatter'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('user.private_tempstore')
|
||||
$container->get('tempstore.private')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Provides a confirmation form for deleting a comment type entity.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CommentTypeDeleteForm extends EntityDeleteForm {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Drupal\comment\Form;
|
||||
|
||||
use Drupal\comment\CommentStorageInterface;
|
||||
use Drupal\user\PrivateTempStoreFactory;
|
||||
use Drupal\Core\TempStore\PrivateTempStoreFactory;
|
||||
use Drupal\Core\Form\ConfirmFormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Url;
|
||||
@@ -11,13 +11,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Provides the comment multiple delete confirmation form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfirmDeleteMultiple extends ConfirmFormBase {
|
||||
|
||||
/**
|
||||
* The tempstore factory.
|
||||
*
|
||||
* @var \Drupal\user\PrivateTempStoreFactory
|
||||
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
|
||||
*/
|
||||
protected $tempStoreFactory;
|
||||
|
||||
@@ -40,7 +42,7 @@ class ConfirmDeleteMultiple extends ConfirmFormBase {
|
||||
*
|
||||
* @param \Drupal\comment\CommentStorageInterface $comment_storage
|
||||
* The comment storage.
|
||||
* @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
|
||||
* The tempstore factory.
|
||||
*/
|
||||
public function __construct(CommentStorageInterface $comment_storage, PrivateTempStoreFactory $temp_store_factory) {
|
||||
@@ -54,7 +56,7 @@ class ConfirmDeleteMultiple extends ConfirmFormBase {
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('entity.manager')->getStorage('comment'),
|
||||
$container->get('user.private_tempstore')
|
||||
$container->get('tempstore.private')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ use Drupal\Core\Entity\ContentEntityDeleteForm;
|
||||
|
||||
/**
|
||||
* Provides the comment delete confirmation form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DeleteForm extends ContentEntityDeleteForm {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Drupal\comment\Plugin\Action;
|
||||
use Drupal\Core\Action\ActionBase;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\user\PrivateTempStoreFactory;
|
||||
use Drupal\Core\TempStore\PrivateTempStoreFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ class DeleteComment extends ActionBase implements ContainerFactoryPluginInterfac
|
||||
/**
|
||||
* The tempstore object.
|
||||
*
|
||||
* @var \Drupal\user\PrivateTempStore
|
||||
* @var \Drupal\Core\TempStore\PrivateTempStore
|
||||
*/
|
||||
protected $tempStore;
|
||||
|
||||
@@ -43,7 +43,7 @@ class DeleteComment extends ActionBase implements ContainerFactoryPluginInterfac
|
||||
* The plugin ID for the plugin instance.
|
||||
* @param array $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
|
||||
* The tempstore factory.
|
||||
* @param \Drupal\Core\Session\AccountInterface $current_user
|
||||
* The current user.
|
||||
@@ -62,7 +62,7 @@ class DeleteComment extends ActionBase implements ContainerFactoryPluginInterfac
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('user.private_tempstore'),
|
||||
$container->get('tempstore.private'),
|
||||
$container->get('current_user')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,37 +2,32 @@
|
||||
|
||||
namespace Drupal\comment\Plugin\Action;
|
||||
|
||||
use Drupal\Core\Action\ActionBase;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Action\Plugin\Action\PublishAction;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
|
||||
/**
|
||||
* Publishes a comment.
|
||||
*
|
||||
* @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\Action\Plugin\Action\PublishAction instead.
|
||||
*
|
||||
* @see \Drupal\Core\Action\Plugin\Action\PublishAction
|
||||
* @see https://www.drupal.org/node/2919303
|
||||
*
|
||||
* @Action(
|
||||
* id = "comment_publish_action",
|
||||
* label = @Translation("Publish comment"),
|
||||
* type = "comment"
|
||||
* )
|
||||
*/
|
||||
class PublishComment extends ActionBase {
|
||||
class PublishComment extends PublishAction {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute($comment = NULL) {
|
||||
$comment->setPublished(TRUE);
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
|
||||
/** @var \Drupal\comment\CommentInterface $object */
|
||||
$result = $object->status->access('edit', $account, TRUE)
|
||||
->andIf($object->access('update', $account, TRUE));
|
||||
|
||||
return $return_as_object ? $result : $result->isAllowed();
|
||||
public function __construct($configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager);
|
||||
@trigger_error(__NAMESPACE__ . '\PublishComment is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\Core\Action\Plugin\Action\PublishAction instead. See https://www.drupal.org/node/2919303.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,33 +2,33 @@
|
||||
|
||||
namespace Drupal\comment\Plugin\Action;
|
||||
|
||||
use Drupal\Core\Action\ActionBase;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Component\Datetime\TimeInterface;
|
||||
use Drupal\Core\Action\Plugin\Action\SaveAction;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
|
||||
/**
|
||||
* Saves a comment.
|
||||
*
|
||||
* @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\Action\Plugin\Action\SaveAction instead.
|
||||
*
|
||||
* @see \Drupal\Core\Action\Plugin\Action\SaveAction
|
||||
* @see https://www.drupal.org/node/2919303
|
||||
*
|
||||
* @Action(
|
||||
* id = "comment_save_action",
|
||||
* label = @Translation("Save comment"),
|
||||
* type = "comment"
|
||||
* )
|
||||
*/
|
||||
class SaveComment extends ActionBase {
|
||||
class SaveComment extends SaveAction {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute($comment = NULL) {
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
|
||||
/** @var \Drupal\comment\CommentInterface $object */
|
||||
return $object->access('update', $account, $return_as_object);
|
||||
public function __construct($configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, TimeInterface $time) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $time);
|
||||
@trigger_error(__NAMESPACE__ . '\SaveComment is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\Core\Action\Plugin\Action\SaveAction instead. See https://www.drupal.org/node/2919303.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,37 +2,32 @@
|
||||
|
||||
namespace Drupal\comment\Plugin\Action;
|
||||
|
||||
use Drupal\Core\Action\ActionBase;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Action\Plugin\Action\UnpublishAction;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
|
||||
/**
|
||||
* Unpublishes a comment.
|
||||
*
|
||||
* @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\Core\Action\Plugin\Action\UnpublishAction instead.
|
||||
*
|
||||
* @see \Drupal\Core\Action\Plugin\Action\UnpublishAction
|
||||
* @see https://www.drupal.org/node/2919303
|
||||
*
|
||||
* @Action(
|
||||
* id = "comment_unpublish_action",
|
||||
* label = @Translation("Unpublish comment"),
|
||||
* type = "comment"
|
||||
* )
|
||||
*/
|
||||
class UnpublishComment extends ActionBase {
|
||||
class UnpublishComment extends UnpublishAction {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute($comment = NULL) {
|
||||
$comment->setPublished(FALSE);
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
|
||||
/** @var \Drupal\comment\CommentInterface $object */
|
||||
$result = $object->status->access('edit', $account, TRUE)
|
||||
->andIf($object->access('update', $account, TRUE));
|
||||
|
||||
return $return_as_object ? $result : $result->isAllowed();
|
||||
public function __construct($configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager);
|
||||
@trigger_error(__NAMESPACE__ . '\UnpublishComment is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\Core\Action\Plugin\Action\UnpublishAction instead. See https://www.drupal.org/node/2919303.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class CommentSelection extends DefaultSelection {
|
||||
|
||||
// Passing the query to node_query_node_access_alter() is sadly
|
||||
// insufficient for nodes.
|
||||
// @see SelectionEntityTypeNode::entityQueryAlter()
|
||||
// @see \Drupal\node\Plugin\EntityReferenceSelection\NodeSelection::buildEntityQuery()
|
||||
if (!$this->currentUser->hasPermission('bypass node access') && !count($this->moduleHandler->getImplementations('node_grants'))) {
|
||||
$query->condition($node_alias . '.status', 1);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use Drupal\Core\Menu\LocalTaskDefault;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Provides a local task that shows the amount of unapproved comments.
|
||||
@@ -53,7 +54,7 @@ class UnapprovedComments extends LocalTaskDefault implements ContainerFactoryPlu
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTitle() {
|
||||
public function getTitle(Request $request = NULL) {
|
||||
return $this->t('Unapproved comments (@count)', ['@count' => $this->commentStorage->getUnapprovedCount()]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\comment\Plugin\views\field;
|
||||
|
||||
use Drupal\system\Plugin\views\field\BulkForm;
|
||||
use Drupal\views\Plugin\views\field\BulkForm;
|
||||
|
||||
/**
|
||||
* Defines a comment operations bulk form element.
|
||||
|
||||
@@ -30,14 +30,6 @@ class Comment extends WizardPluginBase {
|
||||
* Set default values for the filters.
|
||||
*/
|
||||
protected $filters = [
|
||||
'status' => [
|
||||
'value' => TRUE,
|
||||
'table' => 'comment_field_data',
|
||||
'field' => 'status',
|
||||
'plugin_id' => 'boolean',
|
||||
'entity_type' => 'comment',
|
||||
'entity_field' => 'status',
|
||||
],
|
||||
'status_node' => [
|
||||
'value' => TRUE,
|
||||
'table' => 'node_field_data',
|
||||
|
||||
@@ -63,8 +63,8 @@ abstract class CommentTestBase extends ViewTestBase {
|
||||
*/
|
||||
protected $comment;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
|
||||
|
||||
|
||||
+3
-3
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- comment
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457826
|
||||
|
||||
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- comment
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457826
|
||||
|
||||
@@ -8,8 +8,8 @@ dependencies:
|
||||
- comment
|
||||
- views
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457826
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\comment\Functional;
|
||||
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests comment administration and preview access.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentAccessTest extends BrowserTestBase {
|
||||
|
||||
use CommentTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'node',
|
||||
'comment',
|
||||
];
|
||||
|
||||
/**
|
||||
* Node for commenting.
|
||||
*
|
||||
* @var \Drupal\node\NodeInterface
|
||||
*/
|
||||
protected $unpublishedNode;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$node_type = NodeType::create([
|
||||
'type' => 'article',
|
||||
'name' => 'Article',
|
||||
]);
|
||||
$node_type->save();
|
||||
$node_author = $this->drupalCreateUser([
|
||||
'create article content',
|
||||
'access comments',
|
||||
]);
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser([
|
||||
'edit own comments',
|
||||
'skip comment approval',
|
||||
'post comments',
|
||||
'access comments',
|
||||
'access content',
|
||||
]));
|
||||
|
||||
$this->addDefaultCommentField('node', 'article');
|
||||
$this->unpublishedNode = $this->createNode([
|
||||
'title' => 'This is unpublished',
|
||||
'uid' => $node_author->id(),
|
||||
'status' => 0,
|
||||
'type' => 'article',
|
||||
]);
|
||||
$this->unpublishedNode->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests commenting disabled for access-blocked entities.
|
||||
*/
|
||||
public function testCannotCommentOnEntitiesYouCannotView() {
|
||||
$assert = $this->assertSession();
|
||||
|
||||
$comment_url = 'comment/reply/node/' . $this->unpublishedNode->id() . '/comment';
|
||||
|
||||
// Commenting on an unpublished node results in access denied.
|
||||
$this->drupalGet($comment_url);
|
||||
$assert->statusCodeEquals(403);
|
||||
|
||||
// Publishing the node grants access.
|
||||
$this->unpublishedNode->setPublished(TRUE)->save();
|
||||
$this->drupalGet($comment_url);
|
||||
$assert->statusCodeEquals(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests cannot view comment reply form on entities you cannot view.
|
||||
*/
|
||||
public function testCannotViewCommentReplyFormOnEntitiesYouCannotView() {
|
||||
$assert = $this->assertSession();
|
||||
|
||||
// Create a comment on an unpublished node.
|
||||
$comment = Comment::create([
|
||||
'entity_type' => 'node',
|
||||
'name' => 'Tony',
|
||||
'hostname' => 'magic.example.com',
|
||||
'mail' => 'foo@example.com',
|
||||
'subject' => 'Comment on unpublished node',
|
||||
'entity_id' => $this->unpublishedNode->id(),
|
||||
'comment_type' => 'comment',
|
||||
'field_name' => 'comment',
|
||||
'pid' => 0,
|
||||
'uid' => $this->unpublishedNode->getOwnerId(),
|
||||
'status' => 1,
|
||||
]);
|
||||
$comment->save();
|
||||
|
||||
$comment_url = 'comment/reply/node/' . $this->unpublishedNode->id() . '/comment/' . $comment->id();
|
||||
|
||||
// Replying to a comment on an unpublished node results in access denied.
|
||||
$this->drupalGet($comment_url);
|
||||
$assert->statusCodeEquals(403);
|
||||
|
||||
// Publishing the node grants access.
|
||||
$this->unpublishedNode->setPublished(TRUE)->save();
|
||||
$this->drupalGet($comment_url);
|
||||
$assert->statusCodeEquals(200);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class CommentActionsTest extends CommentTestBase {
|
||||
$action = Action::load('comment_unpublish_action');
|
||||
$action->execute([$comment]);
|
||||
$this->assertTrue($comment->isPublished() === FALSE, 'Comment was unpublished');
|
||||
|
||||
$this->assertArraySubset(['module' => ['comment']], $action->getDependencies());
|
||||
// Publish a comment.
|
||||
$action = Action::load('comment_publish_action');
|
||||
$action->execute([$comment]);
|
||||
|
||||
@@ -450,6 +450,7 @@ class CommentNonNodeTest extends BrowserTestBase {
|
||||
'post comments',
|
||||
'administer comment fields',
|
||||
'administer comment types',
|
||||
'view test entity',
|
||||
]);
|
||||
$this->drupalLogin($limited_user);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class CommentPreviewTest extends CommentTestBase {
|
||||
|
||||
// Add a user picture.
|
||||
$image = current($this->drupalGetTestFiles('image'));
|
||||
$user_edit['files[user_picture_0]'] = drupal_realpath($image->uri);
|
||||
$user_edit['files[user_picture_0]'] = \Drupal::service('file_system')->realpath($image->uri);
|
||||
$this->drupalPostForm('user/' . $this->webUser->id() . '/edit', $user_edit, t('Save'));
|
||||
|
||||
// As the web user, fill in the comment form and preview the comment.
|
||||
@@ -117,6 +117,8 @@ class CommentPreviewTest extends CommentTestBase {
|
||||
|
||||
// Go back and re-submit the form.
|
||||
$this->getSession()->getDriver()->back();
|
||||
$submit_button = $this->assertSession()->buttonExists('Save');
|
||||
$submit_button->click();
|
||||
$this->assertText('Your comment has been posted.');
|
||||
$elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article');
|
||||
$this->assertEqual(2, count($elements));
|
||||
|
||||
@@ -144,6 +144,7 @@ class CommentTokenReplaceTest extends CommentTestBase {
|
||||
|
||||
// Create a user and a comment.
|
||||
$user = User::create(['name' => 'alice']);
|
||||
$user->activate();
|
||||
$user->save();
|
||||
$this->postComment($user, 'user body', 'user subject', TRUE);
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\comment\Kernel;
|
||||
|
||||
use Drupal\comment\Entity\CommentType;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests that comment bundles behave as expected.
|
||||
*
|
||||
* @group comment
|
||||
*/
|
||||
class CommentBundlesTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['comment', 'node', 'taxonomy', 'user'];
|
||||
|
||||
/**
|
||||
* Entity type ids to use for target_entity_type_id on comment bundles.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $targetEntityTypes;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
|
||||
*/
|
||||
protected $entityFieldManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->entityFieldManager = $this->container->get('entity_field.manager');
|
||||
|
||||
$this->installEntitySchema('comment');
|
||||
|
||||
// Create multiple comment bundles,
|
||||
// each of which has a different target entity type.
|
||||
$this->targetEntityTypes = [
|
||||
'comment' => 'Comment',
|
||||
'node' => 'Node',
|
||||
'taxonomy_term' => 'Taxonomy Term',
|
||||
];
|
||||
foreach ($this->targetEntityTypes as $id => $label) {
|
||||
CommentType::create([
|
||||
'id' => 'comment_on_' . $id,
|
||||
'label' => 'Comment on ' . $label,
|
||||
'target_entity_type_id' => $id,
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the entity_id field is set correctly for each comment bundle.
|
||||
*/
|
||||
public function testEntityIdField() {
|
||||
$field_definitions = [];
|
||||
|
||||
foreach (array_keys($this->targetEntityTypes) as $id) {
|
||||
$bundle = 'comment_on_' . $id;
|
||||
$field_definitions[$bundle] = $this->entityFieldManager
|
||||
->getFieldDefinitions('comment', $bundle);
|
||||
}
|
||||
// Test that the value of the entity_id field for each bundle is correct.
|
||||
foreach ($field_definitions as $bundle => $definition) {
|
||||
$entity_type_id = str_replace('comment_on_', '', $bundle);
|
||||
$target_type = $definition['entity_id']->getSetting('target_type');
|
||||
$this->assertEquals($entity_type_id, $target_type);
|
||||
|
||||
// Verify that the target type remains correct
|
||||
// in the deeply-nested object properties.
|
||||
$nested_target_type = $definition['entity_id']->getItemDefinition()->getFieldDefinition()->getSetting('target_type');
|
||||
$this->assertEquals($entity_type_id, $nested_target_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\Tests\comment\Kernel\Migrate;
|
||||
|
||||
use Drupal\comment\Entity\CommentType;
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
|
||||
use Drupal\migrate_drupal\Tests\StubTestTrait;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
@@ -29,6 +28,8 @@ class MigrateCommentStubTest extends MigrateDrupalTestBase {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('comment');
|
||||
$this->installEntitySchema('node');
|
||||
$this->installSchema('system', ['sequences']);
|
||||
|
||||
// Make sure uid 0 is created (default uid for comments is 0).
|
||||
$storage = \Drupal::entityManager()->getStorage('user');
|
||||
// Insert a row for the anonymous user.
|
||||
@@ -55,18 +56,6 @@ class MigrateCommentStubTest extends MigrateDrupalTestBase {
|
||||
* Tests creation of comment stubs.
|
||||
*/
|
||||
public function testStub() {
|
||||
try {
|
||||
// We expect an exception, because there's no node to reference.
|
||||
$this->performStubTest('comment');
|
||||
$this->fail('Expected exception has not been thrown.');
|
||||
}
|
||||
catch (MigrateException $e) {
|
||||
$this->assertIdentical($e->getMessage(),
|
||||
'Stubbing failed, unable to generate value for field entity_id');
|
||||
}
|
||||
|
||||
// The stub should pass when there's a node to point to.
|
||||
$this->createStub('node');
|
||||
$this->performStubTest('comment');
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
||||
*/
|
||||
protected function getMockNode($has_field, $comment_status, $form_location, $comment_count) {
|
||||
$node = $this->getMock('\Drupal\node\NodeInterface');
|
||||
$node->expects($this->once())
|
||||
$node->expects($this->any())
|
||||
->method('hasField')
|
||||
->willReturn($has_field);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user