We got more than 50k terms and synonyms_get_term_by_synonym() is stacks on execution.

It should be refactored to something light, rather than using taxonomy_get_tree() and checking each term.

Comments

mrded’s picture

Status: Active » Needs review
StatusFileSize
new1.87 KB
mrded’s picture

StatusFileSize
new1.75 KB
AlexKirienko’s picture

StatusFileSize
new1.76 KB
new787 bytes

With patch #2 two error messages occurred on save term without synonym:

Warning: reset() expects parameter 1 to be array, null given in synonyms_get_term_by_synonym() (line 364 of /sites/all/modules/contrib/synonyms/synonyms.module).

Warning: Illegal offset type in isset or empty in taxonomy_get_term_by_name() (line 1230 of /modules/taxonomy/taxonomy.module).

Fixed patch with interdiff.

AlexKirienko’s picture

bucefal91’s picture

Status: Needs review » Needs work

hello!

You're very right about the function synonyms_get_term_by_synonym() being slow. I looked into the patch from #3 - you take the approach that I support (and any other clever programmer would too), you leverage DB for the search operation instead of letting PHP do the string search. But the patch is not ideal.

Since we have this abstract field independency feature in Synonyms module, we just do not know how the field stores (encodes) the synonyms in the DB. Your patch would work for the text field type, but it wouldn't for entityreference, for example, because the latter has different columns in its field, i.e. it encodes data in another way in the DB.

Before the end of the next week I'll extend your patch to work with any kind of field types.

bucefal91’s picture

Status: Needs work » Needs review
StatusFileSize
new61.15 KB

I have coded what I outlined in my previous comment. Please, review it. I've updated the synonyms_get_term_by_synonym() and updated the synonyms extractor interface. Then I also updated the tests to cover the new functionality. Lastly, I reorganized the tests so now they are executed faster.

devad’s picture

Hi

I don't know about speed improvments, but I have tested the patch and it applies nicely and as much as I have tested it didn't break any existing functionality causing new issues. Which is good. :)

mrded’s picture

Hi guys,

The patch #6 has to many changes, it's really hard to review. @bucefal91, can you please do your refactoring as a separate issue?

Thanks.

  • bucefal91 committed 84107c1 on 7.x-1.x
    Issue #2463541 by mrded, AlexKirienko, bucefal91:...
bucefal91’s picture

Status: Needs review » Fixed

Refactoring was done only within synonyms.test file, the rest of the patch is fully tied to this issue. As the patch has been there for over 2 weeks and we have at least 2 people supporting it (myself and devad), I've committed it into the module code.

mrded’s picture

Great, thanks! I've been using #3 patch for 6 months already, no problems so far.

Status: Fixed » Closed (fixed)

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