Problem/Motivation
Follow-up to #3493951: Split File oop hook implementations into separate classes where I noticed we have the following code in \Drupal\file\Hook\CronHook::__invoke():
$url_options = ['absolute' => TRUE];
if (isset($options['langcode'])) {
$url_options['language'] = $this->languageManager->getLanguage($options['langcode']);
$langcode = $options['langcode'];
}
else {
$langcode = NULL;
}
However, $url_options is never read anywhere, which means \Drupal\Core\Language\LanguageManagerInterface::getLanguage() is being called unneccessarily and the LanguageManagerInterface dependency can be removed.
Steps to reproduce
Proposed resolution
Remove the $url_options variable and LanguageManagerInterface dependency.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Comments
Comment #2
kim.pepperComment #4
jquijano commentedI will work on this
Comment #6
jquijano commentedRemoved $url_options as suggested, LanguageManagerInterface was not referenced in code.
Comment #7
jquijano commentedComment #8
kim.pepperSorry I should have postponed this on #3493951: Split File oop hook implementations into separate classes
Comment #9
dcam commentedThe related issue to split up the File hooks was committed. The changes in the existing MR will need to be applied in the new TokenHooks class. This seems like a Novice task to me.
Comment #10
jquijano commentedok, i'll work on this
Comment #11
jquijano commentedComment #12
jquijano commentedRebased branch to incorporate the latest updates. Made changes to the TokenHook class. Note: The CronHook file has been rewritten due to updates, rendering the original modifications unnecessary.
Comment #13
adwivedi008 commentedHello @jquijano,
I have checked the changes and it looks good to me
Also, there is no merge conflict as you already rebased the branch
Seems good to me, moving the issue to RTBC and let's wait for somemore feedback
Comment #14
quietone commentedWhenever dead code is removed we should do some digging to make sure that we aren't accidentally removing the last remnant of something that should be implemented. It is possible that this is accidentally dead code.
Therefor I used
git log -L 762,767:core/modules/file/file.moduleto find out when$url_options was added. It was inI then read that issue and found $url_options in the first patch there. It was removed in the next patch after feedback from berdir. It was originally used in the several of the cases following the line of code and those were re-written. I think that confirms that we are not losing anything here.
Comment #16
quietone commentedCommitted 56e3f8e and pushed to 11.x.
Thanks!