Being that it has these functions, and in places like node add pages it'll likely already used that function, maintaining own separate query/cache seems unideal. http://gyazo.com/fe4d98642cf76fd9c434f8a1075b29aa

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markus_petrux’s picture

Status: Needs review » Closed (works as designed)

Nope, this cannot be done. If CCK inners change, we can adapt with a patch, but we need a method to bypass content_types(). See the comment in function noderelationships_get_relationships():

/**
 * Build the list of node relationships on the system.
 *
 * This function is basically the heart of this module. We build the
 * list of all relationed content types by parsing all nodereference
 * fields.
 *
 * Non-standard requirement:
 * The 'referenceable_types' attribute of nodereference fields must
 * be populated explicitly by the user, regardless of the use of views
 * for nodereference widgets.
 *
 * We cannot use content_types() because we could be invoked while
 * the data content_types() generates is being computed.
 * Note that noderelationships_content_extra_fields() is invoked
 * by content_types() to process hook_content_extra_fields() and
 * noderelationships_content_extra_fields() needs the information
 * we generate here.
 * So we read field settings directly from database using the same
 * method as content_field_instance_read(), just focussing on data
 * we're interested in.
 */
function noderelationships_get_relationships($reset = FALSE) {

Please, re-open if there's any problem with the current code, but if not, I would not apply any patch here.

hefox’s picture

Title: noderelationships_get_nodereferences: Use cck's functions info instead of directly quering it's database for field info » Redo noderelationships_get_nodereferences so it doesn't query the database so much
Status: Closed (works as designed) » Active

Sorry, should have seen that.

What about a patch so just hook_content_extra_fields uses a function/query similair to current one, and node relationships in general uses ^?

Or perhaps add some caching? Actually, caching might be the best performance wise, as won't even need to process the data since it can just grab it.

From what I saw/recall, it's doing that query every node form, which doesn't seem that bad since it's just that node form, but on a heavy site with many users + a lot of content addition, it's becomes a problem.

markus_petrux’s picture

Honestly, due to lack of time, I'm not sure I'll be able to review such a change, because it is not trivial.

I'm setting the project status properly.