Problem/Motivation

Variable Debug module helps spot some overly large variables.

These should be candidates for porting to a custom table (as to save loading them into memory on each page request).

This is on a commerce site and the biggest culprit is token module followed by the number of fields and entity types on the site.

Proposed resolution

Move this large variable table to a custom table so that it's not loaded into the memory of each request.

Remaining tasks

  1. Find out if we can just do the panel types and how this will affect panelizer
  2. Needs to be exportable (export/import hook).

User interface changes

API changes

Comments

joelpittet’s picture

Status: Active » Needs review
StatusFileSize
new3.21 KB

This patch is just a starter to get the ball rolling a bit.

Not sure if the scope should include '_default' values as well?

joelpittet’s picture

Issue summary: View changes
temkin’s picture

Here is a full patch based on joelpittet's initial version, plus interdiff. Could you guys review and let me know if anything is missing? Also, do we want to move "_default" variables to a table as well?

joelpittet’s picture

For now I think it's great to just do those ones, maybe a separate issue for those other ones. Thanks for pushing this further. I discussed this a bit with japerry a while back and I think he was keen on this.

temkin’s picture

Hey guys,

Just wanted to check if anyone had a chance to review this patch. I'm eager to get it into one of the upcoming module releases. Thanks!

sylus’s picture

The patch looks good and passed all tests for me. @joelpittet was there anything else you wanted to add before this patch can get RTBC?

joelpittet’s picture

I've not gotten to review it but if you have, feel free. There are some nitpicky coding standards to clean up, but otherwise yeah this looks nice.

joelpittet’s picture

Status: Needs review » Needs work

Reviewing the patch it looks well done. Just some little nits and picks to point at:

  1. +++ b/includes/common.inc
    @@ -272,7 +272,11 @@ function panels_common_settings($form, &$form_state, $module_name = 'panels_comm
    +    $allowed_content_types = db_select('panels_allowed_types', 'pat')
    
    @@ -368,9 +382,13 @@ function panels_common_settings_submit($form, &$form_state) {
    +  $allowed_types = db_select('panels_allowed_types', 'pta')
    +    ->fields('pta')
    

    One thing, it's 'pat' and 'pta', probably should keep this consistent.

  2. +++ b/includes/common.inc
    @@ -272,7 +272,11 @@ function panels_common_settings($form, &$form_state, $module_name = 'panels_comm
    +      ->fetchAllKeyed(1,2);
    

    spaces after comma but it would really be nice to know which keys are 1 and 2, any way we can be more specific without moving to db_query()?

  3. +++ b/includes/common.inc
    @@ -353,12 +357,22 @@ function panels_common_settings_submit($form, &$form_state) {
    +            "module" => $module_name,
    

    nit: single quotes

  4. +++ b/includes/common.inc
    @@ -353,12 +357,22 @@ function panels_common_settings_submit($form, &$form_state) {
    +      }
    
    +++ b/panels.install
    @@ -47,9 +47,44 @@ function panels_requirements_install() {
    +      'type_idx' => array('type'),
    

    I like this naming for indexes, clearer than I've seen in other places.

  5. +++ b/panels.install
    @@ -47,9 +47,44 @@ function panels_requirements_install() {
    +}
    +
    +
     function panels_schema_6() {
    

    nit: extra line break not needed.

  6. +++ b/panels.install
    @@ -492,3 +527,38 @@ function panels_update_7303() {
    +  }
    +  ¶
    +  // Read existing allowed settings and store them in a new table.
    

    nit: leftover trailing whitespace here.

  7. +++ b/panels.install
    @@ -492,3 +527,38 @@ function panels_update_7303() {
    +}
    \ No newline at end of file
    

    Missing a line break at the end of file.

temkin’s picture

Status: Needs work » Needs review
StatusFileSize
new7.18 KB

Thank you for a detailed review, @joelpittet. Here is a new patch that addresses those issues. I had to make more changes since the data scheme version has changed. Regarding your comments:

  1. 'pat'/'pta' - made it 'pat' to match 'panels_allowed_types' table name
  2. Replaced fetchAllKeyed(1,2) with fetchAllKeyed() since fields are explicitly set in ->fields('pat', array('type', 'allowed')) statement now
  3. Fixed double quotes in my code and a couple of other places. hope it's alright
  4. I inherited index naming from the piece that you created originally. No doubt you like it ;-)
  5. Fixed all the extra line breaks and trailing spaces
temkin’s picture

StatusFileSize
new7.18 KB

Not sure why test bot didn't pick the previous patch. Trying one more time.

joelpittet’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new46.72 KB
new35.77 KB

I inherited index naming from the piece that you created originally. No doubt you like it ;-)

LOL, touché

Testing with a different site:
Before patch:

After patch:

Mixologic’s picture

Status: Reviewed & tested by the community » Needs review

Pre drupalci patches had a hard time understanding that they are still patches. trying some more things.

Mixologic’s picture

StatusFileSize
new7.18 KB
temkin’s picture

It looks like tests are broken on D7 branch - https://www.drupal.org/node/74958/qa. Most likely they were disabled for automatic issue verification because of that.

Mixologic’s picture

Actually, looks like *panels doesnt have any tests*, so, doesnt much matter whether it runs or not.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Holly poop it doesn't. Another issue for that, back to RTBC

japerry’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/includes/common.inc
@@ -196,7 +196,7 @@ class panels_allowed_layouts {
     if (!is_null($this->module_name)) {
-      variable_set($this->module_name . "_allowed_layouts", serialize($this));

Shouldn't this be updated to the new db?

temkin’s picture

Status: Needs work » Reviewed & tested by the community

That's a good question. Right now the issue is specific to "_allowed_types" variable. On my site, that variable is 20 times bigger than "_allowed_layouts" and it has a potential to grow even bigger, while with layouts I'd say it won't grow much. Therefore it was decided to address only "_allowed_types" for now, unless "_allowed_layouts" is going to become an issue as well. Switching back to RTBC.

joelpittet’s picture

Leaving as RTBC. Re-roll due to schema changes in HEAD.

joelpittet’s picture

Heads up because this patch previously used the same panels_update_7305() this may have messed your instance up.

I just call panels_update_7305() again in panels_update_7306() to resolve this.

  • japerry committed fc2d524 on 7.x-3.x authored by joelpittet
    Issue #2479879 by temkin, joelpittet, Mixologic: Move '...
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Okay, we can tackle the allowed layouts later. This one is good. Committed.

geek-merlin’s picture

Status: Fixed » Active

>Find out if we can just do the panel types and how this will affect panelizer
Just tested. Panelizer allowed types also go into this table.

> Needs to be exportable (export/import hook).
This seems to have been forgotten here so that stuff is not deployable anymore. Reopening to discuss how and where to tackle this.

joelpittet’s picture

@axel.rutz oh because it was in the variables table before it was deployable through strongarm I'm guessing?

stephaneq’s picture

Hello,

This update deleted some variables added by other modules, for example media_wysiwyg_wysiwyg_allowed_types (from media_wysiwyg module).

Perhaps check if the variables start by panels_ or panelizer_ in the query?

joelpittet’s picture

Oh crap, wasn't expecting other modules to be using that but not for panels... namespace collisions!

Not sure if all the types are prefixed with panels_ or panelizer_ though... I think we need to look into the discovery method to get the list instead of wildcard, but couldn't spot the discovery method in a quick scan. Does anybody know where this is?

chris burge’s picture

Category: Task » Bug report
Priority: Normal » Major

@joelpittet - I think a discovery method is best. What we need as a starting point is a list of panelized entity types. Take a look at the 'panelizer_entity_view_alter' function. It calls 'panelizer_entity_plugin_get_handler' to check if there's a handler. If not, then it returns without doing anything.

For each panelized node bundle, I'm seeings two variables of interest. Take the 'page' node bundle for example: 'panelizer_node:page_allowed_types' and 'panelizer_node:page_allowed_types_default'.

Also, +1 on Features integration. Previously, this configuration was deployable through Strongarm. Currently, it's no longer possible to deploy or manage 'allowed types' configuration with Features.

Changing category and priority per https://www.drupal.org/node/45111#major-bug.

geek-merlin’s picture

for the upgrade hook deleting too many variables: i think we should have a fast solution for this because there are still some people out there that do not have their config in code thus lose work!

so while we seek the silver bullet we should either
a) remove the update hook immediately or
b) keep the pattern matching, but respect the namespace

My vote is that b) is enuff and we don't need more complex discovery. The main point is imho to get that information killer out immediately.

geek-merlin’s picture

> @axel.rutz oh because it was in the variables table before it was deployable through strongarm I'm guessing?

Yes indeed. This is a serious regression which seems to break our site after every deployment (which is strange and i did not have time to figure out why).

hanness’s picture

same issue here

chrisgross’s picture

+1 on features exporting. I feel that this commit should never have been released because it broke existing features integration, which is a huge deal. This has made me unable to deploy new changes to my content type features, and new sites that have been spun up since have no restrictions on allowed content.

chris burge’s picture

Issue tags: +Release blocker

The current recommended release of Panels is documented to break sites. It 1) deletes configuration of other modules, and 2) breaks Features-based workflows. Either of these should trigger a release.

I see two options: 1) Fix this issue and create a new release or 2) Revert the commit and create a new release.

chrisgross’s picture

Here's a patch to revert the new functionality while leaving the developed schema changes in tact. This should be enough for most people until the new stuff is actually fully complete.

geek-merlin’s picture

Priority: Major » Critical

#32
> The current recommended release of Panels is documented to break sites.

Indeed. so now qualifying as critical.

dsnopek’s picture

Issue tags: +panopoly

We're going to include the patch to revert in Panopoly

cboyden’s picture

The patch to revert in #33 leaves the update hook intact - so the allowed_types variables provided by other modules are still being deleted. It seems weird to change an update hook after the code has been released, but that seems like the only way to prevent data loss on sites that haven't upgraded to 3.8 yet.

cboyden’s picture

Status: Active » Needs review
StatusFileSize
new5.46 KB
new1.41 KB

So for the benefit of sites that have not updated to 3.8 yet, it doesn't make sense to revert/remove the code that uses the custom table instead of the variables, and leave in place the code that deletes the variables.

Also, if these sites are using Features or any other exportables, they won't want to start using the new custom table until there's a way to export the configuration in the table. So if the code is reverted to still use variables, there's not much point in running the variable-to-table conversion in update hook 7307. The data in the table will not be updated if configuration changes, the variables will be updated. When sites are ready and able to export configuration from the table, they'd have to run the conversion again.

So I think the revert should not only avoid deleting the variables, it shouldn't bother to run the data conversion either. Just create the table, and leave it empty until everything's ready. The data conversion + variable deletion can happen in an update hook that's released along with the ability to export this configuration.

I've attached a patch (and interdiff from #33) that removes that code from the update hook, leaving only the schema change, and adds a note about what happened.

dsnopek’s picture

Status: Needs review » Reviewed & tested by the community

The latest patch makes sense to me -- we're using it in Panopoly now. Marking RTBC!

geek-merlin’s picture

Makes sense, +1 for committing this soon.

  • japerry committed 8a117f1 on 7.x-3.x
    Revert Issue #2479879: Move 'panels_page_allowed_types' variable to a...
japerry’s picture

Status: Reviewed & tested by the community » Needs work

Yah, I agree. we need to revert this. Reverted. I've also marked this 'needs work' to the original issue.

dsnopek’s picture

Did you 'git revert' or apply the patch? The patch is probably better for bringing this back later, since some pepole have already updated

japerry’s picture

Yah I applied the patch, that included the note from cboyden in the update hook. Since it went out with 3.8 and had data changes, it seemed best to go that way.

dsnopek’s picture

Great, thanks!

attiks’s picture

Just discovered on a site, that people were seeing all possible blocks (allowed_types) when adding content, while checking the variables all were on default and all values where still available in {panels_allowed_types}. All updates were ran before installing 3.9

drush vget _allowed_types

panelizer_node:hr_space_allowed_types_default: 0
panelizer_node:hr_sector_allowed_types_default: 0
panelizer_node:hr_page_allowed_types_default: 0
panelizer_node:hr_operation_allowed_types_default: 0
panelizer_node:hr_bundle_allowed_types_default: 0
panelizer_node:webform_allowed_types_default: 0
panelizer_node:hr_dataset_allowed_types_default: 0
panelizer_node:hr_contact_allowed_types_default: 0
panelizer_node:hr_office_allowed_types_default: 0
panelizer_node:hr_toolbox_item_allowed_types_default: 0
panelizer_node:hr_funding_allowed_types_default: 0
panelizer_node:hr_disaster_allowed_types_default: 0
panelizer_node:acc_incident_allowed_types_default: 0