[development] fixing broken nodes

Mukesh Agarwal mike4u4ever2001 at gmail.com
Tue Apr 20 10:19:32 UTC 2010


Try changing $node->uid.. The timestamps will have to change when you update
a node.. it is necessary for many modules to be identified of the change
like search and xmlsitemap

On Tue, Apr 20, 2010 at 3:43 PM, Lluís Forns <enboig at gmail.com> wrote:

> My problem right now is node_save itself: uid and timestamps are
> changed by node_save. Is there a way to avoid that? Or should I reset
> these fields with db_query("UPDATE ...")?
>
> 2010/4/20 Lluís Forns <enboig at gmail.com>:
> > This is the way I am following now. I hope my code will fix all the
> > "broken" nodes.
> >
> > 2010/4/20 Steven Jones <steven.jones at computerminds.co.uk>:
> >> Hi Lluís,
> >>
> >> You can use Drupal's Batch API to process large sets of objects like
> >> this. Documentation for the API is here:
> >>
> >> http://api.drupal.org/api/group/batch
> >>
> >> And it includes an example for iterating over all nodes.
> >>
> >> Hope that helps!
> >>
> >> Regards
> >> Steven Jones
> >> ComputerMinds ltd - Perfect Drupal Websites
> >>
> >> Phone : 024 7666 7277
> >> Mobile : 07702 131 576
> >> Twitter : darthsteven
> >> http://www.computerminds.co.uk
> >>
> >>
> >>
> >> On 20 April 2010 08:38:19 UTC+1, Lluís Forns <enboig at gmail.com> wrote:
> >>> I have some modules creating nodes calling directly node_save() and
> >>> now when trying to rebuild permissions table drupal fails at a random
> >>> node.
> >>>
> >>> I think this is caused because of some bad created nodes, and I thing
> >>> I have found a way to fix them; but it fail because of memory limit.
> >>> Is there a way to make node_load() not store nodes in cache? (I have
> >>> around 30k nodes)
> >>>
> >>> Thanks
> >>>
> >>> <?php
> >>> function mymodule_update_6008() {
> >>>  $ret=array();
> >>>  $res=db_query("SELECT nid, type FROM {node}");
> >>>  while ($row=db_fetch_array($res)){
> >>>    $prenode['type']=$row['type'];
> >>>    $prenode=(object)$prenode;
> >>>    $node_new=node_object_prepare($prenode);
> >>>    $node_old=node_load($row['nid']);
> >>>    foreach($node_old AS $key => $value) {
> >>>      $node_new->$key = $value;
> >>>    }
> >>>    node_save($node_new);
> >>>  }
> >>> }
> >>> ?>
> >>>
> >>>
> >>> --
> >>> *Les normes hi són perquè hi pensis abans de saltar-te-les
> >>> *La vida és com una taronja, què esperes a exprimir-la?
> >>> *Si creus que l'educació és cara, prova la ignorància.
> >>> *La vida és com una moneda, la pots gastar en el que vulguis però
> >>> només una vegada.
> >>> *Abans d'imprimir aquest missatge, pensa en el medi ambient.
> >>>
> >>
> >
> >
> >
> > --
> > *Les normes hi són perquè hi pensis abans de saltar-te-les
> > *La vida és com una taronja, què esperes a exprimir-la?
> > *Si creus que l'educació és cara, prova la ignorància.
> > *La vida és com una moneda, la pots gastar en el que vulguis però
> > només una vegada.
> > *Abans d'imprimir aquest missatge, pensa en el medi ambient.
> >
>
>
>
> --
> *Les normes hi són perquè hi pensis abans de saltar-te-les
> *La vida és com una taronja, què esperes a exprimir-la?
> *Si creus que l'educació és cara, prova la ignorància.
> *La vida és com una moneda, la pots gastar en el que vulguis però
> només una vegada.
> *Abans d'imprimir aquest missatge, pensa en el medi ambient.
>



-- 
Cheers,
Mukesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100420/f3fe4741/attachment-0001.html 


More information about the development mailing list