updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
@@ -95,7 +95,7 @@ class StatisticsPopularBlock extends BlockBase implements ContainerFactoryPlugin
return [
'top_day_num' => 0,
'top_all_num' => 0,
'top_last_num' => 0
'top_last_num' => 0,
];
}
@@ -81,15 +81,24 @@ class NodeCounter extends DestinationBase implements ContainerFactoryPluginInter
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = []) {
$nid = $row->getDestinationProperty('nid');
$daycount = $row->getDestinationProperty('daycount');
$totalcount = $row->getDestinationProperty('totalcount');
$timestamp = $row->getDestinationProperty('timestamp');
$this->connection
->insert('node_counter')
->merge('node_counter')
->key('nid', $nid)
->fields([
'nid' => $row->getDestinationProperty('nid'),
'daycount' => $row->getDestinationProperty('daycount'),
'totalcount' => $row->getDestinationProperty('totalcount'),
'timestamp' => $row->getDestinationProperty('timestamp'),
'daycount' => $daycount,
'totalcount' => $totalcount,
'timestamp' => $timestamp,
])
->expression('daycount', 'daycount + :daycount', [':daycount' => $daycount])
->expression('totalcount', 'totalcount + :totalcount', [':totalcount' => $totalcount])
->expression('timestamp', 'CASE WHEN timestamp > :timestamp THEN timestamp ELSE :timestamp END', [':timestamp' => $timestamp])
->execute();
return [$row->getDestinationProperty('nid')];
}
@@ -23,9 +23,9 @@ class StatisticsViewsResult {
protected $timestamp;
public function __construct($total_count, $day_count, $timestamp) {
$this->totalCount = $total_count;
$this->dayCount = $day_count;
$this->timestamp = $timestamp;
$this->totalCount = (int) $total_count;
$this->dayCount = (int) $day_count;
$this->timestamp = (int) $timestamp;
}
/**
@@ -37,7 +37,6 @@ class StatisticsViewsResult {
return $this->totalCount;
}
/**
* Total number of times the entity has been viewed "today".
*
@@ -47,7 +46,6 @@ class StatisticsViewsResult {
return $this->dayCount;
}
/**
* Timestamp of when the entity was last viewed.
*
+2 -2
View File
@@ -3,7 +3,7 @@
* Statistics functionality.
*/
(function ($, Drupal, drupalSettings) {
(function($, Drupal, drupalSettings) {
$(document).ready(() => {
$.ajax({
type: 'POST',
@@ -12,4 +12,4 @@
data: drupalSettings.statistics.data,
});
});
}(jQuery, Drupal, drupalSettings));
})(jQuery, Drupal, drupalSettings);
+1 -1
View File
@@ -6,4 +6,4 @@ version: VERSION
core: 8.x
configure: statistics.settings
dependencies:
- node
- drupal:node
+1 -1
View File
@@ -41,7 +41,7 @@ function statistics_help($route_name, RouteMatchInterface $route_match) {
function statistics_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
if (!$node->isNew() && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
$build['#attached']['library'][] = 'statistics/drupal.statistics';
$settings = ['data' => ['nid' => $node->id()], 'url' => Url::fromUri('base:' . drupal_get_path('module', 'statistics') . '/statistics.php')->toString()];
$settings = ['data' => ['nid' => $node->id()], 'url' => \Drupal::request()->getBasePath() . '/' . drupal_get_path('module', 'statistics') . '/statistics.php'];
$build['#attached']['drupalSettings']['statistics'] = $settings;
}
}
+1 -1
View File
@@ -9,7 +9,7 @@
* Implements hook_views_data().
*/
function statistics_views_data() {
$data['node_counter']['table']['group'] = t('Content statistics');
$data['node_counter']['table']['group'] = t('Content statistics');
$data['node_counter']['table']['join'] = [
'node_field_data' => [
@@ -5,5 +5,5 @@ package: Testing
version: VERSION
core: 8.x
dependencies:
- statistics
- views
- drupal:statistics
- drupal:views
@@ -38,7 +38,7 @@ class StatisticsAdminTest extends BrowserTestBase {
/**
* The Guzzle HTTP client.
*
* @var \GuzzleHttp\Client;
* @var \GuzzleHttp\Client
*/
protected $client;
@@ -46,7 +46,7 @@ class StatisticsAttachedTest extends BrowserTestBase {
$node = Node::create([
'type' => 'page',
'title' => 'Page node',
'body' => 'body text'
'body' => 'body text',
]);
$node->save();
$this->drupalGet('node/' . $node->id());
@@ -39,7 +39,7 @@ class StatisticsLoggingTest extends BrowserTestBase {
/**
* The Guzzle HTTP client.
*
* @var \GuzzleHttp\Client;
* @var \GuzzleHttp\Client
*/
protected $client;
@@ -125,7 +125,7 @@ class StatisticsLoggingTest extends BrowserTestBase {
$post = ['nid' => $this->node->id()];
$this->client->post($base_root . $stats_path, ['form_params' => $post]);
$node_counter = statistics_get($this->node->id());
$this->assertIdentical($node_counter['totalcount'], '1');
$this->assertIdentical($node_counter['totalcount'], 1);
// Try fetching statistics for an invalid node ID and verify it returns
// FALSE.
@@ -9,6 +9,7 @@ namespace Drupal\Tests\statistics\Functional;
* @group statistics
*/
class StatisticsTokenReplaceTest extends StatisticsTestBase {
/**
* Creates a node, then tests the statistics tokens generated from it.
*/
@@ -0,0 +1,87 @@
<?php
namespace Drupal\Tests\statistics\FunctionalJavascript;
use Drupal\Core\Session\AccountInterface;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\user\Entity\Role;
/**
* Tests that statistics works.
*
* @group system
*/
class StatisticsLoggingTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'statistics', 'language'];
/**
* Node for tests.
*
* @var \Drupal\node\Entity\Node
*/
protected $node;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->config('statistics.settings')
->set('count_content_views', 1)
->save();
Role::load(AccountInterface::ANONYMOUS_ROLE)
->grantPermission('view post access counter')
->save();
// Add another language to enable multilingual path processor.
ConfigurableLanguage::create(['id' => 'xx'])->save();
$this->config('language.negotiation')->set('url.prefixes.en', 'en')->save();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->node = $this->drupalCreateNode();
}
/**
* Tests that statistics works with different addressing variants.
*/
public function testLoggingPage() {
// At the first request, the page does not contain statistics counter.
$this->assertNull($this->getStatisticsCounter('node/1'));
$this->assertSame(1, $this->getStatisticsCounter('node/1'));
$this->assertSame(2, $this->getStatisticsCounter('en/node/1'));
$this->assertSame(3, $this->getStatisticsCounter('en/node/1'));
$this->assertSame(4, $this->getStatisticsCounter('index.php/node/1'));
$this->assertSame(5, $this->getStatisticsCounter('index.php/node/1'));
$this->assertSame(6, $this->getStatisticsCounter('index.php/en/node/1'));
$this->assertSame(7, $this->getStatisticsCounter('index.php/en/node/1'));
}
/**
* Gets counter of views by path.
*
* @param string $path
* A path to node.
*
* @return int|null
* A counter of views. Returns NULL if the page does not contain statistics.
*/
protected function getStatisticsCounter($path) {
$this->drupalGet($path);
// Wait while statistics module send ajax request.
$this->assertSession()->assertWaitOnAjaxRequest();
// Resaving the node to call the hook_node_links_alter(), which is used to
// update information on the page. See statistics_node_links_alter().
$this->node->save();
$field_counter = $this->getSession()->getPage()->find('css', '.statistics-counter');
return $field_counter ? (int) explode(' ', $field_counter->getText())[0] : NULL;
}
}
@@ -15,7 +15,11 @@ class MigrateNodeCounterTest extends MigrateDrupal6TestBase {
* {@inheritdoc}
*/
public static $modules = [
'content_translation',
'language',
'menu_ui',
// Required for translation migrations.
'migrate_drupal_multilingual',
'node',
'statistics',
'text',
@@ -29,16 +33,20 @@ class MigrateNodeCounterTest extends MigrateDrupal6TestBase {
$this->installEntitySchema('node');
$this->installConfig('node');
$this->installSchema('node', ['node_access']);
$this->installSchema('statistics', ['node_counter']);
$this->executeMigrations([
'language',
'd6_filter_format',
'd6_user_role',
'd6_node_settings',
'd6_user',
'd6_node_type',
'd6_language_content_settings',
'd6_node',
'statistics_node_counter'
'd6_node_translation',
'statistics_node_counter',
]);
}
@@ -51,6 +59,13 @@ class MigrateNodeCounterTest extends MigrateDrupal6TestBase {
$this->assertNodeCounter(3, 1, 0, 1471428153);
$this->assertNodeCounter(4, 1, 1, 1478755275);
$this->assertNodeCounter(5, 1, 1, 1478755314);
$this->assertNodeCounter(10, 5, 1, 1521137459);
$this->assertNodeCounter(12, 3, 0, 1521137469);
// Tests that translated node counts include all translation counts.
$this->executeMigration('statistics_node_translation_counter');
$this->assertNodeCounter(10, 8, 2, 1521137463);
$this->assertNodeCounter(12, 5, 1, 1521137470);
}
/**
@@ -15,7 +15,11 @@ class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
* {@inheritdoc}
*/
public static $modules = [
'content_translation',
'language',
'menu_ui',
// Required for translation migrations.
'migrate_drupal_multilingual',
'node',
'statistics',
'text',
@@ -29,14 +33,18 @@ class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
$this->installEntitySchema('node');
$this->installConfig('node');
$this->installSchema('node', ['node_access']);
$this->installSchema('statistics', ['node_counter']);
$this->executeMigrations([
'language',
'd7_user_role',
'd7_user',
'd7_node_type',
'd7_language_content_settings',
'd7_node',
'statistics_node_counter'
'd7_node_translation',
'statistics_node_counter',
]);
}
@@ -47,6 +55,11 @@ class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
$this->assertNodeCounter(1, 2, 0, 1421727536);
$this->assertNodeCounter(2, 1, 0, 1471428059);
$this->assertNodeCounter(4, 1, 1, 1478755275);
// Tests that translated node counts include all translation counts.
$this->executeMigration('statistics_node_translation_counter');
$this->assertNodeCounter(2, 2, 0, 1471428153);
$this->assertNodeCounter(4, 2, 2, 1478755314);
}
/**
@@ -0,0 +1,37 @@
<?php
namespace Drupal\Tests\statistics\Unit;
use Drupal\statistics\StatisticsViewsResult;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\statistics\StatisticsViewsResult
* @group statistics
*/
class StatisticsViewsResultTest extends UnitTestCase {
/**
* Tests migration of node counter.
*
* @covers ::__construct
*
* @dataProvider providerTestStatisticsCount
*/
public function testStatisticsCount($total_count, $day_count, $timestamp) {
$statistics = new StatisticsViewsResult($total_count, $day_count, $timestamp);
$this->assertSame((int) $total_count, $statistics->getTotalCount());
$this->assertSame((int) $day_count, $statistics->getDayCount());
$this->assertSame((int) $timestamp, $statistics->getTimestamp());
}
public function providerTestStatisticsCount() {
return [
[2, 0, 1421727536],
[1, 0, 1471428059],
[1, 1, 1478755275],
['1', '1', '1478755275'],
];
}
}