Description
---
The "computed field tools" module offers a way to re-compute the CCK computed fields
of existing nodes. It does so through the Batch API.

When using the Drupal module Computed Field (CCK) you sometimes make changes to
the logic behind the value in the computed field. If you wish to avoid re-saving
all nodes using the computing field, you can use this tool to re-compute all the
values again.

It is possible to choose which field (cross nodes) to re-compute and you can also
choose which node types you whish to re-compute.

When the batch is running it does not save the entire node again, but it only saves
the computed field.

---

Existing suggested patches which offers similar functionality does not take into account that when adding computed fields to other content types, it does not create entries in the split out table for each new node.

This is running on several live sites for Bonnier Publications and has run through 4 iterations in our local repository.

Link to project:
http://drupal.org/sandbox/frakke/1079758

CommentFileSizeAuthor
#1 computed_field_tools.png24.98 KBfrakke

Comments

frakke’s picture

StatusFileSize
new24.98 KB

Added a screenshot of the interface

avpaderno’s picture

Status: Active » Needs review
berdir’s picture

Status: Needs review » Needs work

Just some minor stuff...

- The title of the batch_set() operation title should be translated, see for example http://api.drupal.org/api/drupal/modules--user--user.module/function/use.... Something like t('Recomputing @field_name', array('@field_name' => $field['field_name'])).

- You don't need to call batch_process() in a form submit function, again, see the linked example above.

- "WHERE node.type IN (" . $types_string . ") "
You need to use the db_placeholders function: http://api.drupal.org/api/drupal/includes--database.inc/function/db_plac...

- db_query("UPDATE {" . $db_table . "} SET `%s_value` = '%s' WHERE `vid` = '%d'", $field['field_name'], $node_field[0]['value'], $result->vid);
I would recommend against using %s placeholder for anything else than actual values. This just works because Drupal 6 uses basic string search/replace to do the parameter replacement (in a secure way, of course). It will not work anymore in Drupal 7, where the replacement is actually done by the database. Also, you shouldn't use '%d' but just %d, the first won't work for PostgreSQL.

frakke’s picture

Status: Needs work » Active

Thank you for the comments.

I have fixed the issues you mentioned above:

  1. Title in the batch_set() operation fixed.
  2. Unnecessary call to batch_process() removed from form submit.
  3. db_placeholder(s) used instead of doing it the manual way.
  4. Wrong usage of placeholders in "db_query("UPDATE {" . $db_table . "} SET `%s_value` = '%s' replaced with the values from the $field, which contains all the needed info.
frakke’s picture

Status: Active » Needs review
sreynen’s picture

Component: new project application » module
Status: Needs review » Needs work

Hi frakke,

This looks good, but it seems like it may be more appropriate as a patch to Computed Field rather than a separate module. There are many open issues around similar functionality, e.g.:

http://drupal.org/node/195013
http://drupal.org/node/146608
http://drupal.org/node/924374

The code seems simple enough that it could be applied as a patch on one of these issues. Please set this back to "needs review" when responding to this.

frakke’s picture

Status: Needs work » Needs review

Hi sreynen,

It has a few issues regarding the taxonomies on the nodes and possibly other values as well not being in the same format when recalculating the nodes as when just saving the node (It loads the node when recalculating the field).
I think for now I prefer releasing it as a standalone solution since its not a re-calculate out of the box, but for the Drupal7 implementation I might suggest the patch to the computed field maintainers.

roball’s picture

Please approve this a a project - highly needed! And could you please change the .info file's package to "CCK" (currently it reads "Peytz & Co.")?

randomuser’s picture

+1

enxox’s picture

subscribe

roball’s picture

Priority: Normal » Critical

Sorry to push the priority to critical, but according to the Application Review Timelines given in Review process for Full Project Applications: What to Expect the priority should be raised to critical when an application is waiting for more than 4 weeks to be reviewed.

The feature this module is offering has been requested so many times in the mother's module issue queue - it's totally needed. I am using it since weeks without any problems. It does its job in a smart and speedy way. Adding this functionality into the mother module seems to delay progress significantly for now. This may be a goal for the wider future. Thanks for your considerations whoever will review this module.

rafamd’s picture

This is definitely a very useful thing and I think it should make it one way or the other. That being said, I'm +1 for this being part of the main computed field module, as it doesn't make sense as a stand alone one. Also, the maintainers seem to be open for this.

rafamd’s picture

(following my last phrase ...) So they could give you (frakke) commit rights I guess ...

roball’s picture

I agree in having this module included as a sub module of Computed Field itself would be the best for now, if the Computed Field maintainers agree to do that soon. Has there yet been made a request in Computed Field's issue queue?

rafamd’s picture

roball, I've just made the request in #1262820: Merge Computed Field Tools into Computed Field, Frakke feel free to close that issue if you don't like the idea.

frakke’s picture

Hi rafamd and roball.

Thnx for all the interest in this module. I don't mind, that you, rafamd, has taken it upon yourself to add the request :-)
This module has just been sitting here for soo long now. It has been used with no issues for about 1 year now at several sites, so I guess it could be ready to be part of the computed_field module - if they accept it.

beanluc made a few suggestions a few days ago, so I have made a small update to the code, adding a hook_help which basically just repeats the README.txt and I have added a note about nodes being in a different format when saving nodes and doing the re-computing.

rafamd’s picture

Thank you Frakke, and I'm glad you found it alright, let's see what the maintainers say over there :)

tim.plunkett’s picture

Priority: Critical » Normal
Status: Needs review » Postponed

I'm going to temporarily mark this as postponed on #1262820: Merge Computed Field Tools into Computed Field.

However, the maintainers seem to be absent of late, there is a chance you might need to follow the Abandoned Modules process.

LTech’s picture

Hi is anything happening with this module? I really need my computed field to update without re-saving the node. Are there any other options how to do this?

frakke’s picture

Hi LTech,

The module is ready for download on the sandbox page. I'm not sure if it is ever going to be approved as its own project (really don't know why... we could not have used computed field without it and I've seen many smaller projects) or as a part of the computed_field project.

But really, just download it and start using it. It just re-saves each computed field and is so much faster to use than f.ex. Views Bulk Operations...

frakke’s picture

Status: Postponed » Needs review

Mkay, no response from the computed field maintainers so I will try to re-open this issue for project approvement.

enxox’s picture

I need also a 7.x version of this module, i'm trying to update it but i'm not very friendly with drupal code and api...

LTech’s picture

That's great news! Where do I find the sandbox page?

LTech’s picture

I think I found the sandbox page http://drupal.org/sandbox/frakke/1079758. But I'm sorry I don't understand where the module is and how to download it?

sreynen’s picture

Relevant note from the patch thread:

Ok, so there is no response from the maintainers. I am personally not interested in taking over the entire computed fields project, so I guess in an attempt to move things forward, I will try to re-open my project application in the hopes, that it will get approved at some point.

I'm not sure the best way to resolve this. In the one hand, it would be best as a patch. On the other hand, it can't be a patch with no maintainer prepared to patch it.

While we work that out, frakke, you'll need to address the open bug before this can move forward either way.

frakke’s picture

Hi sreynen,

This (http://drupal.org/node/1140498) is not a bug. It's just the way it has to be for it to work. I have explained why in the tread and closed the issue :-)

sreynen’s picture

Status: Needs review » Reviewed & tested by the community

Great, thanks.

I'm marking this application as reviewed and tested. The code looks good and frakke has demonstrated a willingness to collaborate where possible. It's unfortunate that's not possible here, but getting an active maintainer for Computed Field is a bit beyond the scope of this review.

I'll leave this for someone else to actually approve, so others have an opportunity to disagree.

LTech’s picture

Hi Frakke, Thanks for this great module. Please can you explain how I can download it from the sandbox page. What do I do with git clone http://git.drupal.org/sandbox/frakke/1079758.git computed_field_tools ? Thank you.

frakke’s picture

Hi LTech,

It's rather well hidden. You need to go to the "Repository viewer" in the right column. Then click on the "snapshot" link on the latest version. This should give you a tar.gz file containing the module.

mlncn’s picture

Status: Reviewed & tested by the community » Fixed

frakke, you are now a vetted user, and can promote this to full project. If you feel the need to become a committer on computed fields (an occasional committer is better than a completely absentee maintainer), please ping me about that thread and access will be granted swiftly.

Clearly, people need to be able to easily download your module, and i'm sorry you had to serve as yet another reason there are strong moves now to make this application process faster and more automatic. Congratulations, and i look forward to your continued contributions.

Thanks to everyone and especially sreynan for review work and keeping this moving forward.

rafamd’s picture

If commit access (and project page edit permission) to computed field module is possible, maybe it's best to include computed field tools as a sub-module of computed field, stating that you (Frakke) are maintaining just that. Otherwise, we are unnecessarily bloating the (bloated :) ) contrib repo.

my 2c

rafa.

frakke’s picture

Status: Fixed » Closed (fixed)

Promoted to project.
Http://drupal.org/project/computed_field_tools

LTech’s picture

I'm using drupal7 so what should I do?

tim.plunkett’s picture

Status: Closed (fixed) » Fixed
LTech’s picture

Is there a way to update the node using drupal7? The computed_field_tools only has a drupal6 version.
Should I open a new issue?

sreynen’s picture

LTech, you should open an issue on the project asking for a D7 version. This thread should not be used for general support.

Status: Fixed » Closed (fixed)

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