updated core to 8.6.1 via composer
This commit is contained in:
@@ -2,11 +2,11 @@ name: Forum
|
||||
type: module
|
||||
description: 'Provides discussion forums.'
|
||||
dependencies:
|
||||
- node
|
||||
- history
|
||||
- taxonomy
|
||||
- comment
|
||||
- options
|
||||
- drupal:node
|
||||
- drupal:history
|
||||
- drupal:taxonomy
|
||||
- drupal:comment
|
||||
- drupal:options
|
||||
package: Core
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
|
||||
@@ -522,6 +522,7 @@ function template_preprocess_forums(&$variables) {
|
||||
$table['#rows'][] = $row;
|
||||
}
|
||||
|
||||
$variables['topics_original'] = $variables['topics'];
|
||||
$variables['topics'] = $table;
|
||||
$variables['topics_pager'] = [
|
||||
'#type' => 'pager',
|
||||
|
||||
@@ -74,7 +74,7 @@ function forum_views_data() {
|
||||
'filter' => [
|
||||
'title' => t('Has taxonomy term'),
|
||||
'id' => 'taxonomy_index_tid',
|
||||
'hierarchy table' => 'taxonomy_term_hierarchy',
|
||||
'hierarchy table' => 'taxonomy_term__parent',
|
||||
'numeric' => TRUE,
|
||||
'skip base' => 'taxonomy_term_data',
|
||||
'allow empty' => TRUE,
|
||||
@@ -93,7 +93,7 @@ function forum_views_data() {
|
||||
'id' => 'date',
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'date'
|
||||
'id' => 'date',
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'date',
|
||||
|
||||
@@ -42,6 +42,13 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
|
||||
*/
|
||||
protected $forumManager;
|
||||
|
||||
/**
|
||||
* The taxonomy term storage.
|
||||
*
|
||||
* @var \Drupal\taxonomy\TermStorageInterface
|
||||
*/
|
||||
protected $termStorage;
|
||||
|
||||
/**
|
||||
* Constructs a forum breadcrumb builder object.
|
||||
*
|
||||
@@ -59,6 +66,7 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
|
||||
$this->config = $config_factory->get('forum.settings');
|
||||
$this->forumManager = $forum_manager;
|
||||
$this->setStringTranslation($string_translation);
|
||||
$this->termStorage = $entity_manager->getStorage('taxonomy_term');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ class ForumListingBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
||||
$term_id = $term->id();
|
||||
$breadcrumb->addCacheableDependency($term);
|
||||
|
||||
$parents = $this->forumManager->getParents($term_id);
|
||||
$parents = $this->termStorage->loadAllParents($term_id);
|
||||
if ($parents) {
|
||||
foreach (array_reverse($parents) as $parent) {
|
||||
if ($parent->id() != $term_id) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
||||
$breadcrumb = parent::build($route_match);
|
||||
$breadcrumb->addCacheContexts(['route']);
|
||||
|
||||
$parents = $this->forumManager->getParents($route_match->getParameter('node')->forum_tid);
|
||||
$parents = $this->termStorage->loadAllParents($route_match->getParameter('node')->forum_tid);
|
||||
if ($parents) {
|
||||
$parents = array_reverse($parents);
|
||||
foreach ($parents as $parent) {
|
||||
|
||||
@@ -63,7 +63,7 @@ class DeleteForm extends ConfirmFormBase {
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->taxonomyTerm->delete();
|
||||
drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', ['%label' => $this->taxonomyTerm->label()]));
|
||||
$this->messenger()->addStatus($this->t('The forum %label and all sub-forums have been deleted.', ['%label' => $this->taxonomyTerm->label()]));
|
||||
$this->logger('forum')->notice('forum: deleted %label and all its sub-forums.', ['%label' => $this->taxonomyTerm->label()]);
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
}
|
||||
|
||||
@@ -77,18 +77,18 @@ class ForumForm extends TermForm {
|
||||
$status = $term_storage->save($term);
|
||||
|
||||
$route_name = $this->urlStub == 'container' ? 'entity.taxonomy_term.forum_edit_container_form' : 'entity.taxonomy_term.forum_edit_form';
|
||||
$route_parameters = ['taxonomy_term' => $term->id()];
|
||||
$route_parameters = ['taxonomy_term' => $term->id()];
|
||||
$link = $this->l($this->t('Edit'), new Url($route_name, $route_parameters));
|
||||
$view_link = $term->link($term->getName());
|
||||
switch ($status) {
|
||||
case SAVED_NEW:
|
||||
drupal_set_message($this->t('Created new @type %term.', ['%term' => $view_link, '@type' => $this->forumFormType]));
|
||||
$this->messenger()->addStatus($this->t('Created new @type %term.', ['%term' => $view_link, '@type' => $this->forumFormType]));
|
||||
$this->logger('forum')->notice('Created new @type %term.', ['%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link]);
|
||||
$form_state->setValue('tid', $term->id());
|
||||
break;
|
||||
|
||||
case SAVED_UPDATED:
|
||||
drupal_set_message($this->t('The @type %term has been updated.', ['%term' => $term->getName(), '@type' => $this->forumFormType]));
|
||||
$this->messenger()->addStatus($this->t('The @type %term has been updated.', ['%term' => $term->getName(), '@type' => $this->forumFormType]));
|
||||
$this->logger('forum')->notice('Updated @type %term.', ['%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link]);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class Overview extends OverviewTerms {
|
||||
// Use the existing taxonomy overview submit handler.
|
||||
$form['terms']['#empty'] = $this->t('No containers or forums available. <a href=":container">Add container</a> or <a href=":forum">Add forum</a>.', [
|
||||
':container' => $this->url('forum.add_container'),
|
||||
':forum' => $this->url('forum.add_forum')
|
||||
':forum' => $this->url('forum.add_forum'),
|
||||
]);
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ class ForumManager implements ForumManagerInterface {
|
||||
'cid',
|
||||
'last_comment_uid',
|
||||
'last_comment_timestamp',
|
||||
'comment_count'
|
||||
'comment_count',
|
||||
]);
|
||||
|
||||
$query->join('forum_index', 'f', 'f.nid = n.nid');
|
||||
@@ -435,7 +435,7 @@ class ForumManager implements ForumManagerInterface {
|
||||
'container' => 1,
|
||||
'parents' => [],
|
||||
'isIndex' => TRUE,
|
||||
'vid' => $vid
|
||||
'vid' => $vid,
|
||||
]);
|
||||
|
||||
// Load the tree below.
|
||||
|
||||
@@ -52,7 +52,7 @@ class ForumSettingsForm extends ConfigFormBase {
|
||||
1 => $this->t('Date - newest first'),
|
||||
2 => $this->t('Date - oldest first'),
|
||||
3 => $this->t('Posts - most active first'),
|
||||
4 => $this->t('Posts - least active first')
|
||||
4 => $this->t('Posts - least active first'),
|
||||
];
|
||||
$form['forum_order'] = [
|
||||
'#type' => 'radios',
|
||||
|
||||
@@ -62,12 +62,12 @@ class ForumUninstallValidator implements ModuleUninstallValidatorInterface {
|
||||
if ($vocabulary->access('view')) {
|
||||
$reasons[] = $this->t('To uninstall Forum, first delete all <a href=":url">%vocabulary</a> terms', [
|
||||
'%vocabulary' => $vocabulary->label(),
|
||||
':url' => $vocabulary->url('overview-form'),
|
||||
':url' => $vocabulary->toUrl('overview-form')->toString(),
|
||||
]);
|
||||
}
|
||||
else {
|
||||
$reasons[] = $this->t('To uninstall Forum, first delete all %vocabulary terms', [
|
||||
'%vocabulary' => $vocabulary->label()
|
||||
'%vocabulary' => $vocabulary->label(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* Available variables:
|
||||
* - forums: The forums to display (as processed by forum-list.html.twig).
|
||||
* - topics: The topics to display.
|
||||
* - topics_original: Original topics data before modification.
|
||||
* - topics_pager: The topics pager.
|
||||
* - forums_defined: A flag to indicate that the forums are configured.
|
||||
*
|
||||
|
||||
@@ -5,5 +5,5 @@ package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- forum
|
||||
- views
|
||||
- drupal:forum
|
||||
- drupal:views
|
||||
|
||||
@@ -266,7 +266,12 @@ class ForumTest extends BrowserTestBase {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalPostForm('node/add/forum', $edit, t('Save'));
|
||||
|
||||
$nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
|
||||
$nid_count = $this->container->get('entity_type.manager')
|
||||
->getStorage('node')
|
||||
->getQuery()
|
||||
->accessCheck(FALSE)
|
||||
->count()
|
||||
->execute();
|
||||
$this->assertEqual(0, $nid_count, 'A forum node was not created when missing a forum vocabulary.');
|
||||
|
||||
// Reset the defaults for future tests.
|
||||
@@ -427,18 +432,30 @@ class ForumTest extends BrowserTestBase {
|
||||
$view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'term/']);
|
||||
$this->assert(isset($view_link), 'The message area contains a link to a term');
|
||||
|
||||
/** @var \Drupal\taxonomy\TermStorageInterface $taxonomy_term_storage */
|
||||
$taxonomy_term_storage = $this->container->get('entity_type.manager')->getStorage('taxonomy_term');
|
||||
// Verify forum.
|
||||
$term = db_query("SELECT * FROM {taxonomy_term_field_data} t WHERE t.vid = :vid AND t.name = :name AND t.description__value = :desc AND t.default_langcode = 1", [':vid' => $this->config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description])->fetchAssoc();
|
||||
$term = $taxonomy_term_storage->loadByProperties([
|
||||
'vid' => $this->config('forum.settings')->get('vocabulary'),
|
||||
'name' => $name,
|
||||
'description__value' => $description,
|
||||
]);
|
||||
$term = array_shift($term);
|
||||
$this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database');
|
||||
|
||||
// Verify forum hierarchy.
|
||||
$tid = $term['tid'];
|
||||
$parent_tid = db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = :tid", [':tid' => $tid])->fetchField();
|
||||
$tid = $term->id();
|
||||
$parent_tid = $taxonomy_term_storage->loadParents($tid);
|
||||
$parent_tid = empty($parent_tid) ? 0 : array_shift($parent_tid)->id();
|
||||
$this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container');
|
||||
|
||||
$forum = $this->container->get('entity.manager')->getStorage('taxonomy_term')->load($tid);
|
||||
$forum = $taxonomy_term_storage->load($tid);
|
||||
$this->assertEqual(($type == 'forum container'), (bool) $forum->forum_container->value);
|
||||
return $term;
|
||||
return [
|
||||
'tid' => $tid,
|
||||
'name' => $term->getName(),
|
||||
'vid' => $term->bundle(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -633,10 +650,14 @@ class ForumTest extends BrowserTestBase {
|
||||
$this->assertText(t('Forum topic @title has been updated.', ['@title' => $edit['title[0][value]']]), 'Forum node was edited');
|
||||
|
||||
// Verify topic was moved to a different forum.
|
||||
$forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", [
|
||||
':nid' => $node->id(),
|
||||
':vid' => $node->getRevisionId(),
|
||||
])->fetchField();
|
||||
$forum_tid = $this->container
|
||||
->get('database')
|
||||
->select('forum', 'f')
|
||||
->fields('f', ['tid'])
|
||||
->condition('nid', $node->id())
|
||||
->condition('vid', $node->getRevisionId())
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertTrue($forum_tid == $this->rootForum['tid'], 'The forum topic is linked to a different forum');
|
||||
|
||||
// Delete forum node.
|
||||
|
||||
@@ -34,7 +34,6 @@ class ForumIntegrationTest extends ViewTestBase {
|
||||
ViewTestData::createTestViews(get_class($this), ['forum_test_views']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the integration.
|
||||
*/
|
||||
@@ -72,17 +71,17 @@ class ForumIntegrationTest extends ViewTestBase {
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[0]->id(),
|
||||
'sticky' => NodeInterface::STICKY,
|
||||
'comment_count' => 1.
|
||||
'comment_count' => 1.,
|
||||
];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[1]->id(),
|
||||
'sticky' => NodeInterface::NOT_STICKY,
|
||||
'comment_count' => 2.
|
||||
'comment_count' => 2.,
|
||||
];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[2]->id(),
|
||||
'sticky' => NodeInterface::NOT_STICKY,
|
||||
'comment_count' => 3.
|
||||
'comment_count' => 3.,
|
||||
];
|
||||
$column_map = [
|
||||
'nid' => 'nid',
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\taxonomy\TermStorageInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
@@ -138,12 +139,12 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||
$term2 = $prophecy->reveal();
|
||||
|
||||
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
|
||||
$forum_manager->expects($this->at(0))
|
||||
->method('getParents')
|
||||
$term_storage = $this->getMockBuilder(TermStorageInterface::class)->getMock();
|
||||
$term_storage->expects($this->at(0))
|
||||
->method('loadAllParents')
|
||||
->will($this->returnValue([$term1]));
|
||||
$forum_manager->expects($this->at(1))
|
||||
->method('getParents')
|
||||
$term_storage->expects($this->at(1))
|
||||
->method('loadAllParents')
|
||||
->will($this->returnValue([$term1, $term2]));
|
||||
|
||||
// The root forum.
|
||||
@@ -167,6 +168,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
||||
->method('getStorage')
|
||||
->will($this->returnValueMap([
|
||||
['taxonomy_vocabulary', $vocab_storage],
|
||||
['taxonomy_term', $term_storage],
|
||||
]));
|
||||
|
||||
$config_factory = $this->getConfigFactoryStub(
|
||||
@@ -177,6 +179,8 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
||||
]
|
||||
);
|
||||
|
||||
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
|
||||
|
||||
// Build a breadcrumb builder to test.
|
||||
$breadcrumb_builder = $this->getMock(
|
||||
'Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder', NULL, [
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\taxonomy\TermStorageInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
@@ -149,11 +150,12 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
||||
$forum_manager = $this->getMockBuilder('Drupal\forum\ForumManagerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$forum_manager->expects($this->at(0))
|
||||
->method('getParents')
|
||||
$term_storage = $this->getMockBuilder(TermStorageInterface::class)->getMock();
|
||||
$term_storage->expects($this->at(0))
|
||||
->method('loadAllParents')
|
||||
->will($this->returnValue([$term1]));
|
||||
$forum_manager->expects($this->at(1))
|
||||
->method('getParents')
|
||||
$term_storage->expects($this->at(1))
|
||||
->method('loadAllParents')
|
||||
->will($this->returnValue([$term1, $term2]));
|
||||
|
||||
$prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface');
|
||||
@@ -176,6 +178,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
||||
->method('getStorage')
|
||||
->will($this->returnValueMap([
|
||||
['taxonomy_vocabulary', $vocab_storage],
|
||||
['taxonomy_term', $term_storage],
|
||||
]));
|
||||
|
||||
$config_factory = $this->getConfigFactoryStub(
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\forum\Unit;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\simpletest\AssertHelperTrait;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
@@ -103,13 +104,16 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
||||
->method('hasForumNodes')
|
||||
->willReturn(TRUE);
|
||||
|
||||
$url = $this->prophesize(Url::class);
|
||||
$url->toString()->willReturn('/path/to/vocabulary/overview');
|
||||
|
||||
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('label')
|
||||
->willReturn('Vocabulary label');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('url')
|
||||
->willReturn('/path/to/vocabulary/overview');
|
||||
->method('toUrl')
|
||||
->willReturn($url->reveal());
|
||||
$vocabulary->expects($this->once())
|
||||
->method('access')
|
||||
->willReturn(TRUE);
|
||||
@@ -143,7 +147,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
||||
->method('label')
|
||||
->willReturn('Vocabulary label');
|
||||
$vocabulary->expects($this->never())
|
||||
->method('url');
|
||||
->method('toUrl');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('access')
|
||||
->willReturn(FALSE);
|
||||
@@ -172,10 +176,13 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
||||
->method('hasForumNodes')
|
||||
->willReturn(FALSE);
|
||||
|
||||
$url = $this->prophesize(Url::class);
|
||||
$url->toString()->willReturn('/path/to/vocabulary/overview');
|
||||
|
||||
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('url')
|
||||
->willReturn('/path/to/vocabulary/overview');
|
||||
->method('toUrl')
|
||||
->willReturn($url->reveal());
|
||||
$vocabulary->expects($this->once())
|
||||
->method('label')
|
||||
->willReturn('Vocabulary label');
|
||||
@@ -211,7 +218,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
||||
->method('label')
|
||||
->willReturn('Vocabulary label');
|
||||
$vocabulary->expects($this->never())
|
||||
->method('url');
|
||||
->method('toUrl');
|
||||
$vocabulary->expects($this->once())
|
||||
->method('access')
|
||||
->willReturn(FALSE);
|
||||
|
||||
Reference in New Issue
Block a user