I enabled the module and taxonomy only. I added an HS component to a content type based on one taxonomy.
When I click on the component to configure it, I get this error:
PHP Fatal error: Call to undefined function db_rewrite_sql() in D:\inetpub\wwwroot\sevendevel\sites\all\modules\hierarchical_select\modules\hs_taxonomy.module on line 730

I noticed that this is the line to get the count with comments to convert to D7 api.

Comments

wim leers’s picture

Title: PHP fatal error. » HS Taxonomy: "entity count" support — sponsorship needed
Component: Code » Code - Taxonomy
Category: bug » feature
Status: Active » Postponed (maintainer needs more info)

"Entity count" support will only be added to HS3 if it gets sponsored (or contributed, of course). It will definitely be included in the rewrite of HS, HS 4.

wim leers’s picture

Possible solution in #1190028: D6 to D7 SQL Conversion. That issue was marked as duplicate of this one. Other duplicate issues: #1142264: same issue dont any 1 heregot the solution :(, #1206766: README text not yet updated for D7 port.

wim leers’s picture

Another duplicate was at #1107092: Fatal Error.

alexverb’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new14.61 KB

Well 5 years later... Here's an entity count patch for hierarchical select. It provides an entity_count setting that other modules can use to calculate the entity count. In this patch it's implemented for the hs_taxonomy module. Though you can only use this feature if you have the Taxonomy entity index module installed.

TODO's are:

  • Implement a caching mechanism so we don't have to do a large number of heavy queries each time we refresh the select. There will be plenty of $cid's generated. Maybe provide a caching table for it?
  • Clean up the variables needed for the entity_count() function. I don't really know why $params is seperate from $config.
  • Fix a #states visibility of entity count settings fieldset by replacing it with custom javascript. Don't think it's possible without knowing the parents.
  • Add query tags for node_access and entity_access. Probably not compatible with caching unless everything is being cached on user level.

On my computer it works fine. I need some testers :)

alexverb’s picture

Just removed the dependency on taxonomy_entity_index. With this patch it will work as well with cores taxonomy_index table. You now get a notice in the fieldset description saying the functionality is extendible to other entities by installing that module.

alexverb’s picture

@stefan.r, Gold, Wim Leers:

Could you give me an example of how to implement the New cache system: JS? I would like to have a look at it to see if I can avoid making expensive database queries for counting the entities. The clientside caching would be a perfect solution for this. And it would be a good alternative to actually creating a cache table in Drupal, which you already removed for reasons not known to me.

Once I know the ins and outs of the caching mechanism I would be happy to write a patch to implement that in 7.x-3.x.

Without caching the Entity count feature becomes rather handicapped once you get a decent amount of tagged entities.

alexverb’s picture

@stefan.r, I've looked at your remarks and handled those that I could.

  1. Write update hook:
    • I've checked where hook_hierarchical_select_entity_count was used in 7.x. But the hook usage was commented out from port 6.x to 7.x. See #1069382: HS Taxonomy: disable unported functionality So I guess there hasn't been any use of the old settings in 7.x. I guess it's safe to just move them to another place. If you don't like that though I have an update hook also. Check attached file.
  2. Inconsistency with API.txt, hs_menu, hser and internals.test:
    • Made all #config instances consistent with the new changes and updated API.txt
  3. References to term in common.inc:
    • Swapped all term references with $arg variables
  4. Integration for hs_menu and hser:
    • I don't see any use case for hs_menu.
    • Integration for hser could be a separate issue I'm willing to work on.
  5. Changes in parameters for hook_hierarchical_select_entity_count:
    • I've moved the required settings into the $params variable.
  6. Remaining TODO in patch:
    • #states functionality has been moved to common_config_form.js
  7. Security issue for checkbox labels:
    • Usage of check_plain is implemented.
  8. Simpletest case for feature:
    • Honestly this is above my paygrade. There are multiple test cases that require creating different entity types, vocabularies, taxonomy terms, fields, etc. I haven't done a lot of simpletests, so it could take me ages to write one for this feature.

I guess I've handled 6 out of 8 of your remarks. Maybe it's possible to create seperate issues for n°4 and n°8?

stefan.r’s picture

Status: Needs review » Reviewed & tested by the community

Looks OK to me

  • stefan.r committed 1360594 on 7.x-3.x authored by alexverb
    Issue #1068462 by alexverb: HS Taxonomy: "entity count" support —...
stefan.r’s picture

Status: Reviewed & tested by the community » Fixed

  • stefan.r committed 70be488 on 7.x-3.x authored by alexverb
    Issue #1068462 by alexverb: HS Taxonomy: "entity count" support —...
stefan.r’s picture

The update hook was not included in the patch, so committing that for the next beta

Status: Fixed » Closed (fixed)

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