Problem/Motivation
Currently, _block_rehash()
writes to {block}
far more often than it has to. Recently, we ran into issues caused by an excesses number of UPDATE {block}
queries being run on cron run or a cache-clear. I traced this back to _block_rehash()
.
Proposed resolution
_block_rehash()
begins by comparing what is in {block}
to what is defined in modules' hook_block_info
. By comparing the results of the {block}
query to what is defined in hook_block_info
before attempting to write to {block}
, we can avoid a large number of the UPDATE {block}
queries. A simple if
wrapper around the drupal_write_record
prevents the excess number of UPDATE {block}
queries.
NOTE: _block_rehash()
has been re-architected in D8 and this same issue is not present there.
Comment | File | Size | Author |
---|---|---|---|
#4 | block-rehash-if-2041107-4.patch | 570 bytes | iamEAP |
#1 | block-rehash-if-2041107-1.patch | 569 bytes | ultimateboy |
Comments
Comment #1
ultimateboy CreditAttribution: ultimateboy commentedComment #2
iamEAP CreditAttribution: iamEAP commentedThis is a way saner approach than what I had in mind here #1693336: Block rehashing happens on every cron run, which I've marked as a dupe.
#1 gets a +1 from me.
Comment #4
iamEAP CreditAttribution: iamEAP commentedJust to rule this out...Thought so. Array comparison in PHP can be tricky; I believe the double-equals checks type AND keys AND values AND order. This could result in db updates if (for whatever reason) a hook_block_info implementor changed the order of its keys, but that would be pretty edge-case; this should still drastically reduce the number of updates performed.
Comment #5
iamEAP CreditAttribution: iamEAP commentedPer a quick discussion on IRC, it would appear as though this actually doesn't have the desired effect.
Bumping back to "needs work."
Comment #6
ultimateboy CreditAttribution: ultimateboy commentedMarking as a duplicate of #1693336: Block rehashing happens on every cron run as it has a substantially better patch and roughly solves the same problem.