How to update „changed” date for all nodes in Drupal 7 – the fastest way

[view:googlead_ia1]

The goal is to update ALL nodes „changed” or „updated” date with one SQL command. The reason behind this is called xmlsitemap. If you don’t have any update on a node, you’ll get something like „yearly” frequency in your sitemap for older nodes. What I really wanted was to refresh all nodes in a sitemap so that bots will see your nodes as fresh content. You can even fake it by adding something generic to all your nodes, and if you’re lucky it won’t look like spam. It’s actually not spam, if we’re talking about a new website. 

After 2 hours trying to run a query in phpMyAdmin without success (maybe some limitations, idk) I tried to run the same query in drush. Everything worked perfectly. So, for my own records, the following query updates all nodes as if they were all been modified within the last 7 days.

drush sqlq "UPDATE node SET changed = unix_timestamp('2017-03-28 01:00:00')-floor(rand()*604800)"

I don’t recommend running this query IF you care about node revisions. They’ll be out of sync. It’s just a fast and dirty trick to avoid loading drupal bootstrap for each and every batch set (if you were using VBO). Actually, it took 30 seconds to run this query over 5+ million nodes. Pretty cool, is it?

If you know a better method but as fast as this one, please share it in a comment.

[view:googlead_ia2]

LĂSAȚI UN MESAJ

Vă rugăm să introduceți comentariul dvs.!
Introduceți aici numele dvs.
Captcha verification failed!
Scorul utilizatorului captcha a eșuat. va rog sa ne contactati!

Acest site folosește Akismet pentru a reduce spamul. Află cum sunt procesate datele comentariilor tale.

- Advertisement -spot_img
Noutăți

Articole similare

- Advertisement -spot_img