Problem/Motivation
The basic problem:
- Install standard
- Goto admin/appearance/settings/bartik and press save
- See PHP notice
This is an rc target because this is an extremely common admin task and seeing this error does not inspire confidence in Drupal 8.
There are reports of a more complicated situation but the fix for the above issue will fix the issue reported below.
For themes that have the features[] = logo
disabled in the theme's info file, the following error shows up:
* Notice: Undefined index: logo_path in system_theme_settings_validate() (line 624 of /Users/rene/Sites/test/newmodules7/modules/system/system.admin.inc).
* Notice: Undefined index: logo_upload in system_theme_settings_submit() (line 672 of /Users/rene/Sites/test/newmodules7/modules/system/system.admin.inc).
Steps to recreate:
1) Pulled a fresh installation of Drupal with git
2) Set up Drupal 8 with standard installation
3) Made a copy of Stark theme from drupal/core/themes
4) Pasted copy of Stark theme into drupal/sites/all/themes
5) Edited the necessary files to make a sub-theme of Stark called "Test"
• changed name of info.yml file to "test.info.yml"
• changed name of folder to "test"
• changed breakpoints.yml file to "test.breakpoints.yml"
• in info.yml file changed "name: Test" & added "base theme: stark"
6) Enabled the Stark theme
7) Made test theme the default theme and checked settings page (everything ok)
8) Added a slogan in 'configuration' and uploaded a custom logo under theme appearance.
9) Added following to drupal/sites/all/themes/test/test.info.yml
features:
- logo
- name
- slogan
- node_user_picture
- comment_user_picture
- comment_user_verification
- favicon
- main_menu
- secondary_menu
10) Cleared cache and checked "test" settings - all nine items still available as options (everything ok)
New logo and slogan appear as expected on home page.
11) Removed "- secondary_menu" from drupal/sites/all/themes/test/test.info.yml
• Cleared cache and checked "test" settings
• "Secondary Menu" was no longer an option - eight items still available (everything ok)
• Toggled "Logo" to "off" & saved configuration (everything ok)
12) Removed "- slogan" from drupal/sites/all/themes/test/test.info.yml
• Cleared cache and checked "test" settings
• "Site Slogan" was no longer an option - seven items still available (everything ok)
• Toggled "Logo" to "on" & saved configuration (everything ok)
• Site slogan was no longer visible, but the logo was visible on home page
13) Removed "- logo" from drupal/sites/all/themes/test/test.info.yml
• Cleared cache and checked "test" settings
• "Logo" was no longer an option - six items still available (everything still ok)
======> • Didn't change anything, but click on "Save Configuration"
Got reported error message.....
Notice: Undefined index: logo_path in system_theme_settings_validate() (line 651 of core/modules/system/system.admin.inc).
Notice: Undefined index: logo_upload in system_theme_settings_submit() (line 715 of core/modules/system/system.admin.inc).
Proposed resolution
Fix form submission to check if logo_upload
is set.
Remaining tasks
Review
Commit
User interface changes
None
API changes
None
Original report by @rhache
For themes that have the features[] = logo
disabled in the theme's info file, the following error shows up:
* Notice: Undefined index: logo_path in system_theme_settings_validate() (line 624 of /Users/rene/Sites/test/newmodules7/modules/system/system.admin.inc).
* Notice: Undefined index: logo_upload in system_theme_settings_submit() (line 672 of /Users/rene/Sites/test/newmodules7/modules/system/system.admin.inc).
As soon as I enable the logo in the theme's info file, the error goes away. Error was also in RC2 release.
Thanks,
Rene
Comment | File | Size | Author |
---|---|---|---|
#42 | Bartik___Site-Install.png | 60.2 KB | joelpittet |
#42 | Bartik___Site-Install.png | 421.8 KB | joelpittet |
#39 | 1006266-39.patch | 3.64 KB | alexpott |
#39 | 1006266-39.test-only.patch | 749 bytes | alexpott |
#35 | 1006266-35.patch | 526 bytes | alexpott |
Comments
Comment #1
rhache CreditAttribution: rhache commentedreally, nothing?
Comment #2
droplet CreditAttribution: droplet commentedhow to reproduce ?? what theme are you using. have you test RC4 & Dev ?
Comment #3
marcingy CreditAttribution: marcingy commentedComment #4
fubhy CreditAttribution: fubhy commentedThis error still occurs. Use the features[] in your custom theme .info file and do not add the "logo" as a feature. Submitting the theme settings form then prints that error message.
Comment #5
jastraat CreditAttribution: jastraat commentedsystem_theme_settings() only adds the logo-related form fields if logo is an enabled feature. Which is great - but then system_theme_settings_validate() and system_theme_settings_submit both assume that the logo_path field exists.
Line 631 needs to be something like:
if (isset($form_state['values']['logo_path']) && $form_state['values']['logo_path']) {
Line 679
if (isset($values['logo_upload']) && $file = $values['logo_upload']) {
Comment #6
CrookedNumber CreditAttribution: CrookedNumber commentedRolling patch.
Comment #7
ryan.gibson CreditAttribution: ryan.gibson commentedpatch no longer applies
Comment #8
ryan.gibson CreditAttribution: ryan.gibson commentedRerolling patch
Comment #9
ryan.gibson CreditAttribution: ryan.gibson commentedFavicon also needed fixed. New patch and interdiff attached.
I will write the tests next week at core office hours.
Comment #10
fubhy CreditAttribution: fubhy commentedThanks. This is a very annoying bug indeed.
Comment #11
webchickStill needs tests.
Comment #12
dreamleafI can confirm this bug, see attached images showing error before patch from #9 being applied, and post apply with no error.
With the #9 patch this issue is resolved and works without error.
I used a duplicated (renamed) Stark theme to replicate this, with the theme residing in root/themes.
Comment #13
dreamleafstatus prodding
Comment #14
fubhy CreditAttribution: fubhy commentedWe need tests.
Comment #15
nimazuk CreditAttribution: nimazuk commented#9: theme_with_no_logo_creates_notice-1006266-9.patch queued for re-testing.
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedChecked out latest D8 code, did as previous tester did and created a copy of stark, stark_custom.
Added features, commented out logo & favicon (in turn then both) & the errors were displayed as described in the issue. Tested with all other features available listed in http://drupal.org/node/221905 just to check, confirmed only logo & favicon cause the errors.
Applied patch in #1006266-9: Saving theme-specific theme settings with no logo creates Undefined index error when file module enabled and errors did indeed go away. Checked the code to make sure the solution was a sensible one and not just a hack, code is fine.
Saw two comments on the issue asking for tests to be written for this but confused as to what exactly the tests need to test. Looked through the filesystem for relevant tests - found ThemeTest.php which has relevant tests but couldn't find any specific for the features[] feature so unless it's somewhere else I'd actually be introducing new tests if written, and then the questions beg well the whole lot needs tests written, so jumped onto core office hours and here I am writing it all up awaiting further instruction/guidance!
Thanks
Steve
Comment #17
Tor Arne Thune CreditAttribution: Tor Arne Thune commentedI had begun making tests for this, but couldn't reproduce the undefined index notices with the test. I can reproduce them manually, of course. I'll upload what I have so someone else can continue it, if they see a way to provoke the notices.
The reason I made a new test class for this is that ThemeTest is supposed to test only Theme API functions (and should probably be renamed ThemeApiTest), and there is no other test classes that test the per-theme settings page.
The first patch attached should fail (but does not).
The second patch has the test and the fix combined and should not fail.
Comment #19
Tor Arne Thune CreditAttribution: Tor Arne Thune commented#17: theme_with_no_logo_creates_notice-1006266-17-test-only.patch queued for re-testing.
The bot had some issues yesterday.
Comment #20
Tor Arne Thune CreditAttribution: Tor Arne Thune commented#17: theme_with_no_logo_creates_notice-1006266-17-combined.patch queued for re-testing.
Comment #21
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks Tor Arne Thune!
So I'm still at the "why are we creating a test to test a fix as opposed to creating tests for the functionality, which, if were there in the first place would've meant this error would probably not have arisen, and if we are creating tests for the functionality then surely that should be split into a separate issue?" stage, probably due to lack of process knowledge.
Also I'd just like confirmation on one point, in the new "if" statements the code is thus:
I just thought this was a little confusing as it's checking and populating $file at the same time, which although is nice short code, not sure whether it's 'best practice' or whether it matters at all, just noticed it so thought I'd mention it.
Comment #22
disasm CreditAttribution: disasm commentedI can't duplicate this manually in 8.x HEAD. Adding tags to get some more info.
Comment #23
disasm CreditAttribution: disasm commentedComment #24
stpaultim CreditAttribution: stpaultim commentedI am trying to recreate the steps for this issue.
According to the original report:
Since then the info file has become the info.yml file AND the precise syntax for the items written in the info.yml file has changed slightly.
I found the following CHANGE RECORD that shows some of the changes: http://drupal.org/node/1935708
However, the change record does not show exactly how "features" should be written in the new info.yml file. Based upon other items, I'm guessing they would look something like this:
features:
logo: '0'
name: '0'
favicon: '0'
However, I'm not getting the behavior I expect with "features" formatted like this, so I'm not sure if I'm correct. Can anyone help me confirm the correct format for writing features in Drupal 8 info.yml files?
I will continue to experiment.
Comment #25
YesCT CreditAttribution: YesCT commented@stpaultim to help people give a good answer, please make a comment showing the contents of the files, or just attach a tar gz of the theme files you are trying. Also, let us know where you are putting them (in /themes ?)
that way, we can see where you are.
Comment #26
stpaultim CreditAttribution: stpaultim commentedTried and failed to recreate the problem:
1) Pulled a fresh installation of Drupal with git
2) Set up Drupal 8 with standard installation
3) Made a copy of Stark theme from drupal/core/themes
4) Pasted copy of Stark theme into drupal/themes
5) Made Stark theme the default theme and checked settings page (everything ok)
6) Added following to drupal/themes/stark/stark.info.yml (as described here: http://drupal.org/node/1935708#comment-7224390)
7) Cleared cache and checked stark settings - all nine items still available as options (everything ok)
8) Removed "- favicon" from drupal/themes/stark/stark.info.yml
* Cleared cache and checked stark settings
* "Shortcut Icon" was no longer an option - eight items still available (everything ok)
9) Removed "- slogan" from drupal/themes/stark/stark.info.yml
* Cleared cache and checked stark settings
* "Site Slogan" was no longer an option - seven items still available (everything ok)
10) Removed "- logo" from drupal/themes/stark/stark.info.yml
* Cleared cache and checked stark settings
* "Logo" was no longer an option - six items still available (everything still ok)
I expected it to break at this last step, but it didn't. Either it is now working or I've misunderstood the problem. It seems to me like there may have been significant problems since this was last confirmed as an issue.
Comment #27
YesCT CreditAttribution: YesCT commentedthose are great step by step instructions!
I think that now, we wait for someone to confirm that *they* can reproduce the problem.
Hmm thinking a little bit more:
I'm wondering if as a 4b you changed the name of the theme to make sure the right stark was being changed.
When you removed the slogan from the info file, did the slogan also disappear from the site?
After step 10, try a step 11 where you save the form (looks like you cleared the cache and reloaded the form).
For example, try changing the site name and then save.
We will need some steps to reproduce that are nice and specific like that for 7.x eventually, which will be a bit different since the info file in 7 does not use yml.
Comment #28
stpaultim CreditAttribution: stpaultim commentedThanks for the feedback @YesCT
I tried again, this time addressing the issues you mentioned.
Tried and failed to recreate the problem:
1) Pulled a fresh installation of Drupal with git
2) Set up Drupal 8 with standard installation
3) Made a copy of Stark theme from drupal/core/themes
4) Pasted copy of Stark theme into drupal/sites/all/themes
5) Edited the necessary files to make a sub-theme of Stark called "Test"
• changed name of info.yml file to "test.info.yml"
• changed name of folder to "test"
• changed breakpoints.yml file to "test.breakpoints.yml"
• in info.yml file changed "name: Test" & added "base theme: stark"
6) Made test theme the default theme and checked settings page (everything ok)
7) Added a slogan in 'configuration' and uploaded a custom logo under theme appearance.
8) Added following to drupal/sites/all/themes/test/test.info.yml
9) Cleared cache and checked "test" settings - all nine items still available as options (everything ok)
New logo and slogan appear as expected on home page.
10) Removed "- secondary_menu" from drupal/sites/all/themes/test/test.info.yml
* Cleared cache and checked "test" settings
* "Secondary Menu" was no longer an option - eight items still available (everything ok)
11) Removed "- slogan" from drupal/sites/all/themes/test/test.info.yml
* Cleared cache and checked "test" settings
* "Site Slogan" was no longer an option - seven items still available (everything ok)
* Site slogan was no longer visible on home page
12) Removed "- logo" from drupal/sites/all/themes/test/test.info.yml
* Cleared cache and checked "test" settings
* "Logo" was no longer an option - six items still available (everything still ok)
* Logo was no longer visible on home page.
13) Added "- logo" back to drupal/sites/all/themes/test/test.info.yml
* Cleared cache and checked "test" setings
* "Logo" was once again a visible option
* The logo was once again visible on the home page
14) Commented out several features including logo in drupal/sites/all/themes/test/test.info.yml
* Cleared cache and checked "test" settings.
* "Logo" was no longer an option
* Logo was no longer visible on the home page
At no point along this entire process did I experience any breaks or error messages.
Comment #29
stpaultim CreditAttribution: stpaultim commented@YesCT spotted the fact that I was failing to "Save Configuration" after checking the settings as described in #1006266-4: Saving theme-specific theme settings with no logo creates Undefined index error when file module enabled.
Once I realized this, it was easy to create the error messages. I've updated the issues summary to include very detailed instructions on how to recreate this issue. Please, excuse my confusion above.
Comment #30
sidharthapThanks for the clear steps @ Stpaultim
i tried to replicate the issue, I followed steps 1-6. when i click on activate and set default the theme, it displays error "The test theme was not found."
is it something wrong with my dev setup ?
Comment #31
sidharthapI did the same process mentined @stpaultim. I did not encounter any error messages.
Comment #31.0
sidharthapAdding detailed steps to recreate the issue
Comment #31.1
mandclu CreditAttribution: mandclu commentedUpdated issue summary.
Comment #32
mandclu CreditAttribution: mandclu commented@sidharthap It gave that message because you did not have the Stark theme enabled. I updated the steps to replicate to include that.
Having followed the updated steps I was also able to reproduce the problem.
Comment #33
star-szrI think we have confirmed the steps to reproduce, so removing that tag. This still needs tests.
The issue summary could still use some love.
Comment #34
sidharthapThank you for the clear steps. This time i replicate the issue. Here is my attachment.
Comment #34.0
sidharthapthe steps might be able to be simplified. pointing out the step that makes the error.
Comment #35
alexpottThis error is reproducible by just doing this...
Comment #36
BerdirComment #39
alexpottA better test because it is in the correct test and a fix.
My steps to reproduce:
Comment #41
alexpottImproved this issue title.
Tagging with "rc target" as this user story, changing theme specific settings, is super common and this looks bad. Not critical because site is not broken and nothing bad actually happens.
Comment #42
joelpittetThis still applies and fixes the issue thanks for the test.
Followed the steps to reproduce:
Before
After
Comment #43
catchCommitted/pushed to 8.0.x, thanks!