Drupal Themes getting "unselected" - drupal

Sometimes, at least 1 time a month +-, when I visit my site, there is no theme selected and I get a lot of error code.
Notice: Undefined index: highlighted em include() (linha 120 de /var/www/novoportal.faccat.br/htdocs/portal/modules/system/page.tpl.php).
Notice: Undefined index: sidebar_first em include() (linha 132 de /var/www/novoportal.faccat.br/htdocs/portal/modules/system/page.tpl.php).
Notice: Undefined index: sidebar_second em include() (linha 138 de /var/www/novoportal.faccat.br/htdocs/portal/modules/system/page.tpl.php).
Notice: Undefined index: genesis em drupal_theme_initialize() (linha 100 de /var/www/novoportal.faccat.br/htdocs/portal/includes/theme.inc).
Notice: Trying to get property of non-object em _drupal_theme_initialize() (linha 145 de /var/www/novoportal.faccat.br/htdocs/portal/includes/theme.inc).
Notice: Trying to get property of non-object em _theme_load_registry() (linha 321 de /var/www/novoportal.faccat.br/htdocs/portal/includes/theme.inc).
Notice: Undefined index: genesis em theme_get_setting() (linha 1316 de /var/www/novoportal.faccat.br/htdocs/portal/includes/theme.inc).
I always need to select the theme again and clear the cache.
Also I used the Devel theme rebuild tool, but I keep getting these errors.
Any Ideas?

This is what I suggest:
1) First check the .info file and make sure the regions are there as per page.tpl.php. Your error is based on that .
2) If the the above is true then the next thing I would do is make a new fresh installation and only move the sites/all/themes/ folder to it and the db I would then test it to make sure the error does not occur.
Hope it helps.

From your description I think it might be a weird bug in Drupals theme discovery - try calling:
_system_rebuild_theme_data()
One call to it should be enough so don't leave it permanent - as it will cripple your site load times.
I've filed a bug and description.
Edit
The above will probably not fix your problem permanently, I just thought it would at the time of writing.

I believe this may be caused in some cases by a failed cron run.
I was observing this problem on a dev site where I was basically the only person interacting with it. The problem would surface after a couple of hours of inactivity. The only events in the log would be related to cron runs.
I was able to determine that a normal, user-initiated cron run would not cause the problem.
One type of cron entry was an 'invalid key' error. I investigated and determined that there was a cron job set up to run without a key. After eliminating that cron job, I wasn't able to observe the error any longer.

i also had faced similar issue and after installing nucleus https://www.drupal.org/project/nucleus theme (which is required to install any custom theme on drupal7) and secondly I deleted cache entry for my custom theme(drupal_cache table), then above issue resolved.I could see modules now then i went to appearance tab and set my custom theme as Default theme.
Hope this would help

Though I have no answer to this problem, I thought it might come in handy to add some cross links:
"Theme is randomly disabled" at drupal.org
"Themes (custom/derived/new) are disabled at random intervals" at drupal.org
If you find more links, please add them here!
EDIT (2014-10-22): In a multisite environment we had not installed the default site at first. Because of this Drush occasionally generated warnings or errors, so we added a settings.php file to the default site's directory with database credentials of a test site's database. Since we installed the default site with it's own database, the problem fortunately has not occurred anymore. :-)
It might have had something to do with multiple crons being executed on the same database at the same time...?

Related

WP Contact form is not working, Spinning wheel forever after submitting form

I have created a contact form on our website, I thought it worked in the past, but now when you click the submit button nothing happens and a blue spinning wheel comes up and nothing happens.
Does anyone know what it can be? Some manage to fix it by deleting the password-protect plugin but I do not have that enabled.
Java error from console
Link to the website with the contact form: https://www.hamarbilpleie.no/kontakt-oss/
Dubug plugin result
[03-Mar-2021 20:31:48 UTC] PHP Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/2/h/hamarbilpleie/www/wp-content/themes/carservice/contact_form.php on line 261
[03-Mar-2021 20:31:48 UTC] PHP Fatal error: Uncaught TypeError: Argument 1 passed to cs_phpmailer_init() must be an instance of PHPMailer, instance of PHPMailer\PHPMailer\PHPMailer given, called in /home/2/h/hamarbilpleie/www/wp-includes/class-wp-hook.php on line 287 and defined in /home/2/h/hamarbilpleie/www/wp-content/themes/carservice/functions.php:298 Stack trace:
#0 /home/2/h/hamarbilpleie/www/wp-includes/class-wp-hook.php(287): cs_phpmailer_init(Object(PHPMailer\PHPMailer\PHPMailer))
#1 /home/2/h/hamarbilpleie/www/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array)
#2 /home/2/h/hamarbilpleie/www/wp-includes/plugin.php(551): WP_Hook->do_action(Array)
#3 /home/2/h/hamarbilpleie/www/wp-includes/pluggable.php(494): do_action_ref_array('phpmailer_init', Array)
#4 /home/2/h/hamarbilpleie/www/wp-content/themes/carservice/contact_form.php(280): wp_mail(Array, 'Foresp\xC3\xB8rsel fr...', 'F\xC3\xB8lgende henve...', Array)
#5 /home/2/h/hamarbilpleie/www/wp-includes/class-wp-hook.php(287): cs_theme_contact_form('')
#6 /home/2/h/hamarbilple in /home/2/h/hamarbilpleie/www/wp-content/themes/carservice/functions.php on line 298
Probably you are having a bug in Javascript. What you have to do is, open up the Developer Tools in your browser, then goto Console tab. You would find the error messages there. Copy that error and share it with us.
EDIT
I can see that there's a 500 Internal Server Error (based on the screenshot you provided) when the data is submitted to the server. What you have to do is, see if there's any error log created inside your server. It would have some information regarding what is causing the issue. Please share it with us. If you are not able to see it, please follow this: Debugging in WordPress
EDIT 2
It appears that you are having two issues in your theme's functions.php file. It's using one depreciated function and for the other probably because of old code. The line numbers are #261 and #298 (/wp-content/themes/carservice/functions.php). The easy would be to ask your theme developer to get it fixed for you. If you have the update available for your theme and plugins, make sure you update it. Kindly note that, if you have done any modifications on the functions.php file, instead of doing it in a child theme, those changes would be overwritten when you update the theme.
After some digging and discussion, I found out that the theme had not been updated for ages. But to find an update for this was not easy. For some reason, it did not automatically update from WP. But it is fixed now. Thanks for the tips and hints, guys.

Fix for the "The following theme is missing from the file system" error in Drupal 7

I keep getting this same error from bugsnag for my site, and I'm unsure how to fix it/why it's popping up in the first place.
User Warning · The following theme is missing from the file system: <em class="placeholder">Theme_Name</em>. For information about how to fix this, see the documentation page.
The theme that it claims it is missing is the only theme I have for the site and is the one it is currently using. Besides overloading my bugsnag reporting, it's not causing any issues. Is there a way to resolve this? I checked the documentation page and all the articles I found only refer to modules.
It's likely that the there is an old reference of Theme_Name in the systems table of your database.
You can look for the references that your Drupal instance is checking against by running this query:
SELECT name, status, filename FROM system WHERE type = 'theme' AND name = 'Theme_Name';
Find the reference that doesn't look quite right, preferably by the name of "Theme_Name", and delete it.
DELETE FROM system WHERE type = 'theme' AND name = 'Theme_Name' AND status = 0 AND filename = 'path/to/Theme_Name.info' LIMIT 1;
Once deleted, flush your Drupal caches.
Well this is embarrassing. The source of the problem was that I was adding an image using:
src="<?= drupal_get_path('theme','Theme_Name'); ?>/sites/all/themes/theme_name/img/image.png">
The first problem is that the theme name I was calling was using capitals when the actual theme was all in lower case. But to actually resolve the problem I changed the image call to:
src="<?= drupal_get_path('theme',$GLOBALS['theme']); ?>/img/image.png">
Unsure if this turns out to be the same problem others have had, but that's what fixed it for me. If you're getting this error I'd suggest double checking how your src's are being called. Thanks to everyone that answered/responded!

Errors in Drupal 7 - Trying to get property of non-object in taxonomy_overview_terms()

I would love to get some help here. I enabled the forums module which is part of Drupal core. When I go to add a container, I get the following error:
Notice: Trying to get property of non-object in taxonomy_overview_terms() (line 279 of D:\Development\drupal\sites\all\modules\taxonomy\taxonomy.admin.inc).
Notice: Trying to get property of non-object in taxonomy_overview_terms() (line 403 of D:\Development\drupal\sites\all\modules\taxonomy\taxonomy.admin.inc).
Notice: Trying to get property of non-object in taxonomy_overview_terms() (line 405 of D:\Development\drupal\sites\all\modules\taxonomy\taxonomy.admin.inc).
I have tried to delete the tables and reinstall the module. I have the same module enabled on another one of our sites (which is identical in structure). But I do not get these errors on it. Anyone know how to fix this?
Thanks!
FWIW I debugged a similar issue and found that the 'forum' vocabulary nav variable (forum_nav_vocabulary) was not set in my installation, and that just plain breaks things. In the forum module there are a number of calls to variable_get('forum_nav_vocabulary', ''), but unfortunately if it is not set, using an empty vid has not been properly catered for.
If you set it, make sure to use the vid and not the machine name (i.e. the number, not the name). You will need to do this with drush, via the db, or using devel module's variable editor.

Remove Drupal Commerce Empty Products

I am getting empty products in my views recently after the first few rounds of having a crawler import the data for the products. Unfortunately, after deleting all but two products that existed beforehand, These "empty" products still exist. I also made sure there were no extra variation types, and cleared the commerce_line_item table. Does anybody know where I can find and get rid of these nameless products?
Here is a photo for reference: http://i.imgur.com/bISsCmB.png [1]
I noticed this title (this product was created by the) was able to be selected and edited. This is the only title that shows up: http://i.imgur.com/xwZKRBJ.png
Unfortunately, after trying to edit it, this is the error I get: http://i.imgur.com/e0sbwsT.png
After running #Clive's script, I couldn't flush the cache and I received these errors:
Notice: Undefined index: label in entity_views_field_definition() (line 191 of /home/accuairt/public_html/profiles/commerce_kickstart/modules/contrib/entity/views/entity.views.inc).
Notice: Undefined index: search_api_views_fulltext in views_handler_filter->accept_exposed_input() (line 1260 of /home/accuairt/public_html/profiles/commerce_kickstart/modules/contrib/views/handlers/views_handler_filter.inc).
Notice: Undefined index: table in entity_views_plugin_row_entity_view->init() (line 20 of /home/accuairt/public_html/profiles/commerce_kickstart/modules/contrib/entity/views/plugins/entity_views_plugin_row_entity_view.inc).
SearchApiException: Unknown or invalid item type node. in search_api_get_datasource_controller() (line 1506 of /home/accuairt/public_html/profiles/commerce_kickstart/modules/contrib/search_api/search_api.module).
STATUS MESSAGE Operating in maintenance mode. Go online.
The website encountered an unexpected error. Please try again later.
I restored a backup from a few hours ago to get the site back where it was.
edit: 12/18 Still looking for an answer. There has to be a table I can clear to get rid of this information.
If you know for definite that all products without a title should be deleted you can try something like this:
$query = new \EntityFieldQuery();
$query->entityCondition('entity_type', 'commerce_product')
->propertyCondition('title', '');
$results = $query->execute();
if (!empty($results['commerce_product'])) {
commerce_product_delete_multiple(array_keys($results['commerce_product']));
}
It might be wise to inspect the results of the query before you run the delete function, just to make sure you're not deleting anything you want to keep by mistake.

"Undefined property: stdClass"

This error suddenly occurred when Pressflow was added to our Drupal installation. It is coming from a custom module that, prior to Pressflow seemed to work fine. After the addition of Pressflow, running Drush causes this error to display on screen.
The function that is identified as the source of the error looks like this:
function user_search_location_get(&$user) {
if (count($user->user_location_pref)) { // This line is causing the error.
return $user->user_location_pref;
}
// …
}
The error message is the following:
WD php: Notice: Undefined property: stdClass::$user_location_pref in user_search_location_get()
Short answer, in your custom module, you should check if that property exists before you count it. That, or make sure the $user object has that property before you use it.
if (isset($user->user_location_pref) && count($user->user_locaion_pref) > 0) {
return $user->user_locaion_pref;
}
While it is a little more work, when you start developing with notices turned on, you will find errors in your code that otherwise would have not appeared till later, and would have been more difficult to track down.
In your previous environment or install, the PHP error reporting was probably set to not show notices. While I recommend keeping notices on and making your code work with them, you can turn them off through the Drupal 7 UI. Configuration -> Development -> Logging and Errors. Then set the value to 'Errors and Warnings' ... Otherwise, you can set your error reporting level in your php.ini to report all except notices.
Note that Drupal 6 did not force notice reporting on, while Drupal 7 does. That prompts this type of question a lot.
If this is your only notice issue though, it makes more sense to just correct your custom module.

Resources