This is a simple module that when clicking on a media entity instead of being redirects to media/123 it will display the file in the browser with the alias. The pros of this are
Internal path to file, such as sites/default/files is not displayed to the user
If a media object is referenced in multiple locations the media object can be updated with a new file and reflected in all instances automatically.
Believe it can be added with composer also. The dev version should be a stable release but want to have it covered first. My first module submission so hope I did everything right!
Project link
https://www.drupal.org/project/media_alias_display
Git instructions
git clone --branch 1.0.x https://git.drupalcode.org/project/media_alias_display.git
Manual reviews of other projects:
https://www.drupal.org/project/projectapplications/issues/3185387#commen...
https://www.drupal.org/project/projectapplications/issues/3180754#commen...
https://www.drupal.org/project/projectapplications/issues/3172187#commen...
Comments
Comment #2
avpadernoThank you for applying! Remember to change status, when the project is ready to be reviewed. The current status is telling reviewers not to review it,
Comment #3
smustgrave commentedComment #4
smustgrave commentedJust wondering what next steps are for me to opt in for my modules?
Comment #5
smustgrave commentedJust following up on this. Wondering if there are next steps I should take?
Comment #6
bramdriesenHave a look at the review bonus program :) https://www.drupal.org/node/1975228
Comment #7
bramdriesenI ran codesniffer on your project and it returned the following code sniffs.
No big issues, nor a showstopper to move on, but would be great if you can fix those small issues to have no sniffs at all.
Going a bit more through the code I noticed following things.
- In your info.yml you have the following comment
# Modelled after https://www.drupal.org/project/media_entity_downloadIt's not really needed to credit a module for having a look at their info.yml version ;-)
core_version_requirement: ^8.7.7 || ^9Is there a reason to be requiring 8.7.7 specifically?
- Your README.txt only has the project name which is not helpful. Have a look here https://www.drupal.org/docs/develop/documenting-your-project/module-docu... & https://www.drupal.org/docs/develop/documenting-your-project/readme-temp... to build a meaningful readme file.
- You can also add the drupal core requirements in your composer.json (but first clarify the requirement of 8.7.7 :-) )
- In your DisplayController.php class you are mixing variable naming conventions. $current_path for example is in snake case. $mediaID is no standard at all.
- In your DisplayController.php class you're using the \Drupal::logger() service, this could be injected with dependency injection.
I didn't test the module yet, but it sounds very interesting, so I'll test this on a vanilla Drupal installation in the coming days.
Comment #8
avpadernoComment #9
smustgrave commentedThank you for this! I'll work on these changes and try and get them pushed today.
Comment #10
smustgrave commentedRan phpcs through it and all those findings should be addressed.
Updated the .info and composer files to have the correct requirements/require value.
Updated the controller to use dependency injection.
Also updated the naming convention.
All ready for testing!
Comment #11
bramdriesenYour module info.yml is not compatible anymore with any Drupal core older as 8.7.7. So you need to add the core: 8.x key or bump your requirement to 8.7.7 or 8.8
Comment #12
smustgrave commentedFixed the issue above.
Comment #13
smustgrave commentedTook a look at the review bonus program. Would someone be able to tell if I did a correct job on https://www.drupal.org/project/projectapplications/issues/3185387#commen...? If so I'll pick 2 others!
Comment #14
bramdriesenWhat you did was good and would qualify for the bonus program.
Comment #15
smustgrave commentedComment #16
smustgrave commentedDid 2 others.
Comment #17
smustgrave commentedComment #18
smustgrave commentedI hate to be that guy but could anyone look at this application this week? My work wants to add this and another module to a proposal and it looks better with that security coverage. Know that’s not how this stuff works but it truly would be appreciated. Not the end of the world if not just wanted to ask.
Comment #19
avpaderno$this->currentPath->getPath()already returns the un-aliased Drupal path.Instead of concatenating the strings passed to
notice()the code should use placeholders.A method that extends the parent's method uses
{@inheritdoc}as documentation comment.Why is the view method redirecting users to the edit route, when it's supposed to be invoked when the entity is viewed?
Comment #20
smustgrave commentedJust pushed those fixes up to the dev branch.
That last snippet of code is actually a trick I added. During a migration out of a non Drupal system we had over 50,000 PDFs with weird aliases but editors were having a hard time finding the media object in Drupal. So they just append ?edit-media while viewing a PDF and it took them straight to the media object to edit.
Comment #21
bramdriesenDoes it need to be part of the module?
And it would be better to check for the edit media permission instead of just checking if the user isn't anonymous. It's not really an issue because the permission system would block users that don't have access to the edit page. But still it would be cleaner if you would catch it.
Comment #22
smustgrave commentedIt is something I would like to keep.
I readded a path field back because $this->currentPath->getPath(); got me the internal path but $this->request->getRequestUri(); got me the browser url (ex. test?edit-media).
Added in the permission check for the bundle to see if the user has permission to edit their own or any of that particular bundle.
Pushed changes to the dev branch.
Comment #23
smustgrave commentedJust following up if all the blockers have been resolved?
Comment #24
avpadernoI edited the issue tags as per https://www.drupal.org/node/1975228.
Comment #25
smustgrave commentedWait why did I lose the review bonus/ what else needs to be done?
Comment #26
carwin commentedAutomated Review
[Best practice issues identified by pareview.sh / drupalcs / coder.
phpcs with Drupal standards reported no errors or warning on the latest commit to the 1.0.x branch.
Manual Review
@placeholders for functions that provide output, and good use of existing API functions, but otherwise nothing jumps out that seems like it needs any kind of overt security / hardening.This review uses the Project Application Review Template.
At this point, smustgrave has addressed or resolved everything that's been brought up. I'm marking this RTBC, nice work.
Comment #27
avpadernoThe string passed to
notice()should use a placeholder too, like the following line.Thank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
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 all the dedicated reviewers as well.