This probably needs to be opened as an issue, not here, but so many things crash at form.inc, I don’t know if it should be placed in Media or File Entity. I’ll edit/remove this post once that’s figured out.

# # #

Sorry to be a downer, but I’ve seemed to have found a few more issues. Getting these errors now as well:

Fatal error: Call to undefined function theme1033_form_system_theme_settings_reset() in /home/michael/public_html/d7pat/includes/form.inc on line 1520
Page execution time was 2324.23 ms. Memory used at: devel_boot()=0.92 MB, devel_shutdown()=11.7 MB, PHP peak=14 MB.

Fatal error: Call to undefined function theme1033_form_system_theme_settings_submit() in /home/michael/public_html/d7pat/includes/form.inc on line 1520
Page execution time was 1745.6 ms. Memory used at: devel_boot()=0.92 MB, devel_shutdown()=11.5 MB, PHP peak=13.75 MB.

None of the Devel error handlers are reporting anything (above is the total output).

From searching it’s possibly from a change in the use of managed files by file_entity, or maybe it’s an after effect of square_thumbnail ???

# # #

Background:

This theme was written to support Media 1.x

Related to: /admin/appearance/settings/theme1033

- Uploading images though Media browser (1.x & 2.x) works correctly (thumbnail displayed upon completion).
- The theme settings work with Media 1.x.
- The theme settings work without Media.
- The theme settings work with Media 2.x disabled (media, media_internet, media_wysiwyg, media_youtube).
- With Media 2.x enabled 2 of the 3 functions in theme-settings.php Fatal error.
- - Works: function theme1033_form_system_theme_settings_alter( &$form, &$form_state )
- - Error: function theme1033_form_system_theme_settings_submit( $form, &$form_state )
- - Error: function theme1033_form_system_theme_settings_reset( $form, &$form_state )

Global:

- Bartik, can change logo image okay.
- I can’t find any other form on the site having issues.
- Eyeball scan of theme-settings.php doesn’t show any glaring issues.

Fixes Tried:

- Flush and completely rebuild all image styles.
- Disable and re-Enable the Theme
- Disable and re-Enable Media 2.x (media, media_internet, media_wysiwyg, media_youtube)

# # #

At this point I want to ask, “What are the form building differences between Media 1.x and 2.x?”

Where’s the document for that basically?

With that I can check if anything in theme_settings_alter is no longer valid and somehow hosing submit and reset.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joseph.olstad created an issue. See original summary.

joseph.olstad’s picture

clue number 1:
Call to undefined function theme1033_form_system_theme_settings_reset()
clue number 2:
Call to undefined theme1033_form_system_theme_settings_submit()

in /home/michael/public_html/d7pat/includes/form.inc on line 1520

DEBUGGING TIPS:

//When you want to debug the $wtf variable, and dpm isn't doing it for you, then you should use this:
  watchdog('michael_debug', '<pre>@print_r</pre>', array('@print_r' => print_r( $wtf, TRUE)));

When you need a backtrace

Here is some backtrace code that might come in handy. The file should be created in the web root.

if ($fp = fopen('backtrace.log', 'w')) {
  $bt = debug_backtrace();
  fwrite($fp, 'debug='.print_r($bt, true));
  fclose($fp);
}

Another approach if you want it in your browser:

$bt = debug_backtrace();
echo "<pre>" . print_r($bt, true) . "</pre>\n";

Here is an example of some output:

[4] => Array (
  [file] => sites/all/modules/contrib/path_breadcrumbs/path_breadcrumbs.module
  [line] => 135
  [function] => ctools_access
  [args] => Array (
    [0] => Array (
      [plugins] => Array (
        [0] => Array (
          [name] => entity_field_value:node:feed_item:field_news_category

Keeping a log

Using a function like this, you can keep appending a log. The log is best viewed using gedit on Linux or Notepad++ on windows where you will be prompted automatically to reload. When you're wanting to see a fresh log, then just select-all, delete and save.


function imgoingtosaythis($what_im_sayin) {
  if ($fp = fopen('saythis.txt', 'a')) {
    fwrite($fp, "$what_im_sayin\r\n");
    fclose($fp);
  }
}
joseph.olstad’s picture

Title: custom called theme1033 no longer behaves since upgrading » custom theme called theme1033 no longer behaves since upgrading
Status: Active » Postponed (maintainer needs more info)
Michael-IDA’s picture

Hi Joseph,

backtrace-m1.log = Media 7.x-1.5 *
backtrace-m2.log = Media 7.x-2.6

I modified your back trace to use [=] as unique find-ables and added $form and $form_state to make it easier.

if ($fp = fopen('backtrace-m1.log', 'a')) {
  $bt = debug_backtrace();
  fwrite($fp, 'form[=]'.print_r($form, true));
  fwrite($fp, 'form_state[=]'.print_r($form_state, true));
  fwrite($fp, 'debug[=]'.print_r($bt, true));
  fclose($fp);
}

Added just prior to line 1520:

$function($form, $form_state);

Steps used:

Pre-load /admin/appearance/settings/theme1033
Delete backtrace-mN.log
Click ‘Reset to defaults’

This gives two of each variable, six sections total.

# # #

KDiff3 shows a large amount of variation (besides the expected for different items checked and pictures loaded).

About line 2514, we start getting additions of:

[#value_callback] => media_file_value

and

[#pre_render] => Array
                                        (
                                            [0] => media_element_pre_render
                                        )

====

The [js] => Array just below that has a completely different way of referencing sites/all/modules/media/js/media.js.

# # #

I’ve also attached theme-settings.php for reference.

I can also give you tarballs of the m1 and m2 sites. Take a day or so, as I’ll have to strip out the users and any proprietary content.

What would you like me to do at this point?

Best,
Michael

* D.O won't allow a 16MB file size to be uploaded (contrary to the 50MB it claims). Had to tar them.

# # # Other reference

michael@local [~/public_html/d7ptst]# php -v
PHP 5.5.9-1ubuntu4.21 (cli) (built: Feb  9 2017 20:54:58)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

michael@local [~/public_html/d7pat]# mysql -V
mysql  Ver 14.14 Distrib 5.5.55, for debian-linux-gnu (x86_64) using readline 6.3

michael@local [~/public_html/d7ptst]# drush status
 Drupal version                :  7.54
 Site URI                      :  http://default
 Database driver               :  mysql
 Database hostname             :  localhost
 Database username             :  inetd_d7ptst
 Database name                 :  inetd_d7ptst
 Database                      :  Connected
 Drupal bootstrap              :  Successful
 Drupal user                   :  Anonymous
 Default theme                 :  theme1033
 Administration theme          :  seven
 PHP configuration             :  /etc/php5/cli/php.ini
 Drush version                 :  5.7
 Drush configuration           :
 Drupal root                   :  /home/michael/public_html/d7ptst
 Site path                     :  sites/default
 File directory path           :  sites/default/files/public
 Private file directory path   :  sites/default/files/private
 temp                          :  /tmp

michael@local [~/public_html/d7pat]# drush status
 Drupal version                :  7.54
 Site URI                      :  http://default
 Database driver               :  mysql
 Database hostname             :  localhost
 Database username             :  inetd_d7pat
 Database name                 :  inetd_d7pat
 Database                      :  Connected
 Drupal bootstrap              :  Successful
 Drupal user                   :  Anonymous
 Default theme                 :  theme1033
 Administration theme          :  seven
 PHP configuration             :  /etc/php5/cli/php.ini
 Drush version                 :  5.7
 Drush configuration           :
 Drupal root                   :  /home/michael/public_html/d7pat
 Site path                     :  sites/default
 File directory path           :  sites/default/files/public
 Private file directory path   :  sites/default/files/private
 temp                          :  /tmp
Michael-IDA’s picture

Status: Postponed (maintainer needs more info) » Active

huh, forgot to change the Status back to active...

joseph.olstad’s picture

I was hoping you'd be able to find the answer your own question as this is a lot of customization.

Michael-IDA’s picture

Hi Joseph,

This is a purchased theme that works fine in Media 1.x. I am requesting information on how to upgrade its forms from Media 1.x to 2.x.

The use of Media in this theme administration page is quite small. I’ve added screen caps of the one tab where Media is used. Each drop down has the choices ‘None,’ ‘Image,’ and ‘Video.’ I’ve selected those in the first three regions. The ‘Image’ selection is the only use of Media (that I’m aware of), and it is called once for each of the 12 regions. media-regions-settings-07.jpg shows the pop up from clicking “Select media.”

While I didn’t write this code, I have no problem fixing it, but I do need a maintainer of the Media module to tell me what changed between 1.x and 2.x that breaks it. I was hoping you would spend the 15 minutes looking at the diff between the two backtraces to identify what Media 2.x broke, or what it now does differently that breaks a Media 1.x form.

These are swags, but:

What API changes did Media 2.x make?
What function(s) became no longer used?
What data structure(s) changed?

The code for a simple, known good, form that works in Media 1.x and code for the same form used for Media 2.x, to use for an example is also highly desired.

Best,
Michael

pacow’s picture

Hi,

I'm administering three websites, and all of them happen to use templates created by this same vendor. The upgrade from Media 1.x to 2.x went well. However when editing the themes' settings and committing them, this error is shown and the changes aren't committed:

"Error: Call to undefined function theme<my theme number>_form_system_theme_settings_submit() in form_execute_handlers() (line 1520 of <my specific path>/includes/form.inc). - The website encountered an unexpected error. Please try again later."

So it's the exact same problem. I'm no stranger to PHP, however not in a Drupal context. So I don't know what to do with earlier mentioned debugging code in order to find out what the problem is. I'm sorry about that.

To the point... The good thing is, this vendor offers one theme/template for free which uses the same code as the themes I'm having troubles with since Media 2.x. So anyone willing to help might want to download the Free Museum Drupal Template from here (http://info.template-help.com/help/drupal-template.html) and have a look at which point the theme's code conflicts with the Media 2.x module. I don't mind having to alter the theme's code, as long as I know *what* to alter.

I hope this comment is helpful and will not be seen as spam. Even worse, I wouldn't recommend purchasing these templates for use in new projects: they're old and therefore contain modules that cause problems when updating them.

pacow’s picture

I forgot to mention this because I didn't think it's important. When I open the theme's settings page (admin/appearance/settings/themeXXXX), twelve identical warnings are shown:

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /opt/lampp/htdocs/apps/themefix/includes/entity.inc).

As I'm still in urgent need for a solution, and as I'm now suspecting these 12 warnings might cause the error when the form page is submitted, I am now trying to investigate these 12 warnings first...

EDIT
sites/all/modules/media/media.module:930 shows: file_load($default_fid). I can get rid of the 12 array_flips() warnings by casting to integer: file_load((int) $default_fid). However, the error with submitting the form is still there, so I assume these 12 warnings don't have anything to do with it.

joseph.olstad’s picture

What version of php?

joseph.olstad’s picture

Any chance you can try an older 2.x release like example 7.x-2.x-beta2? See if that one has this problem, then from there try to see which release introduced this compatibility issues.

Follow-up here. Try to help out

Michael-IDA’s picture

> Any chance you can try an older 2.x release like example 7.x-2.x-beta2?

Sure. I can easily step through from 1.5 to 2.8.

Wish I'd thought of that myself :(

And thanks @pacow, I'll use their free demo, so I don't have the ~250 CK modules in the mix...

Back Friday(ish)

Michael

pacow’s picture

I am able to reproduce the error with PHP versions 5.3.3, 5.6.30, 5.4.16, 7.0.18, so differences in PHP versions might not be the problem.

I tried older versions for Media and File Entity in order to see with which one the problem is introduced. The latest combination that doesn't show the error message is: Media 2.0-alpha3 + File Entity 2.0-alpha3, both released October 26 2013. The next combination (Media 2.0-alpha4 + File Entity 2.0-beta1, October 4 2014) introduces the problem. In fact upgrading only File Entity to 2.0-beta1 works OK. If I instead only upgrade Media to 2.0-alpha4, the problem is introduced.

To further investigate, I disabled Media's submodules one by one (such as Media Internet Sources) and the problem was still there. When I finally disabled Media itself (while File Entity was still enabled) the problem disappeared. So I can now more precisely conclude that the problem starts occurring with Media's main module version Media 2.0-alpha4.

joseph.olstad’s picture

ok, thats great detective work.

Unfortunately there's a LOT of commits between alpha3 and alpha4
alpha3 was tagged 2013-10-25

alpha4 was tagged 2014-10-04

best path of debug is to clone media 7.x-2.x and checkout commit by commit between 2013-10-25 and 2014-10-04
this will pinpoint the exact commit that causes the issue.
if you can identify the exact commit that introduces this then we can very easily pinpoint the cause and possibly easily find a solution.

pacow’s picture

Indeed alpha4 has a huge changelog, so the following might point us to the exact commit... I did a stack trace with each warning. They mention media.module line 855 (still in alpha4) which inside the media_file_value() function says:

// Confirm that the file exists when used as a default value.
    if ($default_fid && $file = file_load($default_fid)) {
      $fid = $file->fid;
    }

If this info isn't useful, I can still do the debug path you suggested. It'll take some time but I just need to solve this. :-)

joseph.olstad’s picture

Based on your helpful debug information it appears that the commit in question is from 2014-02-05 commit hash 1023f976bd

#2187837: Bring media element and field widget inline with managed_file equivalents

It is however, a very large commit.

See if you can adjust the related code on head to fit your needs.

joseph.olstad’s picture

try this patch for 7.x-2.x dev or 7.x-3.x dev

joseph.olstad’s picture

Status: Active » Needs review
pacow’s picture

Hi, sorry for the delay, I was on vacation. :-) The patch unfortunately doesn't change the situation.

Today I'm diving deeper in it, I'll post my findings here.

pacow’s picture

***summary***

  1. The theme's settings form shows a range of identical warnings: Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of includes/entity.inc).
  2. Submitting the form raises an error: Error: Call to undefined function themeXXXX_form_system_theme_settings_submit() in form_execute_handlers() (line 1520 of includes/form.inc)

We need to get rid of the error in order to be able to save the theme's settings. The error might or might not be related to the warnings, but I can't be sure about that until we eliminate the warnings first...

***end of summary***

I managed to get rid of the warnings. In the patched (or unpatched) code in function media_file_value(), replace file_load($default_fid) with file_load($default_fid['fid']). Perhaps more lines need this fix.

I'm not sure I did the right thing (EDIT: it might even be the theme that passes data in the wrong format), but the warnings are gone and the image file form fields seem to work correctly now. Debug backtraces showed me that data was wrapped into an array twice while it needed to be done just once. file_load() calls file_load_multiple() and both seem to wrap things in an array. The result was: array_flip() was swapping an integer key with an array value while an array can't be used as a key. Instead it was this array's content that needed to be flipped.

The submit error remains however...

joseph.olstad’s picture

Brad.D’s picture

I am having this same issue with a template from the same place. I assume this affects many drupal templates from them. I was receiving errors when in Structure under blocks as well as Modules and Configuration.
I made the change in comment 20 and it seems to have cleaned up the warnings. But can not verify that it is fully functioning. Is there another fix for this?

Thanks.

pacow’s picture

About the warnings... @Brad.D I'm glad my change helps you. Keep in mind that I'm still uncertain about the correctness of my suggested fix. I'm beginning to think the theme's code needs a fix instead, but I'm also beginning to get stuck.

About the error... Thanks @joseph.olstad for pointing to the page about the submit handler. You resolved the issue by following the instructions by @scottm316.

I must admit I need some hints about how to implement these instructions... I found this file sites/all/themes/themeXXXX/theme-settings.php and I suspect this one needs the change. In it there's a function called themeXXXX_form_system_theme_settings_alter( &$form, &$form_state ), and perhaps it's these lines inside this function that need adjustment:

/* Submit function */
$form['#submit'][] = 'themeXXXX_form_system_theme_settings_submit';

/* Add reset button */
$form['actions']['reset'] = array(
	'#submit' => array( 'themeXXXX_form_system_theme_settings_reset' ),
	'#type' => 'submit',
	'#value' => t( 'Reset to defaults' ),
);

I tried changing the first line, but that didn't work. It's my lack of knowledge again getting me stuck here...

Brad.D’s picture

@pacow Yes looks like that fix didn't correct everything. When I went in to modify some images that use the media module it had all types of errors. Unfortunately I just have not had the time to look through the code though I agree it's the template that needs corrected. I contacted support from template help but they just said to use the modules that come with it. Lots of help they are.

joseph.olstad’s picture

@pacow
try this instead:

$form['#submit'][] = 'themeXXXX_form_system_theme_settings_submit';
$form['actions']['submit_add_another']['#submit'][] = 'themeXXXX_form_system_theme_settings_reset';
//$form['actions']['submit_add_another']['#submit'][] = 'theme2_form_system_theme_settings_reset';
//$form['actions']['submit_add_another']['#submit'][] = 'theme3_form_system_theme_settings_reset';

pacow’s picture

That didn't change anything, unfortunately.

As a workaround I would like to roll back my sites to Media (and File Entity) 7.x-2.0 Alpha 3. I know rolling back module versions is tricky. However, I did manage to do this rollback on local copies of my sites. Just by disabling modules, replacing them manually, and enabling them again. If it won't cause any side effects, I'll do this with my live sites too so I can resume my work.

joseph.olstad’s picture

hmm, too bad this isn't working out for this theme.

What is the name of the base theme for this? Maybe there's a patch available for the base theme that will fix this?

have you looked in the base theme issue queue?

joseph.olstad’s picture

There is no hook in drupal called system_theme_settings_reset

this must be a specific function that is included in your theme.

Can we have a look at that code?

you can try something like this:

if (!function_exists('theme1033_form_system_theme_settings_reset')) {
  module_load_include('inc', 'theme1033_theme', 'theme1033_theme.admin');
}

something to that effect.

Which module or theme contains theme1033_form_system_theme_settings_reset ???????

joseph.olstad’s picture

Status: Needs review » Postponed (maintainer needs more info)
pacow’s picture

#27 : There is no base theme. The *.info* file has no *base* config line.

#28 : *system_theme_settings_reset* is indeed a specific function, defined in *theme-settings.php*.

I almost forgot not everything in the world is open source. ;-) It might not be allowed to paste the code over here due to license stuff.

Fortunately one of their templates is freely available (#8): it's basically the same as the other ones and it raises the same problems. This free theme is meant as a demo, not for real use. I'm not a lawyer but I think it's okay for us to discuss that template's code just for our purpose. It's the second theme over here: http://info.template-help.com/help/drupal-template.html (it's called Museum). After installing (and ignoring a fatal error, a.f.i.k. the non-free themes don't have that one) you can login with *admin*:*admin123*.

EDIT: I'm getting tired :-) this is no Markdown form haha. So forgive my excessive use of asterisks. :-D

Michael-IDA’s picture

Status: Postponed (maintainer needs more info) » Active
FileSize
42.39 KB

They won't support their own product… Well, actually, it seems like they just bought it from template-help.com…

In any event, if they want to slap me with a cease and desist, let them..

theme-settings.php attached.

joseph.olstad’s picture

I logged into the museum demo site, looks pretty.
There's a lot of older modules on there that I'm assuming you've upgraded a few of them in your environment.

The first place to start when debugging this would be the duplicate module files module
https://www.drupal.org/project/dmf

Why This:
If module(s) are exists more than one locations on the server. It display a warning message to the developers/administrator and also acknowledge the duplicate path(s).

What could this help fix? Provided you find and remove the extra copies of modules, it could fix or explain the "Call to undefined function" issue.

Otherwise, if you still have an issue, is there any way you can upload the theme somewhere to have a look at the theme files and code? all of it?

Michael-IDA’s picture

you've upgraded a few of them in your environment.

Yes, every module not owned by Commerce Kickstarter in the site that has the issue is latest revision, except for Views Isotope, which I’ve help back as it’s upgrade path from 1.x to 2.x is in worse shape than Media’s.

Reply to my email, I’ll send you the theme tarball.

joseph.olstad’s picture

Ok, I'll have to also look at commerce kickstarter as well , asuming you're on the latest version of commerce kickstarter.

I didn't see your email yet, nor the attachment.

Michael-IDA’s picture

> I'll have to also look at commerce kickstarter

No don't, it's not the issue, it's just what I'm building for the client.

I sent you a message through Drupal.org,

Title: [Drupal.org] Theme tar ball
From: [me] @ .. inet-design.com
Tue Aug  1 10:02:26 2017

Check spam folder?

If you didn't get it send me a message through Drupal.org, and I'll reply to that.

Best,
Michael

Brad.D’s picture

I have almost identical theme-settings.php file for theme1005 from templatemonster which is actually from template-help.com. It has the same issues. I contacted their support and they are unwilling to help with the latest modules.

joseph.olstad’s picture

I'd like to help fix this problem, can someone please summarize all the most helpful clues about this issue so that we can deal with it.
Looks like it's this theme1005 issue
basically what I need, is the simplest way to reproduce this problem, example, download theme xyz from http://xyz
install module A, B, C, D
configure options Z Y X
observe abnormal behavior G and H
wanting to fix K

Michael-IDA’s picture

Hi Joseph,

A) Install the Theme Demo site I sent you yesterday.
B) Do nothing with Views Isotope (ever).
C) Except for Media (and File Entity) upgrade all other modules to latest revisions.

D) Then follow instructions in #13 above.

Path: admin/appearance/settings/theme1033

The latest combination that doesn't show the error message is: Media 2.0-alpha3 + File Entity 2.0-alpha3, both released October 26 2013. The next combination (Media 2.0-alpha4 + File Entity 2.0-beta1, October 4 2014) introduces the problem. In fact upgrading only File Entity to 2.0-beta1 works OK. If I instead only upgrade Media to 2.0-alpha4, the problem is introduced.

To further investigate, I disabled Media's submodules one by one (such as Media Internet Sources) and the problem was still there. When I finally disabled Media itself (while File Entity was still enabled) the problem disappeared. So I can now more precisely conclude that the problem starts occurring with Media's main module version Media 2.0-alpha4.

- Clicking either “Reset to defaults” or “Save configuration” will trigger the error.
- The Theme uses Media functions on the ‘Regions Settings’ tab for the ‘Background image URL’ Browse buttons.

# # #

My best guess is still that Media changed how it collects, handles, or passes, its data to the rest of Drupal. (Which is why I figured you’d be able to easily spot it from the backtraces I attached in #4.)

Best,
Michael

joseph.olstad’s picture

A) Install the Theme Demo site I sent you yesterday.

I didn't receive this email, did you forget to send it?....

However, I think pacow gave me a link to the theme that causes it.
http://info.template-help.com/help/drupal-template.html
the museum theme.

joseph.olstad’s picture

Component: Miscellaneous » Code
Category: Support request » Bug report
Status: Active » Needs review
FileSize
0 bytes

Ok guys, you're not going to believe this, but I isolated the code down to three lines of code...

see patch

joseph.olstad’s picture

removing irrelevant patch file. For the working test patch, use patch #40 until we come up with something better.

Status: Needs review » Needs work
joseph.olstad’s picture

woops, not sure why the file is 0 bytes, I'll re-upload it shortly

joseph.olstad’s picture

weird, I totally uploaded the wrong file in comment #40

here's the correct file:
Patch 43

joseph.olstad’s picture

Thanks for all the hard work and determination everyone!

Victory is ours

Status: Needs review » Needs work

The last submitted patch, 44: media-compatibility_regression_from_2xAlpha4_in_2014_issue-2884164-43.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joseph.olstad’s picture

I will bake up a new patch, have no fear victory is near

joseph.olstad’s picture

***EDIT*** only one patch needed, the core patch ***EDIT***
Ok, to fix this issue, it requires two patches one core patch only
one patch to media (which I will hopefully commit and publish a release once fully reviewed and vetted) - actually will prefer a commit to 7.x-3.x branch as thats our playground

then there's a core patch that is needed (patch 7 from this issue)
#1862892-7: When a theme has a managed_file field and a submit callback, call to undefined function error is thrown.

so apply the media patch to the media module (latest release 7.x-2.10 or 7.x-3.0-beta5)

and apply the core patch to drupal core (this fixes the undefined function xyz_theme_settings_submit
#1862892-7: When a theme has a managed_file field and a submit callback, call to undefined function error is thrown.

I've bumped up the priority on the core issue. It's apparently an issue in both D7+8

joseph.olstad’s picture

To test these patches before and after, it's quite easy:

Download the museum theme from here:
http://info.template-help.com/help/drupal-template.html

then install Drupal 7.56 using this make file:

install Drupal
enable the modules as recommended in the make file

then extract the museum theme and place it in sites/all/themes
the museum theme folder is called theme961

without patching, go to the theme settings page
press save.

you'll see a bunch of notices and warnings

if you get whitescreen make sure to enable the php error messages by editing your settings.php accordingly, this way you can see what the errors are.

***EDIT***to fix it, patch using patch #48***EDIT***
and also apply the core patch to drupal core

retest, it should be working at this point.

joseph.olstad’s picture

Title: custom theme called theme1033 no longer behaves since upgrading » theme no longer behaves since upgrading from media <=2.0-alpha3

update issue title description

Michael-IDA’s picture

Status: Needs review » Needs work

tl;dr
Need to test an existing, working Media 2.x plain form Browse button to see if it still works after applying both patches.

# # #

Just to verify I’m testing the right things:

to fix it, patch using patch #48
wget https://www.drupal.org/files/issues/media-compatibility_regression_from_2xAlpha4_in_2014_issue-2884164-48.patch
and also apply the core patch to drupal core
wget https://www.drupal.org/files/theme-settings-in-build-info-1862892-7.patch

Results:

- admin/appearance/settings/theme1033 no longer throws errors
- the file is uploaded to admin/content/file
- but the file is not retained in Regions Settings » Section 1 » Background image URL .

So, it’s either a partial fix, or the differences on how Media 1.x and Media 2.x handles plain form Browse buttons needs to be published.

I’m fine with just the differences being published, as that would lessen the chance of breaking existing Media 2.x content.

Well, actually, first someone who has an existing, working Media 2.x plain form Browse button needs to see if it still works after applying both patches. Then we’ll know where to go next.

Best

joseph.olstad’s picture

@Michael-IDA , the core patch provides 100% compatibility. its going to be a bit tricky to get to 100% compatibility. there's maybe some limits to what we can easily fix here because we're dealing with a theme that was published in 2012 prior to the media 7.x-2.x branch of the module.

***EDIT***
the core patch fixes everything, no need to patch media at all
***EDIT***

I've done tests, and we're able to save theme configuration without errors, although I you reported that the background image didn't save right, this is possible yes, I can perhaps try to see if we can tighten things up a bit to make that work.

Other tests I did were successful, navigating the site with the theme enabled, no problems.
Uploading a file with admin/content/file (handled by media when it's installed) works, in fact it works even WITH media bulk upload, so upload 10 at a time, the files are correctly created.

The only behavior change that I did to the media module affects theme settings form_state , so if you want to focus just on that, probably where our time will be best spent.

The core patch is definately all that is required, as without it we get errors galore.

joseph.olstad’s picture

Status: Needs work » Reviewed & tested by the community

OK, this is going to make your testing VERY easy.

Patch 48 is NOT required if you're using the core patch.

The core patch fixes EVERYTHING!
put that in your pipe and smoke it.

joseph.olstad’s picture

So back-off, revert patch 48, restore the media module to 7.x-2.10 clean
all you need is the core patch mentioned previously but here it is again:
#1862892-7: When a theme has a managed_file field and a submit callback, call to undefined function error is thrown.

joseph.olstad’s picture

So , I repeat, do NOT patch the media module.

core is the only thing that needs patching here.

Michael-IDA’s picture

Okay, good to go.

With just core patch:

Theme saves the file and re-populates ‘Background image URL’ correctly on page re-load.

Good by me.

joseph.olstad’s picture

super awesome thanks Michael!!!

Michael-IDA’s picture

Status: Reviewed & tested by the community » Needs work

Well, crud…

I thought I had borked the front page view, but no the core patch isn’t returning an array (when it’s suppose to?)

Adding this here, no need to get Jess riled up any more today ;)

drush vget theme_theme1033_settings

theme_theme1033_settings: Array
(
...

Demo Site: Fully works
Media 7.x-1.5 - no core patch
    [theme1033_section_1_bg_img] => Array
        (
            [fid] => 37
        )


Dev Site:  WSOD
Media 7.x-2.10 - no core patch
    [theme1033_section_1_bg_img] => Array
        (
            [fid] => 71
        )


Dev Site: Works, but doesn’t load image into proper Front Page sectional div's
Media 7.x-2.10 - core patch
    [theme1033_section_1_bg_img] => 407

/file/407 is the proper FID, so…

We now know the Theme is expecting the FID to be in an array, not a text var.

Q’s

  • Media is using FIDs as text var’s?
  • Where is this the data format change coming from?
  • Do we care?

My take

  • We’ve got Core and Media happy.
  • Trying to push them into an array structure will most likely break other code, so leave them alone
  • These themes were written for Media 1.x

So

  • We document how to update the theme?

And we’re finished?

Best,
Michel

::stupid formatting is quirking::

joseph.olstad’s picture

Ok, it looks like the D8 core patch is ready however we don't really care about that other than to adhere to the Drupal policy (I will refrain from comment).

So even though the D7 fix is working and we know it works, we need to backport the D8 tests (again to adhere to the core Policy, however it would be difficult to argue against writing a core test for this one)

Long story short, the D7 core issue needs work, if anyone can pitch in backporting the D8 test that'd be greatly appreciated.
see the D7 core issue here:
#2900373: [D7] When a theme has a managed_file field and a submit callback, call to undefined function error is thrown.

Thanks

joseph.olstad’s picture

the core patch solves most of the issues and the subsequent behavior after patching core is easier to debug for themers. So I imagine that most themers will be able to deal with it at that point however it would be nice to provide 100% support either or.

Michael-IDA’s picture

Edit: Ah, yeah, per Joseph in the next comment, replace my use of Media in a global sense in this post with File Entity in the specific sense. My bad ;)

Hey Joseph,

In regards to your last comment, after a week of noodling in off time, it seems that Media (probably because of core?) changed how it passes the FID around (and possibly other data, but FID shows direct evidence).

Given that Media (for whatever reason) now uses FID as a text var and not an array var, there doesn’t seem like there’s any way to provide 100% support for the (about ancient) themes that started with Media 1.x. Well, not without adding a huge amount of var type checking (gettype) and var conversion (array_map) to Media itself.

In any event, in a couple weeks I’ll re-write the theme I have to use text FIDs and update this ticket with what I find.

Best,
Michael

joseph.olstad’s picture

Media 1.x contained a sub module called file_entity, in 2.x this was split off into a separate project instead and the sub module was removed. If you're looking for file fid handling code, look in file_entity 2.x.

joseph.olstad’s picture

Category: Bug report » Support request
Status: Needs work » Fixed

As a support request, I would say this is fixed. The core patch does the job 99%, from there the theme is usable and the remaining issues easy to debug/fix.

Should someone find a better way, open a new issue, link this one and submit a patch or other.

Meanwhile, I have updated the media quick install recipe (drush make) to include the aforementioned core patch.

Status: Fixed » Closed (fixed)

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

adroot’s picture

Hi joseph.olstad,
after applying the patch to the core (https://www.drupal.org/files/theme-settings-in-build-info-1862892-7.patch), the errors disappear but all the time, the page loops up to message 503. It is not the fault of hosting, I contacted the admins. Please help.

I have updated the media module according to this manual: https://www.drupal.org/project/media/issues/2082037 (ver. by drush).

joseph.olstad’s picture

Hi @adrppt
please enable showing error messages in your settings.php
https://www.drupal.org/docs/7/creating-custom-modules/show-all-errors-wh...

this might help you figure out what is going on.
Try upgrading to Drupal 7 core 7.57
also update your file_entity module to the latest 7.x-2.16 version
and media to 7.x-2.16

make sure to re-apply that patch onto the upgraded drupal core after you've upgraded drupal core
drush up will upgrade

adroot’s picture

Hello joseph,
I followed exactly your instructions and unfortunately the effect is the same, server error 503. This loop in this patch simply causes the page to start (it spins the progress bar on the tab in the browser all the time), until finally the response time from the server pages is exceeded. I do not receive any additional messages (everything is included as in the given link when it comes to the settings.php file). ACB what's going on:

1. I have everything current except Media (1.5x).
2. I follow the manual (https://www.drupal.org/project/media/issues/2082037), ver. via drush.
a) File entity and Media in two variants, i.e. in version 2.16 and 2.6. On both versions the same.
3) Installs the patch to the core (https://www.drupal.org/files/theme-settings-in-build-info-1862892-7.patch). After entering: Appearance -> Settings -> Theme_xxxx I have a lot of errors under the title:
"Warning: array_flip (): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController-> load () ..."
After selecting any checkbox option (eg show the title of the page), and save, the errors disappear and here it is from now on without any mistakes.
4) And the entire page, both for admin and anonymous, still spins until we get 503. Sometimes it will load somehow, but clicking the subpage again results in a long loading and error 503.

Checked on Drupal 7.56 and 7.57 and two versions, above Media and File entity versions.

What are we doing next with this?
thanks for your commitment

joseph.olstad’s picture

Hi Adroot, please read the instructions for upgrading from Media 1.5. Media 1.x is no longer supported, has a known security flaw, the upgrade path is documented (see links in this comment),

First you'll want to back up your filesystem and database before starting. Then you'll have to upgrade to Media 1.6

then run update.php or drush updb

then follow the rest of the instructions here:
#2853273: upgrading from 1.x to 2.x support
and
#2082037: Document Upgrade Path from Media 1.x to Media 2.x/3.x

oh, one more thing, you might want to use file_entity 2.x latest dev release instead of the latest tagged release. However follow the instructions linked above exactly.

Thanks for not replying to this thread, it is unrelated to your issues.

adroot’s picture

Hello,
I did exactly that.
a) having the 1.5 version I raised to 1.6, I updated the base

b) only the version 1.6 I have upgraded to 2.16 and in the second attempt to 2.6, still, the problem is as mentioned above in the post.

I saw that I was not alone with this problem, another user (Michael-IDA) also had an identical problem with the purchased template and the Media update was a supported version.

I am determined, I think that together we will solve the problem :)

Regards

joseph.olstad’s picture

If you are having the same issue that @Michael-IDA describes then you must apply this D7 core patch:

https://www.drupal.org/files/issues/2900373-23.patch

Actually, just apply the core patch. OR could set your default theme to seven or bartik, this will avoid the bug that you are experiencing temporarily allowing you to do whatever necessary to upgrade.

then once the upgrade steps are complete and the said core patch is applied you can try switching back to your theme that was causing issues.

Simultaneously, you should also use the latest file_entity 2.x dev release , there is a few recent commits in the dev branch that may help you here.

otherwise, follow the instructions:

#2853273: upgrading from 1.x to 2.x support
and
#2082037: Document Upgrade Path from Media 1.x to Media 2.x/3.x

I ask as a favour, get this patch applied and then make sure to report here:
#2900373: [D7] When a theme has a managed_file field and a submit callback, call to undefined function error is thrown.

that this patch helped you out

keep in mind, there's over a quarter million installs of media, most people are on the 2.x branch now.
it is rare to have reports like this.

What version of php are you running?
do you also use memcache? maybe try to disable modules until you figure out which one is causing the issue.

adroot’s picture

Media ver. 7.x-1.7 [https://www.drupal.org/project/media/releases/7.x-1.7], solved my problem with media module. Thanx

joseph.olstad’s picture

media 1.7 is not a good solution , recommend the latest 7.x-2.x or 7.x-4.x of media

The newest dev release of Drupal core includes this fix, and the next release (7.60) of Drupal core has this fix so this issue will be resolved permanently from now on using the latest Drupal core dev release or wait until 7.60.
(or patch as directed if using an older core with an affected theme).

joseph.olstad’s picture

Actually I think it was actually Drupal core 7.61 that finally has this core fix.
should be good now with core 7.61 and newer

joseph.olstad’s picture

For anyone still having this issue, see comment #58
#2884164-58: theme no longer behaves since upgrading from media <=2.0-alpha3

After having re-read comment #58, Michael-IDA points out, that it looks like there's still a possibility for improvement with the media module or file_entity code, but should probably open up a new issue.