Closed (won't fix)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
17 Mar 2025 at 15:39 UTC
Updated:
19 Sep 2026 at 20:04 UTC
Jump to comment: Most recent
Comments
Comment #2
vishal.kadamThank 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.
phpcs --standard=Drupal,DrupalPracticeon the project, which alone fixes most of what reviewers would report.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.
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.
Comment #3
vishal.kadamComment #4
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 #5
ckhaliloThe code is ready to review
Comment #6
ckhaliloComment #7
vishal.kadam1. Fix phpcs issues.
2. FILE: media_default_image.module
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/Form/DefaultImageSettingsForm.php
Properties should be declared first in a class, followed by methods.
Comment #8
ckhaliloComments #7 is fixed
Comment #9
vishal.kadamRest seems fine to me.
Let’s wait for other reviewers and Code Review Administrator to take a look and if everything goes fine, you will get the role.
Comment #10
avpadernoI will review the project tomorrow.
Comment #11
avpadernosrc/Form/DefaultImageSettingsForm.php
If the settings are only used by a plugin, there is no need to create a form class. A plugin's form is returned by its
settingsForm()method.The
$messageparameter passed to theLoggerInterfacemethods must be a literal string that uses placeholders. It's not a translatable string returned fromt()or$this->t(), a string concatenation, nor a value returned from a function/method.$form_state->setErrorByName('test', 'No image found for image one');The second argument passed to
::setErrorByName()needs to be a translatable string.src/Plugin/Field/FieldFormatter/DefaultImageFormatter.php
The parent class is not part of the public API and cannot be used as parent class for classes implemented by a contributed module. Only base classes can be used as parent class.
Comment #12
ckhaliloHi,
The reason why I use Form, I need to use default image multiple times, not only for the FieldFormatter.
I will fix the others issue.
Regards
Khalil
Comment #13
ckhaliloHi,
I've updated my code, can you please review?
Best regards
Khalil
Comment #14
rushikesh raval commentedI am changing priority as per Issue priorities.
Comment #15
bbu23Hi @ckhalilo!
Below you have my feedback:
1. One of the issues reported in comment #11 is still pending in
src/Form/DefaultImageSettingsForm.phpfile,validateForm()method.2. In the
DefaultImageSettingsForm.phpthedefault_imagefield is not required, so that means that I can leave the field empty. ThesubmitForm()method does not store the data when the field is empty, which can be confusing. Either make the field required or allow to store empty data.3. The
DefaultImageFormatter.phpfile duplicates significant code fromweb/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php. I was about to ask why not extending it, but it is unclear why you are trying to apply "image" options to a "media" formatter. You should consider extending theRendered entityorThumbnailformatters and simply handle the default image addition, and let the parent do its job, unless there's something that I am missing. By doing the current implementation you are cancelling the Media image usage.4. You have some French comments in the
createDefaultImageElementmethod.5. There is no error handling for when a user attempts to use the formatter without any default image set.
6. The formatter seems to be intended for Media entity but the
isApplicablemethod is not implemented to limit the options. Because of this I can set this formatter to any type of entity reference.7. When you are building the default image element, you should consider adding the configuration as cacheable dependency.
8. Better replace "How to use" with "Configuration" in README and provide better info on how to configure and use the module. And it would be preferred to have the name of the README file in full uppercase.
9. The hook_help provides no relevant information.
10. It's still not clear what's the benefit of this module and the global configuration as mentioned in comments #11 and #12. The current explanation is
but there is only one usage implemented in the module, and that's the field formatter.
Comment #16
avpadernoI am changing priority as per Issue priorities.
Comment #17
ckhaliloHi,
Point 1,2,4,5,6,8,9 fixed
Thank you for the point 3 i have updated to use extended MediaThumbnailFormatter, this work better now.
Point 7 is also fixed, now image has Cache dependency, thank you for remind me.
Point 10.
I understand that the module's scope is currently limited to Field Formatters.
The main objective is to centralize the configuration within a single interface, rather than managing it individually for each entity's field formatter.
If it were configured on a per-entity basis, this module wouldn't be necessary since users can already set default images in the standard image field settings.
I am already using it across six entity types (including Nodes and Taxonomy terms), which simplifies managing default images across various displays, such as Views
I have Updated my code.
Best Regards
Khalil
Comment #18
vishal.kadamI am changing priority as per Issue priorities.
Comment #19
ckhaliloAny updates please?
Comment #20
vishal.kadamI am changing priority as per Issue priorities.
Comment #21
vishal.kadamI am changing priority as per Issue priorities.
Comment #22
scontzen commentedAutomated Review
GitLab CI is not enabled for this project. I'd recommend enabling it, it catches a lot early. See GitLab CI setup.
Manual Review
1.0.x.README.MD, the module documentation guidelines specifyREADME.md(lowercase extension).isApplicable()properly limits the formatter to media references.config/schema/media_default_image.schema.yml. The module stores configuration inmedia_default_image.settingsbut has no schema, which is required for validation, config export/import, and strict config mode. See Configuration schema/metadata.$messageparameter passed toLoggerInterfacemethods must be a literal string that uses placeholders. InDefaultImageFormatter.php,settingsForm()passes$e->getMessage()andcreateDefaultImageElement()passes$exception->getMessage()directly.DefaultImageSettingsForm::submitForm(),file_usageis added for the new file but never removed for the previous one. Old files remain permanent and accumulate. The previous file ID should be loaded from config before saving, and$this->fileUsage->delete()called on the old file.hook_helpinmedia_default_image.moduleshould be converted. This requires^10.3 || ^11, but 10.2 is no longer supported.composer.json. While drupal.org auto-generates one during packaging, having your own allows you to define keywords and license. If you add one, note that there is no need to add the required Drupal version, since that is already added by the Drupal.org Composer façade.The starred items (*) warrant setting this back to Needs work.
This review uses the Project Application Review Template.
Comment #23
scontzen commentedComment #24
ckhaliloI have commited changes
Comment #25
scontzen commentedThanks for the update. All points from #22 are addressed:
config/schema/media_default_image.schema.yml.DefaultImageFormatter::settingsForm(),DefaultImageFormatter::createDefaultImageElement()andDefaultImageSettingsForm::submitForm()use literal strings with placeholders.DefaultImageSettingsForm::submitForm()reads the previous file ID from config and callsfileUsage->delete()on the old file before saving the new one.hook_helpmoved toMediaDefaultImageHookswith the#[Hook]attribute. The.modulefile is reduced to a docblock.composer.jsonadded.Looks good to me. RTBC from my side.
Comment #26
jnguyen23 commentedI reviewed the current 1.0.x branch and cross-checked the existing comments through #25 so I only list points that I did not see already reported there.
The following items still warrant Needs work:
1. The module currently claims `core_version_requirement: ^10.3 || ^11`, but `src/Plugin/Field/FieldFormatter/DefaultImageFormatter.php` still uses the Drupal 10 `MediaThumbnailFormatter` constructor/create signature. In Drupal 11, `MediaThumbnailFormatter::__construct()` also requires `ImageDerivativeUtilities`, so this formatter is not actually compatible with Drupal 11 as declared. Please either adapt the formatter for both supported core branches or drop `^11` until that compatibility is in place.
2. `config/schema/media_default_image.schema.yml` defines `default_image` as a `sequence`, but `DefaultImageSettingsForm::submitForm()` saves a single fid (or `NULL`) with `$config->set('default_image', $fid)`. The schema should describe the shape that is actually stored, or the saved config should be changed to match the schema. As it stands, this is still a config schema mismatch.
I did not find a separate new security flaw beyond the API/schema issues above.
Comment #27
vishal.kadamComment #28
vishal.kadamI am changing priority as per Issue priorities.
Comment #29
avpadernoThis thread has been idle, in the needs work state with no activity for some months.
May you confirm you are still pursuing this application? If this is the case, and you made commits basing on what previously reported, or you can answer the questions previously asked, please change the status to Needs review.
Comment #30
avpadernoThis thread has been idle, in the Needs work state with no activity for about four months or more; the application has been created about 11 months ago or more. Therefore, I marked it as Closed (won't fix).
If this is incorrect, and you are still pursuing this application, 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.