Download & Extend

Undefined index warning in "Available Updates List" with hidden=TRUE base themes

Project:Drupal core
Version:7.x-dev
Component:update.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Issue tags:needs backport to D7, revisit after feature freeze, update.report.inc

Issue Summary

Problem/Motivation

If a base theme attempts to hide itself to end users by adding hidden = TRUE to its .info file, a "Notice: Undefined index" warning is shown while viewing the available updates tab at /admin/reports/updates.

Steps to reproduce the problem:

  1. Install Drupal 8.x with the standard profile.
  2. Copy the update module's existing tests themes (core/modules/update/tests/themes/update_test_basetheme and core/modules/update/tests/themes/update_test_subtheme) to /themes (so they become manually testable).
  3. Edit line 4 of both update_test_basetheme and update_test_subtheme theme's .info file to read hidden = FALSE
  4. Add a new line to both update_test_basetheme and update_test_subtheme theme's .info file to read "project = test" (required by update module)
  5. Clear cache
  6. Visit: Appearance (admin/appearance)
  7. "Enable and set a default" the "Update test subtheme" theme.
  8. Visit: /admin/reports/updates
  9. NOTE: no bug
  10. Edit line 4 of the update_test_basetheme base theme's .info file to read hidden = TRUE
  11. Visit: /admin/reports/updates
  12. NOTE: Notice: Undefined index: update_test_basetheme in theme_update_report() (line 202 of core/modules/update/update.report.inc).
  13. Apply latest patch: #986888-54: Undefined index warning in "Available Updates List" with hidden=TRUE base themes
  14. NOTE: Warning is removed

Proposed resolution

The proposed solution and patch addresses this issue by, "...moving a !$file->status if statement lower down to allow building a list of enabled sub themes in more cases (i.e., always)." #986888-12: Undefined index warning in "Available Updates List" with hidden=TRUE base themes

Current workarounds for people who cannot use the patch are to avoid use of hidden = TRUE of the base theme in use.

Remaining tasks

  1. "...[fix] this first in 8.x and then in 7.x." #986888-42: Undefined index warning in "Available Updates List" with hidden=TRUE base themes

User interface changes

New features/functionality in the enabled themes (/admin/appearance) user interface, would allow sub themes's base theme to be hidden. Currently, basethemes must be remain visible to avoid "Notice: Undefined index" warnings.

Original report by glisteningC

Notice: Undefined index: adaptivetheme in theme_update_report() (line 201 of /usr/... /drupal7/modules/update/update.report.inc).

This error message (above) shows up when viewing the Available Updates List (tab).
Reports >> Available Updates >> List (tab) or
Home » Administration » Reports >> Available updates >> List

As far as I've seen, it only shows up when viewing the List 'tab'.
It shows up on two different Drupal installations.
Running Drupal 7.0-rc1.

Comments

#1

Title:"Undefined Index" error message» Undefined index: adaptivetheme in theme_update_report()

Thought this Issue Title is better than the first one I used.

#2

Title:Undefined index: adaptivetheme in theme_update_report()» Undefined index for base theme in theme_update_report() when the base theme uses hidden = true
Project:AdaptiveTheme» Drupal core
Version:7.x-1.x-dev» 7.x-dev
Component:Code» update.module

Hmmm, looks like it could be a bug in Drupal - I tracked it down to hidden = TRUE, which I'm using in adaptivetheme.info to hide the base theme from end users (such as on the Appearance page). We're meant to be able to use this in Themes in Drupal 7, see http://drupal.org/node/542202 which states this can be used for themes (maybe not base themes?).

I'm moving this to the update module queue to get some feedback.

#3

Having the same error (notice) with 7.0 release:

Notice: Undefined index: adaptivetheme in theme_update_report() (line 201 of /home/XXX/XXX/XXX/modules/update/update.report.inc).

#4

I have removed the hidden = TRUE flag from the info file and has been committed to CVS, I'll be releasing an updated version of the theme very soon, just trying to sort out the skinr module stuff which is holding up a release.

#5

Status:active» needs review

Since it's a relatively simple change, the attached patch changes _update_process_info_list() to process hidden themes which have enabled sub-themes. This eliminates the warning shown in this issue, and seems like a reasonable idea to me.

AttachmentSizeStatusTest resultOperations
986888-5-show_hidden_themes_with_subthemes.patch1.35 KBIdlePASSED: [[SimpleTest]]: [MySQL] 31,494 pass(es).View details | Re-test

#6

Got this message for Zen to.

#7

This moves the problem to

Notice: Undefined index: adaptivetheme in theme_update_report()

line 201 of modules/update/update.report.inc

#8

drbeaker:

I think you'll need to manually check for updates once for this to take effect -- (I think it's relying on insufficient cached data). Go to Reports >> Available Updates >> Updates (it's the tab in the upper-right) >> Check manually.

Please report the results.

#9

Getting this with Omega as well.

#10

Sorry, meant to also say that patch seems to work cleanly. No longer getting the notice error.

#11

drbeaker: The fact that you are still getting the error is because the cached data in {cache_update} is stale. You'll need to empty that table, say via
TRUNCATE TABLE  `cache_update` in SQL.

Okay, I do see how you could still get that undefined index error --- we don't properly build $file->enabled_sub_themes (in update.compare.inc) in the case where the theme is both enabled and hidden. It seems unlikely, but is certainly possible if first you enable the theme and a later update sets hidden = TRUE.

#12

drbeaker: This should fix your issue in #7.

Attached patch addresses the note in #11. The main change is moving a !$file->status if statement lower down to allow building a list of enabled subthemes in more cases (i.e., always).

This might still need some more work, as the list of includes / depends / required by might be impacted by this.

AttachmentSizeStatusTest resultOperations
986888-12-fix_undefined_index_with_hidden_base_themes.patch2.71 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 986888-12-fix_undefined_index_with_hidden_base_themes.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#13

Status:needs review» needs work

The last submitted patch, 986888-12-fix_undefined_index_with_hidden_base_themes.patch, failed testing.

#14

Status:needs work» needs review

Reuploading to preserve the random testbot fail in #12.

AttachmentSizeStatusTest resultOperations
986888-14-fix_undefined_index_with_hidden_base_themes.patch2.71 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 986888-14-fix_undefined_index_with_hidden_base_themes.patch. See the log in the details link for more information.View details | Re-test

#15

Has anybody had a chance to test this one out?

#16

Title:Undefined index for base theme in theme_update_report() when the base theme uses hidden = true» Notice: Undefined index: boron in theme_update_report() (line 201 of [path from root]/modules/update/update.report.inc).
Version:7.x-dev» 7.0

Hi All,

I got a similar error message running the update script on a Drupal 7.0 instance.

Ran updates:
http://(my site).com/#overlay=admin/reports/updates

Got error message:
Notice: Undefined index: boron in theme_update_report() (line 201 of [path from root]/modules/update/update.report.inc).

Took a look at the 'update.report.inc' but can't see what might be triggering the error. Not on line 201 or anywhere else in the file.

I'm stumped.

- dave myers

#17

I'd like to test out this patch.
Not clear where and how to apply it (the specific file in which to insert the patch, and exactly where the insertion point is).
I'm no coder, so explicit instructions usually come in handy.
It appears that this thread mentions at least two files:
1. update.compare.inc
2. update.report.inc
Is the patch applied to one of these two files? If so, is there a specific point in the file in which to insert the patch?
Thanks,
-dave myers
P.S. My site is running on SQLite, not MySQL.

#18

Title:Notice: Undefined index: boron in theme_update_report() (line 201 of [path from root]/modules/update/update.report.inc).» Undefined index warning in "Available Updates List" with hidden=TRUE base themes
Version:7.0» 8.x-dev
Issue tags:-D7+needs backport to D7

#19

subscribe

#20

#21

Status:needs review» needs work

The last submitted patch, 986888-14-fix_undefined_index_with_hidden_base_themes.patch, failed testing.

#22

Subscribing here too. This is showing for all Fusion core and sub themes.

#23

Status:needs work» needs review

I've reuploaded #14 in the current -p1 diff format.

AttachmentSizeStatusTest resultOperations
986888-23-fix_undefined_index_with_hidden_base_themes.patch2.71 KBIdlePASSED: [[SimpleTest]]: [MySQL] 33,637 pass(es).View details | Re-test

#24

Status:needs review» needs work
Issue tags:+Novice

And now it needs a reroll again. :)

Tagging as novice for the task of rerolling the Drupal 8.x patch on account of #22336: Move all core Drupal files under a /core folder to improve usability and upgrades.

If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.

#25

Status:needs work» needs review
Issue tags:-Novice
AttachmentSizeStatusTest resultOperations
986888-now-with-core.patch2.73 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 986888-now-with-core.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#26

Status:needs review» needs work

The last submitted patch, 986888-now-with-core.patch, failed testing.

#27

Note that there is a testbot issue at the moment, which is why the patch failed. We'll want to re-test it once that is fixed.

#28

Status:needs work» needs review

#25: 986888-now-with-core.patch queued for re-testing.

#29

Status:needs review» needs work

The last submitted patch, 986888-now-with-core.patch, failed testing.

#30

#1346772: StatisticsLoggingTestCase->testLogging() fails with clean URLs in some environments again... someone please RTBC that patch before I hurt testbot. :)

#31

Status:needs work» needs review

#32

Issue tags:+Needs tests

The patch looks good to me. We should be able to add tests for this.

#33

Tests might have to wait for #953336: Contributed modules are not able to test theme-related functionality, but should be easy to write.

#34

Version:8.x-dev» 7.14
Assigned to:Anonymous» netdesignate

I am getting this on Fusion_Core:
"Notice: Undefined index: fusion_core in theme_update_report() (line 200 of /var/www/patchxxxxxxx/modules/update/update.report.inc)."

It's been a long time since this was an active thread - did I miss something ?
I am current on all code & modules as of this date...

#35

Version:7.14» 8.x-dev

Please do not change version numbers

#36

Assigned to:netdesignate» Anonymous

#37

#38

#25: 986888-now-with-core.patch queued for re-testing.

#39

Status:needs review» needs work

The last submitted patch, 986888-now-with-core.patch, failed testing.

#40

Assigned to:Anonymous» carsonblack

Looking into writing an automated test.

#41

Version:8.x-dev» 7.x-dev

Getting this error on adaptive subtheme in a profile.

#42

Version:7.x-dev» 8.x-dev
Assigned to:carsonblack» Anonymous

I think we are fixing this first in 8.x and then in 7.x.
@carsonblack, it's been awhile. If you want to tackle this again, just post a note. :) Thanks for trying. Tests can be tricky. Otherwise it's available.

#43

I had to enable the subtheme as a workaround. Can't delete it because it is part of a profile.

#44

I rerolled the patch from post 25, "986888-now-with-core.patch" to apply cleanly to commit 77f0384.

AttachmentSizeStatusTest resultOperations
986888-44-reroll.patch3.73 KBIdlePASSED: [[SimpleTest]]: [MySQL] 49,761 pass(es).View details | Re-test

#45

Status:needs work» needs review

I rerolled the patch from post 25, "986888-now-with-core.patch" to apply cleanly to commit 77f0384.

AttachmentSizeStatusTest resultOperations
986888-44-reroll.patch3.73 KBIdlePASSED: [[SimpleTest]]: [MySQL] 49,864 pass(es).View details | Re-test

#46

Status:needs review» needs work

confirming that patch in #45 removes the warning for base themes with the hidden = TRUE.

status update for automated tests, which are still needed.

#47

Status:needs work» needs review

here's a pass at adding an automated test with patch in #45. this tests specifically for the undefined index error and the hidden base theme and sub theme combination.

AttachmentSizeStatusTest resultOperations
update-hidden-base-themes-986888-47.patch5.4 KBIdlePASSED: [[SimpleTest]]: [MySQL] 50,701 pass(es).View details | Re-test

#48

Status:needs review» needs work

Thanks @bdone!

One thing we want to do in general is assert the correct, expected behavior rather than merely asserting that there is no error message. Otherwise, it could be broken in a different way but still pass the test.

Another thing to keep in mind is that the error reporting settings can vary from site to site, so if we are using assertText() to check whether an error was reported, we need to make sure the error would be reported. See ErrorHandlerTest for an illustration of how the error handling settings can affect what messages are displayed. In general, I recommend against asserting the absence of an error message, but let's start by looking at the test-only patch (like we discussed in IRC) to make sure it provides coverage.

Another thing we could try would be to test the function directly--call update_process_info_list() within the test method, instead of visiting a page where it is called with the browser. That way, the error should hopefully be raised in the test environment rather than the child environment, which would cause the test to fail.

  1. +++ b/core/modules/update/lib/Drupal/update/Tests/UpdateContribTest.phpundefined
    @@ -262,6 +262,37 @@ function testUpdateShowDisabledThemes() {
    +    /**
    +   * Tests that hidden base themes do not report a specified undefined
    +   * index error in the available updates report.
    +   */
    +  function testUpdateHiddenBaseThemeError() {

    The summary should be one line of 80 characters or fewer. I'd suggest broadening the method's purpose a little to test hidden base themes in general, like:

    /**
    * Tests updates with a hidden base theme.
    */
    function testUpdateHiddenBaseTheme() {
  2. +++ b/core/modules/update/lib/Drupal/update/Tests/UpdateContribTest.phpundefined
    @@ -262,6 +262,37 @@ function testUpdateShowDisabledThemes() {
    +    $this->assertNoText(t($message), t('The hidden base theme, update_test_basetheme, did not produce error message: !message', array('!message' => $message)));

    In general, assertion message texts should not use t(). See: http://drupal.org/simpletest-tutorial-drupal7#t

    Also, for assertText() and assertNoText(), the default message is usually sufficiently clear, so we can actually leave off the $message parameter here.

#49

Status:needs work» needs review

Thanks for the help and excellent feedback @xjm! Here's another pass at it.
This one incorporates all of your suggestions and (hopefully) gets us a bit closer.

AttachmentSizeStatusTest resultOperations
986888-49-tests.patch1.52 KBIdleFAILED: [[SimpleTest]]: [MySQL] 49,597 pass(es), 1 fail(s), and 0 exception(s).View details | Re-test
986888-49-complete.patch5.25 KBIdlePASSED: [[SimpleTest]]: [MySQL] 49,622 pass(es).View details | Re-test

#50

@bdone interdiff please (unless it's a reroll that cannot make one because of merges or conflicts)

#51

@YesCT: didn't think an interdiff was needed, because i've not actually touched the original patch. i did re-name it, which was probably my mistake. so in #49, 986888-49-complete.patch is actually 986888-44-reroll.patch.

Here's an attempt at fixing that, w/ out re-naming the original patch. would an interdiff still be needed?

AttachmentSizeStatusTest resultOperations
986888-49-tests.patch1.52 KBIdleFAILED: [[SimpleTest]]: [MySQL] 50,032 pass(es), 2 fail(s), and 0 exception(s).View details | Re-test
986888-44-reroll_0.patch3.73 KBIdlePASSED: [[SimpleTest]]: [MySQL] 50,005 pass(es).View details | Re-test

#52

okay, got a bit confused about which interdiff to provide here. attaching one between 47 and 49 as suggested by @Cottser in #drupal. thanks for helping clear it up!

AttachmentSizeStatusTest resultOperations
interdiff-986888-47-49.txt2.82 KBIgnored: Check issue status.NoneNone

#53

Status:needs review» needs work

+++ b/core/modules/update/lib/Drupal/update/Tests/UpdateContribTest.phpundefined
@@ -262,13 +262,15 @@ function testUpdateShowDisabledThemes() {
-    /**
-   * Tests that hidden base themes do not report a specified undefined
-   * index error in the available updates report.
+  /**
+   * Tests updates with a hidden base theme.

looks like this address. the 80 char. mentioned by xjm. in point 1. of comment #48

+++ b/core/modules/update/lib/Drupal/update/Tests/UpdateContribTest.phpundefined
@@ -262,13 +262,15 @@ function testUpdateShowDisabledThemes() {
-  function testUpdateHiddenBaseThemeError() {
+  function testUpdateHiddenBaseTheme() {

and this is good for being more general.

+++ b/core/modules/update/lib/Drupal/update/Tests/UpdateContribTest.phpundefined
@@ -283,14 +285,41 @@ function testUpdateHiddenBaseThemeError() {
-    $this->assertNoText(t($message), t('The hidden base theme, update_test_basetheme, did not produce error message: !message', array('!message' => $message)));
...
+    $this->assertTrue(!empty($projects['update_test_basetheme']), 'Valid base theme (update_test_basetheme) was found.');

this is both more general than looking for not an error, is looking for correct function. and also takes out the t() in the second argument to the assert.

+++ b/core/modules/update/lib/Drupal/update/Tests/UpdateContribTest.phpundefined
@@ -283,14 +285,41 @@ function testUpdateHiddenBaseThemeError() {
+    update_process_info_list($projects, $theme_data, 'theme', TRUE);

looks like update_process_info_list is called directly, as requested.

Summary

as best I can tell, the improvements have been made. (looking at the interdiff.)

I am confused though as the recent comment says the patch is the same as 44, but that is before xjm asked for the changes. So I think in comment #51 the test only patch has the improvements, but the complete patch does not contain the test. the "patch" should be both the fix and the tests, not just the fix. (when the committer, commits it, they commit the patch, so that should have both the tests and the patch)

I think there was some confusion there. What we need here is a new patch that has both the tests and the fix. probably to make it easy for the drupal core maintainers, is to include a justs tests along with that (which will probably be a duplicate of tests patch in #51 but that is ok.)

#54

Status:needs work» needs review

hopefully this incorporates feedback from @YesCT correctly...

  • 986888-54-tests.patch: a duplicate of tests patch in #51.
  • 986888-54-complete.patch: original patch from #44, including #54 tests patch.
  • interdiff-54-51.txt: an interdiff from #54 to #51.
AttachmentSizeStatusTest resultOperations
986888-54-tests.patch1.52 KBIdleFAILED: [[SimpleTest]]: [MySQL] 48,688 pass(es), 1 fail(s), and 0 exception(s).View details | Re-test
986888-54-complete.patch5.25 KBIdlePASSED: [[SimpleTest]]: [MySQL] 48,720 pass(es).View details | Re-test
interdiff-54-51.txt1.52 KBIgnored: Check issue status.NoneNone

#55

...any luck with the D7 port?...still getting the "Notice: Undefined index: ...theme in theme_update_report() (line 202 of ...\modules\update\update.report.inc)" after (986888-44-reroll_0) patch, even when I enable the base themes (AdaptiveTheme ones) involved...

#56

Status:needs review» reviewed & tested by the community

ok. we are getting completely confused with all these patches. @bdone dont worry much. we will sort out interdiffs on the next issue. :)

I went through this, and test and complete patch in 54 are ok.

#57

Status:reviewed & tested by the community» needs work

I really think this should be fixed by #1297856: Base themes should be required dependencies of subthemes and/or #1067408: Themes need an installation status instead of adding additional complexity around the system to check for updates of things that aren't registered in the system at all.

#58

@catch how about adding a @todo to convert to those once the are fixed? Or would that conflict with those issues and slow down them?

Those issues are not moving very quickly, and have their own dependencies.

Those issues or their dependencies don't look back portable to d7, would we still use an approach like this one in d7?

I suppose waiting a week or two to see how feature completion shakes down feb 18 in those issues is not too long to wait.

Updating tags (this has tests, and to revisit)

#59

Status:needs work» reviewed & tested by the community

Hmm given this is a Drupal 7 bug report I don't think we have a choice but to commit it to 8.x then refactor if those other two get fixed.

Back to RTBC.

#60

Version:8.x-dev» 7.x-dev
Status:reviewed & tested by the community» patch (to be ported)

Committed/pushed to 8.x, thanks!

#61

Status:patch (to be ported)» needs review

Backported #54 to D7.

AttachmentSizeStatusTest resultOperations
986888-61-available-updates-list-tests-only.patch1.38 KBIdleFAILED: [[SimpleTest]]: [MySQL] 40,225 pass(es), 1 fail(s), and 0 exception(s).View details | Re-test
986888-61-available-updates-list.patch5.06 KBIdleFAILED: [[SimpleTest]]: [MySQL] 40,221 pass(es), 1 fail(s), and 0 exception(s).View details | Re-test

#62

Status:needs review» needs work

The last submitted patch, 986888-61-available-updates-list.patch, failed testing.

nobody click here