Avoid using create_function()

kiamlaluno - July 6, 2009 - 03:11
Project:Custom filter
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed
Issue tags:6.x-1.0-beta3, 6.x-2.0-beta1
Description

To use create_function() is not a good idea. First it gets called for each rule that uses PHP code as replacement text, even if the code is not actually used; second, it doesn't allow to cache the rules into a cache table.

It would be better to pass the code to eval() when it's strictly necessary, and to keep it as text until that moment. In that way, the rule array can be saved in cache, and this would help in reducing the number of queries executed (especially when most of the time they return the same result, until a rule is not changed).

To notice that the installation code already created a cache table that is only waiting to be used. I was already writing the code for that purpose (and the code was completed), but I had to fix some problems in the code, before to think of implementing that.

#1

kiamlaluno - July 7, 2009 - 02:14
Version:6.x-2.x-dev» 6.x-1.x-dev
Status:active» patch (to be ported)

The code has been changed, and must be ported to version 6.x-1.

#2

kiamlaluno - July 8, 2009 - 04:22
Status:patch (to be ported)» fixed
Issue tags:+6.x-1.0-beta3

#3

System Message - July 22, 2009 - 04:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.