The project allows integration with Meta Conversions API (Facebook).

Project link

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

Comments

Rob230 created an issue. See original summary.

vishal.kadam’s picture

Issue summary: View changes

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.

nikral’s picture

Status: Needs review » Needs work

Running
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml meta_conversions_api


FILE: contrib/meta_conversions_api/config/schema/meta_conversions_api.schema.yml
-------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------
 19 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: contrib/meta_conversions_api/meta_conversions_api.api.php
--------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
--------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------


FILE: contrib/meta_conversions_api/meta_conversions_api.module
-------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] Missing file doc comment
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------


FILE: contrib/meta_conversions_api/meta_conversions_api.links.task.yml
---------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
 9 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------

FILE: contrib/meta_conversions_api/src/Logger/FacebookLogger.php
---------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------------
 37 | ERROR | [x] Short array syntax must be used to define arrays
 44 | ERROR | [x] Short array syntax must be used to define arrays
 55 | ERROR | [x] Short array syntax must be used to define arrays
---------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------


FILE: contrib/meta_conversions_api/src/MetaApiTwig.php
-----------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------
 29 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 82 | ERROR   | [x] Expected 1 newline at end of file; 0 found
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------

vishal.kadam’s picture

Title: [1.0.x] Meta Conversions API » [1.x] Meta Conversions API
avpaderno’s picture

Priority: Normal » Minor

I am changing priority as per Issue priorities.

vishal.kadam’s picture

Status: Needs work » Closed (won't fix)

This thread has been idle, in the Needs work state with no activity for several months. Therefore, I am assuming that you are no longer pursuing this application, and I marked it as Closed (won't fix).

If this is incorrect, and you are still pursuing this application, then please feel free to re-open it and set the issue status to Needs work or Needs review, depending on the current status of your code.

rob230’s picture

Status: Closed (won't fix) » Needs review

Hi,

I am pretty sure those minor phpcs issues have been resolved now. Please could somebody have a look? I would love if we can get security coverage for this module.

Thanks

vishal.kadam’s picture

Status: Needs review » Needs work

1. FILE: meta_conversions_api.info.yml

core_version_requirement: ^9 | ^10 || ^11

Now that Drupal 8 and Drupal 9 are no longer supported, new projects should no longer be compatible with those Drupal versions.

2. FILE: meta_conversions_api.module

/**
 * @file
 * Provides integration with Meta Conversions API.
 */

The usual description for a .module file is “Hook implementations for the [module name] module”, where [module name] is the module name given in the .info.yml file.

3. FILE: src/Controller/PageViewController.php

Since that class does not use any method from the parent class, it does not need to use ControllerBase as the parent class. Controllers do not need to have a parent class; as long as they implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface, they are fine.

4. FILE: src/Controller/PageViewController.php

  /**
   * Constructor for the controller.
   *
   * @param \Drupal\meta_conversions_api\Services\MetaClient $client
   *   Meta client.
   */
  public function __construct(MetaClient $client) {

FILE: src/Logger/FacebookLogger.php

  /**
   * Constructor.
   *
   * @param \Psr\Log\LoggerInterface $logger
   *   The Drupal logger.
   */
  public function __construct(LoggerInterface $logger) {

FILE: src/Services/MetaClient.php

  /**
   * MetaClient constructor.
   *
   * @param \Drupal\Core\Config\ConfigFactory $config_factory
   *   An instance of Config Factory.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   Drupal module handler.
   * @param \Drupal\Core\Cache\CacheBackendInterface $cache
   *   Cache backend.
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   Request stack.
   * @param \Psr\Log\LoggerInterface $logger
   *   An instance of Logger Channel Factory.
   * @param \Drupal\meta_conversions_api\Logger\FacebookLogger $facebook_logger
   *   Facebook logger.
   */
  public function __construct(

The documentation comment for constructors is not mandatory anymore, If it is given, the description must be “Constructs a new [class name] object”, where [class name] includes the class namespace.

rob230’s picture

Title: [1.x] Meta Conversions API » [1.1.x] Meta Conversions API

I have resolved those issues on the 1.1.x branch if you can take a look.

rob230’s picture

Status: Needs work » Needs review
vishal.kadam’s picture

It would be better not to create new branches: Reviewers could need to check again all the files, to understand which changes has been done in the new branch.

rob230’s picture

It's just branched off 1.x, the only changes are what you asked for. You can see the commits. I did a new dev branch since D9 support was dropped and some people may have been using the dev branch.

These changes to comments are also things which are found in every Drupal module already which has security coverage, including big modules like webform, so I don't really understand why this blocks the module getting security coverage.

avpaderno’s picture

Status: Needs review » Needs work
  • The following points are just a start and don't necessarily encompass all of the changes that may be necessary
  • A specific point may just be an example and may apply in other places
  • A review is about code that does not follow the coding standards, contains possible security issue, or does not correctly use the Drupal API
  • The single review points are not ordered, not even by importance

src/Form/EventsForm.php

With Drupal 10 and Drupal 11, there is no longer need to use #default_value for each form element, when the parent class is ConfigFormBase: It is sufficient to use #config_target, as in the following code.

    $form['image_toolkit'] = [
      '#type' => 'radios',
      '#title' => $this->t('Select an image processing toolkit'),
      '#config_target' => 'system.image:toolkit',
      '#options' => [],
    ];

Using that code, it is no longer needed to save the configuration values in the form submission handler: The parent class will take care of that.

  protected $metaClient;

  public function __construct(
    ConfigFactoryInterface $config_factory,
    TypedConfigManagerInterface $typed_config_manager,
    MetaClient $meta_client,
  ) {
    parent::__construct($config_factory, $typed_config_manager);

    $this->metaClient = $meta_client;
  }

The parameters for ConfigFormBase::__construct() changed in Drupal 10.2; the project cannot be compatible with all the Drupal 10 releases and Drupal 11; it needs to require at least Drupal 10.2.

With the PHP version required by Drupal 10, it is possible to use property promotion.

src/Services/MetaClient.php

    if (empty($eventData['event_name'])) {
      $this->logger->error('Missing event_name in Meta request, called from ' . debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']);
      return;
    }

The $message parameter passed to the LoggerInterface methods must be a literal string that uses placeholders. It's not a translatable string, a string concatenation, a value returned from a function/method, nor a variable containing an exception object.

meta_conversions_api.module

For a new module that aims to be compatible with Drupal 10/11, it is expected it implements hooks as class methods as described in Support for object oriented hook implementations using autowired services.
It requires increasing the minimum required Drupal 10 version, but that is not an issue, since not all the Drupal 10 releases are currently supported.

rob230’s picture

Thanks for that. I have changed to use config_target, and required minimum Drupal 10.2 in the 1.1.x branch.

I have also begun work on supporting object oriented hooks in a service. That's in this ticket, with a merge request: #3556713: Support D11 object oriented hook implementations using autowired services.

I couldn't find any other contrib modules that were doing this out of hundreds of big ones, so was flying a bit blind. I tested it in Drupal 10.5 and it does appear to work, although PHPStan complains about Drupal\Core\Hook\Attribute\Hook not existing, which is true - but I don't think it matters because it's just being called as a normal service. I believe the attribute is ignored until D11.

I'm gonna test in Drupal 10.2 as well just to be sure.

avpaderno’s picture

Remember to change status, when you applied the suggested changes. Otherwise, it is not clear whether you made all the suggested changes.

rob230’s picture

Status: Needs work » Needs review

Thanks, I was testing it, but then forgot to update. It does work fine, so I've merged that.

rushikesh raval’s picture

Priority: Minor » Critical

I am changing priority as per Issue priorities.

avpaderno’s picture

Assigned: Unassigned » avpaderno
Priority: Critical » Normal
Status: Needs review » Reviewed & tested by the community

src/Hook/MetaConversionsApiHooks.php

Code compatible with latest Drupal releases should use property promotion.

avpaderno’s picture

Thank you for your contribution and for your patience with the review process!

I am going to update your account so you can opt into security advisory coverage any project you create, including the projects you already created.

These are some recommended readings to help you with maintainership:

You can find more contributors chatting on Slack or IRC in #drupal-contribute. So, come hang out and stay involved!
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank also all the reviewers for helping with these applications.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.