Closed (fixed)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
9 Aug 2023 at 09:46 UTC
Updated:
10 Feb 2026 at 09:24 UTC
Jump to comment: Most recent
Comments
Comment #2
vishal.kadamThank you for applying! Reviewers will review the project files, describing what needs to be changed.
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.
To reviewers: Please read How to review security advisory coverage applications, What to cover in an application review, and Drupal.org security advisory coverage application workflow.
While this application is open, only the user who opened the application can make commits to the project used for the application.
Reviewers only describe what needs to be changed; they don't provide patches to fix what reported in a review.
Comment #3
vishal.kadamComment #4
vishal.kadam1. Fix phpcs issue.
2. FILE: cron_fail_alert.routing.yml
_permission: 'administer cron_fail_alert configuration''administer cron_fail_alert configuration' permission is not defined in the module.
Comment #5
hemangi.gokhaleOops! I didn't notice that 🤦♀️. Thanks for letting me know. I've fixed it and made some more improvements. This is now ready for another review now.
Comment #6
vishal.kadamRest looks fine to me.
Let’s wait for other reviewers to take a look and if everything goes fine, you will get the role.
Comment #7
hemangi.gokhaleComment #8
avpadernoComment #9
elc commentedOnly calls to t(), $this->t() and
new TranslatableMarkup()are picked up by the d.o strings translation matching.$subject = $this->cronFailAlertSettings->get('subject') . ' on Site: ' . $this->systemSite->get('name');Non-blocking comments
The same outcome happens if the site fails to send the email - when this happens, the full check and attempt to send the email will happen on every page request.
I would imagine both of these has the potential to slow down a site significantly.
Comment #10
hemangi.gokhale@ELC, thanks a lot for your feedback. I've made the changes you suggested, and you can see them in this commit: link to commit.
Here are the updates I've made:
Changes to 'cron_fail_alert_mail' Function
I've used the 't()' function to translate the subject in the 'cron_fail_alert_mail' function, which helps with language translation.
Fix for 'CronFailAlertSubscriber::cronStatusCheck()'
Instead of using string translation, I'm now using FormattableMarkup because my string is combined with other parts. You can find more details here: link to FormattableMarkup.
Additionally, I've done the following improvements:
cronStatusCheck()method tocheckCronStatus()for better understanding.cronFailAlertSendEmail()tosendCronFailAlertEmail()to make it consistent and clear.Regarding the following points:
cron_fail_alert.last_check_timestampwill get updated.Feel free to let me know if you have any further questions or suggestions.
Comment #11
elc commentedUse of t() is implicitly deprecated, but not labelled as such. D10 t() docs states . Use of t() is still supported, but is no longer recommended since D8. Not a blocking issue now.
The issue with setting the timestamp only when TRUE is returned from checkCronStatus() still exists, however this is more debugging than reviewing and I shouldn't really be doing it. This is it. It appears there is actually a new bug in this too.
The value of
cron_fail_alert.last_check_timestampshould be set regardless of the return value as the full expensive check has been done and does not wish to run the check again for at least $frequency. By not setting it, every page request will check to see if cron has failed until the time that cron does in fact fail AND the mail succeeds - neither of these outcomes is guaranteed. Only then will timestamp be updated and it will have a break for 15 minutes (by default).eg. Input initial values into the code
Try it with cron_fail_alert.last_check_timestamp is set to 1692195900, it will do exactly the same thing.
It may be detrimental to a site, this is not a blocking issue.
For the subject on the email, I'd argue that it should be using TranslatableMarkup instead of FormattableMarkup - the comment you linked here, plus the 2 lines before it, state that because there is translation needed in the string being built, it should use TranslatableMarkup. The string is not just being concatenated, it contains english text in need of translation.
As it stands the text "on Site" would not be translated.
The only item pushing this to "Needs Work" is that string not being translated. Otherwise, despite the other notes, you're RTBC.
Comment #12
avpadernoI am removing the PAreview: review bonus tag, as per Review bonus, since a review has been already done.
Comment #13
vinaymahale commentedComment #14
avpadernoComment #15
avpadernoI am changing priority as per Issue priorities.
Comment #16
rushikesh raval commentedThis 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.
Comment #17
hemangi.gokhaleThanks everyone, especially @elc, for the concrete feedback. I'm planning to resume this. @avpaderno, should I change the priority back to Normal, and do I need to request the "PAreview: review bonus" tag again?
Comment #18
hemangi.gokhaleI've updated the module so the timestamp is always set after the cron check, preventing repeated expensive checks. I've also replaced t() with TranslatableMarkup for email subjects to ensure all strings are properly translatable. With these changes, the module should now be fully compliant, and I'm marking it as ready for review. Thanks.
Comment #19
bbu23The priority cannot be changed back to Normal yet. See Issue priorities.
Comment #20
bbu23Hello @hemangi.gokhale,
Here's a quick feedback:
- Update PHP Annotations to PHP Attributes where applicable (including tests)
- The module is missing the composer.json file. See Add a composer.json file for more info.
- The schema defines the field "to", but it's missing in the default module configuration object
- New modules, which are compatible with Drupal 10 and higher versions are expected to include type declarations in property definitions, and use property promotion
Example:
- For a new module that aims to be compatible with Drupal 10 and Drupal 11, I would rather implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.
Comment #21
vishal.kadam1. FILE: cron_fail_alert.module
For a new module that aims to be compatible with Drupal 10 and Drupal 11, I would rather implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.
It would require increasing the minimum Drupal 10 version supported, but Drupal 10.1 is no longer supported.
Drupal does not have primary and secondary hooks. Instead of that, it is preferable to use the usual description: “Hook implementations for the [module name] module”, where [module name] is the name of the module given in its .info.yml file.
2. FILE: src/EventSubscriber/CronFailAlertSubscriber.php
New modules, which are compatible with Drupal 10 and higher versions are expected to include type declarations in property definitions, and use constructor property promotion.
The
$messageparameter passed to theLoggerInterfacemethods must be a literal string that uses placeholders. It's not a translatable string returned fromt()/$this->t(), a string concatenation, a value returned from a function/method, nor a variable containing an exception object.3. FILE: src/Form/SettingsForm.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.
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.
For this change, it is necessary to require at least Drupal 10.3, but that is not an issue, since Drupal 10.2.x is no longer supported.
New modules, which are compatible with Drupal 10 and higher versions are expected to include type declarations in property definitions, and use constructor property promotion.
Given the changes in ConfigFormBase, the module cannot be compatible with Drupal releases before 10.2.0.
Comment #22
hemangi.gokhaleComment #23
vishal.kadamRemember to change status, when the project is ready to be reviewed. In this queue, projects are only reviewed when the status is Needs review.
Comment #24
avpadernoComment #25
hemangi.gokhaleThanks @bbu23 and @vishal.kadam for all the valuable suggestions. I have implemented all of them, and it was a really great experience exploring these API changes, especially PHP attributes. I've updated the code and provided the updates as follows. Apologies for changing the "Priority" & "Status" without fully understanding their importance. Thanks!
All set, the code now uses PHP attributes like
#[Group]and typed properties.Added
composer.jsonfile with module metadata, core constraints, and module type.Good catch, thanks! I've added the missing
tofield tocron_fail_alert.settings.ymlso the default config now matches the schema.Constructor property promotion has been added for the injected services.
hook_mail()has been converted into an OO hook implementation using#[Hook('mail')], with#[LegacyHook]included for backward compatibility.Since this requires bumping the minimum supported Drupal 10 version, and given that 10.1 is no longer supported, I’ve updated the minimum requirements.
Updated minimum requirements in the
.info.ymlfile to^10.3 || ^11Updated the docblock in
cron_fail_alert.moduleto use: “Hook implementations for the Cron Fail Alert module.”Replaced all translatable logger messages with literal strings containing placeholders.
Updated the
buildForm()method accordingly:#config_targetto each form element#default_valueusageSimplified
submitForm()to rely on the parent implementation.Updated
core_version_requirementincron_fail_alert.info.ymlto^10.3 || ^11.The constructor has been refactored to use promoted properties.
Comment #26
rushikesh raval commentedI am changing priority as per Issue priorities.
Comment #27
avpadernoThank 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.
Comment #28
avpaderno