I can add only one rule to chain. Not much of a chain, is it ;) It could be UI problem, but hard to tell without investigation.

CommentFileSizeAuthor
#4 recursion_fix-2023429-4.patch1.37 KBhenrijs.seso

Comments

mkalkbrenner’s picture

Category: bug » support

Very strange. You entered a second rule, but it won't be saved?
Any error message in the watchdog?

henrijs.seso’s picture

Category: support » bug

I investigated little further, rules are saved but not displayed. I added multiple rules and only first showed up, then I started to delete and I could delete them all, but one by one. Once I delete rule, next one is shown, single in list.

I will test on clean install thou, site I am working on is far from that.

(Also didn't mean to change status back)

henrijs.seso’s picture

Status: Active » Closed (works as designed)

Ahh, I'm sorry, clean install works as designed. Oh, well, debugging ensues.

henrijs.seso’s picture

Status: Closed (works as designed) » Needs review
StatusFileSize
new1.37 KB

Well, site I am working on is an edge case, with Oracle database and stuff. There appears to be a problem on some environments where doing db_select multiple times (during recursion) overwrites results and only first result is processed. I managed to fix this problem by improving recursive function so that it works both on clean D installation and in my environment. It will split themekey_load_rules in two functions where db_select will always return just one level of results.

Please review and comment, I will check out other places where db_select and recursion is used, if any.

mkalkbrenner’s picture

I don't know if it's really a limitiation of the Oracle DB itself, but for me it sounds like a bug in the drupal oracle db driver. Which one do you use?

henrijs.seso’s picture

I was using Oracle driver 1.9 and updated to dev version. Problem persistent in both. I can get chain to work well in both oracle versions and clean install with mysql with patch only.

In fact I could get module to work with oracle with super small change, just adding clone before db_select, but that would make it broken on clean installs with mysql. This makes me think that it has something to do with this core bug https://drupal.org/node/1671848. Or not.

If you look at proposed patch, it makes code a little longer, but should not be hackish. Just using different recursion type (not an expert thou).

mkalkbrenner’s picture

Title: Only one rule can be added to Theme Switching Rule Chain » nested / recursive db_select() fails
Project: ThemeKey » Oracle Driver
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: Code / API » Code

ThemeKey stores a tree in table and uses this recursive function to load the tree:

function themekey_load_rules($parent = 0, $depth = 0) {
  $properties = array();

  $result = db_select('themekey_properties', 'tp')
    ->fields('tp')
    ->condition('parent', $parent)
    ->orderBy('weight', 'asc')
    ->execute();

  foreach ($result as $item) {
    $item->depth = $depth;
    $properties[$item->id] = get_object_vars($item);
    $properties = $properties + themekey_load_rules($item->id, $depth + 1);
  }

  return $properties;
}

As described in comment #4, this function fails using the oracle driver.
But it works since year for drupal 6 and 7 with MySQL.

I'm interested in your opinion and therefor shift that issue to the oracle driver issue queue.

For discussions about creating a workaround within ThemeKey I opened #2024915: rule chain storage refactoring.

aaaristo’s picture

In my opinion this should work... I think even the core does recursive db_selects for the menu system...

Could someone provide a testcase?

aaaristo’s picture

Status: Needs review » Postponed (maintainer needs more info)
henrijs.seso’s picture

I am interested in providing testcase. In what form would that be? Project I am working on has rather restrictive environment, but Ill do my best to help here.

aaaristo’s picture

may be a simple php file i can launch with "drush src test.php"
that makes a recursive query on some standard drupal table...

bohart’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (outdated)

D7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.

Everyone can apply the patches/suggestions above (not tested by the maintainers, tested by the community) to their D7 projects.
If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.

Thanks!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.