Skip to content
Snippets Groups Projects
Verified Commit 02c07301 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3422981 by catch, gorkagr, Wim Leers: Return early in...

Issue #3422981 by catch, gorkagr, Wim Leers: Return early in CacheTagsChecksumTrait::isValid() (and possibly elsewhere) if there are no tags to check
parent 213906e2
No related branches found
No related tags found
32 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!6791Issue #3163299: Ajax exposed filters not working for multiple instances of the same Views block placed on one page,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #102227 canceled
Pipeline: drupal

#102228

    ......@@ -110,6 +110,11 @@ public function getCurrentChecksum(array $tags) {
    * Implements \Drupal\Core\Cache\CacheTagsChecksumInterface::isValid()
    */
    public function isValid($checksum, array $tags) {
    // If there are no cache tags, then there is no cache tag to validate,
    // hence it's always valid.
    if (empty($tags)) {
    return TRUE;
    }
    // Any cache reads in this request involving cache tags whose invalidation
    // has been delayed due to an in-progress transaction are not allowed to use
    // data stored in cache; it must be assumed to be stale. This forces those
    ......
    ......@@ -30,6 +30,11 @@ public function getCurrentChecksum(array $tags) {
    * {@inheritdoc}
    */
    public function isValid($checksum, array $tags) {
    // If there are no cache tags, the cache item is always valid, and the child
    // method will be a no-op, so don't log anything.
    if (empty($tags)) {
    return $this->checksumInvalidator->isValid($checksum, $tags);
    }
    $start = microtime(TRUE);
    $return = $this->checksumInvalidator->isValid($checksum, $tags);
    $stop = microtime(TRUE);
    ......
    ......@@ -40,7 +40,7 @@ public function testFrontPageAuthenticatedWarmCache(): void {
    $this->assertSame(0, $performance_data->getCacheSetCount());
    $this->assertSame(0, $performance_data->getCacheDeleteCount());
    $this->assertSame(0, $performance_data->getCacheTagChecksumCount());
    $this->assertSame(54, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(13, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
    }
    ......
    ......@@ -60,7 +60,7 @@ public function testAnonymous() {
    $this->assertSame(47, $performance_data->getCacheSetCount());
    $this->assertSame(0, $performance_data->getCacheDeleteCount());
    $this->assertCountBetween(143, 146, $performance_data->getCacheTagChecksumCount());
    $this->assertCountBetween(177, 180, $performance_data->getCacheTagIsValidCount());
    $this->assertCountBetween(47, 50, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
    // Test node page.
    ......@@ -74,7 +74,7 @@ public function testAnonymous() {
    $this->assertSame(16, $performance_data->getCacheSetCount());
    $this->assertSame(0, $performance_data->getCacheDeleteCount());
    $this->assertCountBetween(79, 80, $performance_data->getCacheTagChecksumCount());
    $this->assertCountBetween(149, 150, $performance_data->getCacheTagIsValidCount());
    $this->assertCountBetween(41, 42, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
    // Test user profile page.
    ......@@ -87,7 +87,7 @@ public function testAnonymous() {
    $this->assertSame(81, $performance_data->getCacheGetCount());
    $this->assertSame(16, $performance_data->getCacheSetCount());
    $this->assertSame(0, $performance_data->getCacheDeleteCount());
    $this->assertCountBetween(129, 130, $performance_data->getCacheTagIsValidCount());
    $this->assertCountBetween(36, 37, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
    }
    ......@@ -118,7 +118,7 @@ public function testLogin(): void {
    $this->assertSame(1, $performance_data->getCacheSetCount());
    $this->assertSame(1, $performance_data->getCacheDeleteCount());
    $this->assertSame(1, $performance_data->getCacheTagChecksumCount());
    $this->assertSame(69, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(28, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
    }
    ......@@ -151,7 +151,7 @@ public function testLoginBlock(): void {
    $this->assertSame(1, $performance_data->getCacheSetCount());
    $this->assertSame(1, $performance_data->getCacheDeleteCount());
    $this->assertSame(1, $performance_data->getCacheTagChecksumCount());
    $this->assertSame(107, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(31, $performance_data->getCacheTagIsValidCount());
    $this->assertSame(0, $performance_data->getCacheTagInvalidationCount());
    }
    ......
    ......@@ -4,6 +4,7 @@
    namespace Drupal\Tests;
    use Drupal\Core\Database\Event\DatabaseEvent;
    use Drupal\performance_test\Cache\CacheTagOperation;
    use OpenTelemetry\API\Trace\SpanKind;
    use OpenTelemetry\Contrib\Otlp\OtlpHttpTransportFactory;
    ......@@ -130,11 +131,7 @@ public function collectPerformanceData(callable $callable, ?string $service_name
    foreach ($performance_test_data['database_events'] as $event) {
    // Don't log queries from the database cache backend because they're
    // logged separately as cache operations.
    $database_cache = FALSE;
    if (isset($event->caller['class'])) {
    $database_cache = is_a(str_replace('\\\\', '\\', $event->caller['class']), '\Drupal\Core\Cache\DatabaseBackend', TRUE) || is_a(str_replace('\\\\', '\\', $event->caller['class']), 'Drupal\Core\Cache\DatabaseCacheTagsChecksum', TRUE);
    }
    if (!$database_cache) {
    if (!static::isDatabaseCache($event)) {
    $query_count++;
    }
    }
    ......@@ -361,7 +358,7 @@ private function openTelemetryTracing(array $messages, string $service_name): vo
    $performance_test_data = $collection->get('performance_test_data');
    $query_events = $performance_test_data['database_events'] ?? [];
    foreach ($query_events as $key => $event) {
    if (isset($event->caller['class']) && is_a(str_replace('\\\\', '\\', $event->caller['class']), '\Drupal\Core\Cache\DatabaseBackend', TRUE)) {
    if (static::isDatabaseCache($event)) {
    continue;
    }
    // Use the first part of the database query for the span name.
    ......@@ -460,4 +457,18 @@ protected function assertCountBetween(int $min, int $max, int $actual) {
    );
    }
    /**
    * Checks whether a database event is from the database cache implementation.
    *
    * @param Drupal\Core\Database\Event\DatabaseEvent $event
    * The database event.
    *
    * @return bool
    * Whether the event was triggered by the database cache implementation.
    */
    protected static function isDatabaseCache(DatabaseEvent $event): bool {
    $class = str_replace('\\\\', '\\', $event->caller['class']);
    return is_a($class, '\Drupal\Core\Cache\DatabaseBackend', TRUE) || is_a($class, '\Drupal\Core\Cache\DatabaseCacheTagsChecksum', TRUE);
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment