Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I just came across this. If you have any upper case in your colors in the default array it will color_shift instead of picking out the color from a selected other color set.
Probably in color_get_palette() it just needs to change all values to lower case.
Comment | File | Size | Author |
---|---|---|---|
#42 | interdiff-39-42.txt | 1.61 KB | naresh_bavaskar |
#42 | 1415206-42.patch | 968 bytes | naresh_bavaskar |
#34 | default-color-scheme-1415206-34.patch | 940 bytes | NitinLama |
#21 | default-color-scheme-1415206-21.patch | 534 bytes | RainbowArray |
#15 | default-color-scheme-1415206-15.patch | 537 bytes | RainbowArray |
Comments
Comment #1
Reg CreditAttribution: Reg commentedFor anyone who needs this fixed now adding array_map() to the return line in color_get_palette() solves it. Below is how the changed line looks:
Comment #2
Reg CreditAttribution: Reg commentedComment #3
Devin Carlson CreditAttribution: Devin Carlson commentedThis is a duplicate of #1196656: Mixed case hex values in default color scheme result in errors when selecting alternate color scheme..
Comment #4
Reg CreditAttribution: Reg commentedThe issue that this was marked as duplicate however the issue it was specified as being a duplicate of an isse that makes mention of a "notice" error is being produced. This is NOT the case here. The issue here is purely that there is a logic error in how case for colors is handled in the color module.
That is, no "notice" message was ever observed. I suspect that the "notice" message was fixed through the Drupal versions since the other issue is so old. The issue here of "case and color shifting" has yet to be resolved so I am changing this issue back to active.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commented#1 as a patch file.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #7
markhalliwellPatch makes sense and is straight forward. However, please re-roll with the new Drupal::config() that's now in place.
Comment #8
markhalliwelltagging
Comment #9
markhalliwellActually you should probably map to drupal_strtolower() instead, which is really just a wrapper around Unicode::strtolower(). Either should work.
Comment #10
RainbowArrayComment #11
RainbowArrayThis was a bit more than a reroll. Here's an updated patch.
Comment #13
RainbowArrayRe-did the patch.
Confession: I hope I did this correctly, but not entirely sure.
The original code that the patch in #5 was trying to fix was as follows:
The suggested patch was:
However, since that patch on July 29, 2012, the color.module was updated to the following line:
Here's the approach I tried.
I changed the config() to Drupal::config() and wrapped that in Unicode::strtolower() as suggested in #7 and #9. I'm not sure if an array_map is what's needed here?
Anyhow, if somebody could take a look, that would be great. Thanks!
Comment #14
markhalliwellHi @mdrummond :) Thanks for working on this issue and submitting patches!
I suspect this patch will fail as well. The errors from the first test indicates that strtolower needs the parameter to be a string and we're passing the CMI setting (which is the array). From reading the issue, the patch in #5 is attempting to use array_map() to lower case the values of the array (see: http://stackoverflow.com/questions/4445984/strtolower-on-a-array).
This being said, I'm not entirely what is being returned by the new CMI (ie: if it's the same simple array as before). Try doing this:
My comment about using drupal_strtolower or Unicode::strtolower, was I'm not entirely sure what should be passed as the first parameter in array_map:
array_map('drupal_strtolower'
,array_map('Unicode::strtolower'
... or I think this would actually work as a valid callback:array_map(array('Unicode', 'strtolower')
Comment #15
RainbowArrayOkay, let's see if this patch passes!
Comment #16
markhalliwellTriggering test bot
Comment #18
RainbowArrayComment #20
markhalliwellAh! I see the problem. The
array_map()
function is getting closed too early. See the extra)
at the end of:Drupal::config('color.' . $theme))
Comment #21
RainbowArrayOne would think that eventually I would get this patch right. One will soon see.
Comment #22
jOksanen CreditAttribution: jOksanen commented#21: default-color-scheme-1415206-21.patch queued for re-testing.
Comment #23
markhalliwellOne tiny nitpick (that I just noticed). This comment should probably be removed and replace with something says it loads the saved configuration palette or the default one if it doesn't exist. It also converts values to lowercase hexes. Follow documentation standards at https://drupal.org/node/1354#drupal and https://drupal.org/node/1354#inline.
Didn't need to re-test, it passed. I'm hesitant to tag as needs tests, this is a very minor change and can be covered with the above inline comment.
Comment #24
mgiffordComment #33
partyka CreditAttribution: partyka at Argonne National Laboratory commentedComment #34
NitinLama CreditAttribution: NitinLama at OpenSense Labs commentedAdded return statement with comments.
Comment #35
NitinLama CreditAttribution: NitinLama at OpenSense Labs commentedComment #36
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commented@NitinLama We cannot have a comment exceed 80 columns due to coding standards. It needs to wrap onto the next line.
Comment #37
NitinLama CreditAttribution: NitinLama as a volunteer and at OpenSense Labs commentedUpdated comment.
Comment #38
g-brodieiNice work!!
Was reviewing as I went searching through D8.9.x, and it seems like the callback function "drupal_strtolower" only exist in D7's Unicode.inc file.
Back to need work if this patch is to be ported to D8.
Posting D7 version code for reference, might reconsider using mb_strtolower() as part of a callback function for array_map as an alternative to the Unicode::strtolower suggestion before since it's gonna be deprecated in D9.
Comment #39
shetpooja04 CreditAttribution: shetpooja04 at QED42 commentedI have added the drupal_strtolower function definition in D8.9.x
Please review !
Thank you
Comment #40
g-brodieiThanks for the effort on creating a new patch! Just a few things we need to check before moving forward.
The function drupal_strtolower($text) was deprecated and removed when upgrading from Drupal 7 to Drupal 8 for a reason, I don't think we should be adding it back into Unicode.inc file again. Let's just use "mb_strtolower" instead in the array_map function, this was what I saw changed in the _color_rewrite_stylesheet function comparing Drupal 7 to Drupal 8.
We still need to update the "issue summary" and do a "manual testing" to assure this patch is good before setting to "RTBC". Follow the guidelines on Issue summary and Manual testing for further information. ;) Thanks!
Going back checking on core's git history, the removal action of drupal_strtolower function happened in the following issues #2361825: Remove drupal_strtolower, #2361823: Remove usage of drupal_strtolower(), and see #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase? for the policy reason for this deprecation change.
Drupal 8 color.module
Drupal 7
Comment #41
naresh_bavaskarComment #42
naresh_bavaskarUpdated the
mb_strtolower
in array_map function asdrupal_strtolower
was removed from d8.Please review
Comment #43
guilhermevp CreditAttribution: guilhermevp at CI&T commentedPatch still applies and is working as intended. Moving to RTBC.
Comment #44
larowlanWe're changing behaviour here, previously it was color.theme.{theme} now it is just color.{theme}
This comment is wrapped prematurely and we're losing a lot of the previous comment. Let's just add a sentence to the existing comment - something along the lines of.
Ensure that hex values are cast to lowercase to ensure case-insensitivity.
Also, as this is a bug-fix, it would be good if we had some test-coverage that demonstrated the bug, and that the fix applied here resolves it.
Given the change made at item 1 didn't break any tests, I'm guessing there isn't much in the way of existing test-coverage for color module.
Comment #48
quietone CreditAttribution: quietone at PreviousNext commentedColor has been removed from core, #3270899: Remove Color module from core.