[1.1.x] Cache review

Created on 13 March 2024, 3 months ago
Updated 1 June 2024, 15 days ago

Cache Review provides tools to help review and analyze how the internal (IPC) and dynamic page cache (DPC) work.
The main goal of Cache Review project is to help developers to learn how cache works for
anonymous and authenticated users.
The developer has an ability to see information about whole page cache status and about caching each item on the page.
The flexible settings help to switch between information details level on the fly.

Project link

https://www.drupal.org/project/cache_review

📌 Task
Status

Needs work

Component

module

Created by

🇺🇦Ukraine osab Ukraine, Kharkiv

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @osab
  • 🇮🇳India vishal.kadam Mumbai

    Thank you for applying!

    Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.

    The important notes are the following.

    • If you have not done it yet, you should run phpcs --standard=Drupal,DrupalPractice on the project, which alone fixes most of what reviewers would report.
    • For the time this application is open, only your commits are allowed.
    • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
    • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

    To the reviewers

    Please read How to review security advisory coverage applications , Application workflow , What to cover in an application review , and Tools to use for reviews .

    The important notes are the following.

    • It is preferable to wait for a Code Review Administrator before commenting on newly created applications. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
    • Reviewers should show the output of a CLI tool only once per application.
    • It may be best to have the applicant fix things before further review.

    For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues .

  • Status changed to Needs work 3 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    I didn't have time to check all the project files, but there is a change that is necessary.

    Projects hosted on drupal.org are licensed under the same license used from Drupal core: GPLv2+. Any other license, including GPLv3, are not allowed.

  • 🇮🇳India vishal.kadam Mumbai

    Fix phpcs issues.

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml cache_review/
    
    FILE: cache_review/src/Render/RenderCacheReview.php                              
    ---------------------------------------------------------------------------------------------                    
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES                                                                  
    ---------------------------------------------------------------------------------------------                    
     75 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead                     
     78 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead                     
    ---------------------------------------------------------------------------------------------                    
    
    
    FILE: cache_review/src/Controller/CacheReviewController.php                      
    -----------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE                                                                                   
    -----------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Cache\Cache. 
    -----------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY                                                       
    -----------------------------------------------------------------------------------------------------------------
    
    
    FILE: cache_review/css/cache_review.css
    -------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------
     27 | ERROR | [x] Expected 1 space before opening brace of class definition; 0 found
    -------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------
    
    
    FILE: cache_review/README.txt
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
    ----------------------------------------------------------------------
     18 | WARNING | Line exceeds 80 characters; contains 88 characters
     54 | WARNING | Line exceeds 80 characters; contains 83 characters
     57 | WARNING | Line exceeds 80 characters; contains 83 characters
    ----------------------------------------------------------------------
    
  • 🇺🇦Ukraine osab Ukraine, Kharkiv

    Thank you @apaderno and @vishal.kadam for help!
    I've removed Lisence file and add phpcs fixes (looks like I have some options and resctrictions in phpcs CLI command before )) ).

    As for cache_review/src/Render/RenderCacheReview.php I need your advices how it can be made better.
    The point is I wanted to make my module work on Drupal 10 and Drupal 11. That's why I can't set 'cache_factory' (for Drupal 10) or 'variation_cache_factory' (Drupal 11) as arguments in servise file directly.
    So, I've found the same approach in core/lib/Drupal/Core/Render/PlaceholderingRenderCache.php:

      public function __construct(RequestStack $request_stack, $cache_factory, CacheContextsManager $cache_contexts_manager, PlaceholderGeneratorInterface $placeholder_generator) {
        if ($cache_factory instanceof CacheFactoryInterface) {
          @trigger_error('Injecting ' . __CLASS__ . ' with the "cache_factory" service is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use "variation_cache_factory" instead. See https://www.drupal.org/node/3365546', E_USER_DEPRECATED);
          $cache_factory = \Drupal::service('variation_cache_factory');
        }
        parent::__construct($request_stack, $cache_factory, $cache_contexts_manager);
        $this->placeholderGenerator = $placeholder_generator;
      }
    

    Maybe it will be Ok to implements ContainerFactoryPluginInterface and add this condition in create() method, but I'm not sure that is correct approach.
    Thanks in advance!

  • Status changed to Needs review 3 months ago
  • 🇺🇦Ukraine osab Ukraine, Kharkiv
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    You cannot have code that works with Drupal 10.0 and Drupal 11, when Drupal 11 implements a different service Drupal 10.0 does not have.

    The following code will not work on Drupal 10.0, since it would request a service that does not exist in Drupal 10.

        if ($cache_factory instanceof CacheFactoryInterface) {
          @trigger_error('Injecting ' . __CLASS__ . ' with the "cache_factory" service is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use "variation_cache_factory" instead. See https://www.drupal.org/node/3365546', E_USER_DEPRECATED);
          $cache_factory = \Drupal::service('variation_cache_factory');
        }
    

    If the module requires Drupal 10.1 or higher version, it would work, since the variation_cache_factory service would be defined.

  • 🇺🇦Ukraine osab Ukraine, Kharkiv

    Thank you, @apaderno! So, if I understood correctly, the better way is to remove version_compare in code, like
    version_compare(\Drupal::VERSION, '10.2', '<'), add 'variation_cache_factory' service only and restrict module to core version 10.1 and higher?

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    That's correct.

    The alternative would make a branch for Drupal 10.0, and one for Drupal 10.1 and Drupal 11. I would follow this path only in the case you are writing the module for a site you know cannot use Drupal 10.1 or Drupal 11, though.

  • Status changed to Active 3 months ago
  • 🇺🇦Ukraine osab Ukraine, Kharkiv
  • 🇺🇦Ukraine osab Ukraine, Kharkiv

    updated.
    - Set >10.1 version and variation_cache_factory only.
    Please, review whenever you will have time. Thanks a lot!

  • Status changed to Needs review 3 months ago
  • 🇺🇦Ukraine osab Ukraine, Kharkiv
  • 🇺🇦Ukraine osab Ukraine, Kharkiv

    hi @apaderno! Could you help once more and review the module after my changes? Thank you in advance!

  • Status changed to Needs work about 1 month ago
  • Status changed to Needs review about 1 month ago
  • 🇺🇦Ukraine osab Ukraine, Kharkiv
  • 🇫🇷France andypost

    Thank you, makes sense to add some test and setup CI

  • Status changed to Needs work about 1 month ago
  • 🇺🇦Ukraine osab Ukraine, Kharkiv
  • 🇺🇦Ukraine osab Ukraine, Kharkiv

    fixing https://www.drupal.org/project/cache_review/issues/3446118 📌 Add basic test and setup CI Needs work is in progress...

Production build 0.69.0 2024