In my project, I have to integrate my custom entities with apachesolr.
We're using https://www.drupal.org/project/entity_scaffold, but this could be done manually.

Its common that custom entities that were created to hold similar content end up with a similar reindex callback.
It would be a good idea to allow developers to assign a generic reindex callback for his project custom entities, therefore I suggest we pass the entity type as parameter to the reindex callback.

I'm uploading a patch with the change I've done to make it possible.

Comments

luizsgpetri created an issue. See original summary.

luizsgpetri’s picture

StatusFileSize
new2.33 KB
luizsgpetri’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: generic_reindex-2559213-2.patch, failed testing.

luizsgpetri’s picture

luizsgpetri’s picture

StatusFileSize
new2.33 KB

Patch

luizsgpetri’s picture

Status: Needs work » Needs review
luizsgpetri’s picture

Assigned: luizsgpetri » Unassigned
DeFr’s picture

Status: Needs review » Needs work

As written, this is going to break backward compatibility for all the existing reindex callback functions, which expect the second parameter to be an optional bundle parameter and not the entity type.

In apachesolr alone, to get this to work correctly, you'd need to change apachesolr_index_node_solr_reindex to take the newly added second parameter. But this also means that all of contrib would need to change, which seems quite wasteful.

That patch would be a lot less disruptive if the new argument is added at the end of the function.

luizsgpetri’s picture

Assigned: Unassigned » luizsgpetri
caminadaf’s picture

StatusFileSize
new1.87 KB

I've done the suggested changes and reapplied the patch against the latest 7.x-1.x branch and tested it with nodes and custom entities.

caminadaf’s picture

Status: Needs work » Needs review
luizsgpetri’s picture

Assigned: luizsgpetri » Unassigned
Status: Needs review » Reviewed & tested by the community
douggreen’s picture

Status: Reviewed & tested by the community » Needs work

I think that this is still going to cause problems with backwards compatibility. If someone already has a custom reindex function without the additional argument passed, and this were to call that function, PHP will complain about the additional argument. Please contact one of the module maintainers and work out the architecture for this. One suggestion I have is to add a new argument called 'reindex callback version' and check that, and only pass the additional argument if this is set to the new version.

As this is currently written, the additional argument needs to be added to the apachesolr_index_node_solr_reindex doxygen.

caminadaf’s picture

@douggreen,

I just realized that PHP doesn't actually sends errors or notices when a function receives additional parameter. Instead, it allows it so that we can define function with a variable number of arguments.

So if a custom module is expecting only two parameters and we send 3, it won't make a difference, since we didn't change the order of the parameters.

caminadaf’s picture

Status: Needs work » Reviewed & tested by the community
douggreen’s picture

interesting, agree. I tested the argument error/warning locally. RTBC from me too.

  • japerry committed e244705 on 7.x-1.x authored by caminadaf
    Issue #2559213 by luizsgpetri, caminadaf, douggreen: Allow developers to...
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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