Problem/Motivation

The basic problem:

  1. Install standard
  2. Goto admin/appearance/settings/bartik and press save
  3. 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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rhache’s picture

really, nothing?

droplet’s picture

how to reproduce ?? what theme are you using. have you test RC4 & Dev ?

marcingy’s picture

Status: Active » Postponed (maintainer needs more info)
fubhy’s picture

Version: 7.0-rc3 » 7.x-dev
Status: Postponed (maintainer needs more info) » Active

This 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.

jastraat’s picture

system_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']) {

CrookedNumber’s picture

Version: 7.x-dev » 8.x-dev
Assigned: Unassigned » CrookedNumber
Status: Active » Needs review
FileSize
1.11 KB

Rolling patch.

ryan.gibson’s picture

Assigned: CrookedNumber » Unassigned
Status: Needs review » Needs work

patch no longer applies

ryan.gibson’s picture

Status: Needs work » Needs review
FileSize
1.16 KB

Rerolling patch

ryan.gibson’s picture

Assigned: Unassigned » ryan.gibson
Issue tags: +Needs tests
FileSize
1.81 KB
1.25 KB

Favicon also needed fixed. New patch and interdiff attached.

I will write the tests next week at core office hours.

fubhy’s picture

Status: Needs review » Reviewed & tested by the community

Thanks. This is a very annoying bug indeed.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Still needs tests.

dreamleaf’s picture

I 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.

dreamleaf’s picture

Status: Needs work » Reviewed & tested by the community

status prodding

fubhy’s picture

Status: Reviewed & tested by the community » Needs work

We need tests.

nimazuk’s picture

Status: Needs work » Needs review
Anonymous’s picture

Checked 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

Tor Arne Thune’s picture

I 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.

Status: Needs review » Needs work
Issue tags: -Needs tests

The last submitted patch, theme_with_no_logo_creates_notice-1006266-17-combined.patch, failed testing.

Tor Arne Thune’s picture

Issue tags: -Needs tests

#17: theme_with_no_logo_creates_notice-1006266-17-test-only.patch queued for re-testing.

The bot had some issues yesterday.

Tor Arne Thune’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
Anonymous’s picture

Thanks 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:

if (isset($values['logo_upload']) && $file = $values['logo_upload']) {

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.

disasm’s picture

I can't duplicate this manually in 8.x HEAD. Adding tags to get some more info.

disasm’s picture

Status: Needs review » Needs work
stpaultim’s picture

I am trying to recreate the steps for this issue.

According to the original report:

For themes that have the features[] = logo disabled in the theme's info file, the following error shows up:

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.

YesCT’s picture

@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.

stpaultim’s picture

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/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)

features:
  - logo
  - name
  - slogan
  - node_user_picture
  - comment_user_picture
  - comment_user_verification
  - favicon
  - main_menu
  - secondary_menu

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.

YesCT’s picture

those 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.

stpaultim’s picture

Thanks 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

features:
  - logo
  - name
  - slogan
  - node_user_picture
  - comment_user_picture
  - comment_user_verification
  - favicon
  - main_menu
  - secondary_menu

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

features:
#  - logo
  - name
  - slogan
#  - node_user_picture
#  - comment_user_picture
#  - comment_user_verification
#  - favicon
  - main_menu
  - secondary_menu

* 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.

stpaultim’s picture

@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.

sidharthap’s picture

Thanks 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 ?

sidharthap’s picture

I did the same process mentined @stpaultim. I did not encounter any error messages.

sidharthap’s picture

Issue summary: View changes

Adding detailed steps to recreate the issue

mandclu’s picture

Issue summary: View changes

Updated issue summary.

mandclu’s picture

@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.

star-szr’s picture

Assigned: ryan.gibson » Unassigned
Issue tags: -Needs steps to reproduce

I think we have confirmed the steps to reproduce, so removing that tag. This still needs tests.

The issue summary could still use some love.

sidharthap’s picture

FileSize
196.18 KB

Thank you for the clear steps. This time i replicate the issue. Here is my attachment.

sidharthap’s picture

Issue summary: View changes

the steps might be able to be simplified. pointing out the step that makes the error.

alexpott’s picture

Priority: Normal » Major
FileSize
526 bytes

This error is reproducible by just doing this...

Berdir’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 35: 1006266-35.patch, failed testing.

The last submitted patch, 35: 1006266-35.patch, failed testing.

alexpott’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests, -Needs issue summary update
FileSize
749 bytes
3.64 KB

A better test because it is in the correct test and a fix.

My steps to reproduce:

  1. Install standard
  2. Goto admin/appearance/settings/bartik and press save
  3. See PHP notice

The last submitted patch, 39: 1006266-39.test-only.patch, failed testing.

alexpott’s picture

Title: Theme with no logo creates Undefined index error » Saving theme-specific theme settings with no logo creates Undefined index error when file module enabled
Issue summary: View changes
Issue tags: +rc target

Improved 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.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
421.8 KB
60.2 KB

This still applies and fixes the issue thanks for the test.

Followed the steps to reproduce:

Before

After

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed 35af648 on 8.0.x
    Issue #1006266 by alexpott, ryanissamson, Tor Arne Thune, CrookedNumber...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.