Problem/Motivation
language() and global $language are now deprecated.
Proposed resolution
Use \Drupal::languageManager()->getCurrentLanguage($type) to replace language($type)
Use \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_INTERFACE) to replace global $language
Read more: https://drupal.org/node/2174591 and https://drupal.org/node/1450578
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | interdiff-2070369-43-45.txt | 749 bytes | herom |
| #45 | remove-language-2070369-45.patch | 40.74 KB | herom |
| #43 | remove-language-2070369-43.patch | 40.09 KB | jeroent |
Comments
Comment #1
mac_weber commentedPatch added.
Comment #2
mac_weber commentedComment #4
sidharthapHope it will pass.
Comment #5
mac_weber commented#1: drupal8.language.module-remove_deprecated_function_language-2070369-1.patch queued for re-testing.
Comment #6
mac_weber commented@sidharthap there is one last call you forgot to convert in your patch.
There is also a line which I cannot figure out why you got rid of. And if there is any reason for deleting it, it may be out of the scope of this issue.
Our patches look almost the same, I wonder if your patch passes the tests only because of this extra line you deleted. Please send an interdiff with next patch.
Comment #7
sidharthapThank you @Mac_Weber for reviewing. here is the new patch and indiff txt file.
Comment #8
mac_weber commentedYou created the interdiff against HEAD, not against the first patch. Well, I think I realized the problem on the first patch, some calls are missing the leading backslash, such as
\Drupal::languageManager()I also suggest you using
git format-patchfor creating the patches, yet it is not necessary: https://drupal.org/node/1054616You are still deleting this line. Which is out of the scope of this patch.
Sending correct patch, which just fixes the
print_r(language_types_get_all());on the patch at #7Comment #9
areke commentedThis patch doesn't apply anymore, so it needs to be re-rolledc.
Comment #10
bdgreen commentedReroll attached
Comment #11
bdgreen commentedComment #12
herom commentedlet's test.
Comment #14
bdgreen commentedReviewed my reroll patch #10 - d'oh - and submitted a new reroll from patch #8.
Comment #15
bdgreen commentedSubmitted for testing
Comment #16
bdgreen commentedSubmitted for testing
Comment #17
herom commented@bdgreen, all
Drupal::references should be prefixed with a backslash. this has been standardized in core: #2053489: Standardize on \Drupal throughout core.otherwise, good job.
Comment #18
bdgreen commentedThanks @herom. Corrections made.
Comment #20
bdgreen commented18: drupal8.language.module-remove_deprecated_function_language-2070369-18.patch queued for re-testing.
Comment #22
herom commented@bdgreen this needs another reroll now.
Comment #23
bdgreen commentedRerolled ;)
Comment #24
herom commentedI guess you didn't reroll #18, ha? just repeat what you did at #14 and #18 on top of #23.
Comment #25
bdgreen commentedYep. Reverted to #14, and since found two further corrections- but now waiting for test results before submitting xD
Comment #27
bdgreen commented23: drupal8.language.module-remove_deprecated_function_language-2070369-23.patch queued for re-testing.
Comment #28
mac_weber commentedThe last patch was fixing only one file.
@bdgreen, please make the patch files against HEAD, this will make them easier for revision.
Moreover, I've noted the first patches (including #8) have a small mistake not including the variable
$typeThere are many new files now that should be patched.
Sending a new one.
Comment #29
mac_weber commentedthere was many other missing entries I've added in this new patch
Comment #30
sunComment #31
herom commentedComment #32
internetdevels commentedI am working on re-rolling #29 patch but I found that
LanguageManager::getLanguage was changed in #1862202: Objectify the language system and now it requires $langcode to be specified.
So, LanguageManager::getCurrentLanguage should be used instead. I.e.
should be
instead of
Comment #33
internetdevels commentedHere is re-rolled and corrected patch.
It removes all calls of the
language()andfunction language()itself.Actually, all calls of the
language()were replaced by\Drupal::languageManager()->getCurrentLanguage()according to https://drupal.org/node/2174591.Comment #35
internetdevels commentedSeems I missed one place to replace
language()Comment #36
ianthomas_ukUpdated the summary following API changes.
Will it? I had a quick look at the implementation of this and I think it's already using an injected object. I don't think this is something we can specify at the interface level so we should just remove the sentence. Similar comments appear elsewhere in the interface and in Drupal.php (the line is also over 80 characters BTW).
We've lost Language::TYPE_INTERFACE. I'm not sure if this was a deliberate choice because TYPE_INTERFACE is the default, but surely it's better to be explict. There are lots of examples of this.
Here we're switching from TYPE_INTERFACE to TYPE_CONTENT. If that's intentional it's out of scope (and the variable name should have been changed too.)
Comment #37
berdirFirst part: I'd just convert that into an actual sentence, something like "Defaults to the current language for the language type Language::TYPE_URL"?
Second part, +1 to removing the default, existing examples often specify it because there used to be no default value. The idea is that if you don't know which one you need, it's very likely the default.
ckeditor: Yep, that looks wrong, probably a wrong copy & paste?
Comment #38
herom commentedrerolled, and fixed points in #36.
Comment #39
ianthomas_ukCurrently we're keeping the functions themselves in, which reduces the chance of breaking HEAD and makes the eventual removal patch easier to roll back.
Other than that, this patch looks ready.
Comment #40
herom commentedpatch without removing
language()function.Comment #41
ianthomas_ukAll my concerns have been addressed
Comment #42
alexpottremove-language-2070369-40.patch no longer applies.
Comment #43
jeroentCreated reroll.
Patch attached.
Comment #44
jeroentComment #45
herom commentedreplacing 1 new
language()call.Comment #46
ianthomas_ukreroll looks good
Comment #47
webchickCommitted and pushed to 8.x. Thanks!
Looks like the change notice at https://drupal.org/node/2174591 covers this change and then some, so we appear to be good there.