Drupal 7 Post Migration Clean Up

Drupal 7 Post Migration Clean Up

Tuesday, Aug 13, 2013
As a follow up to my previous post on Drupal 6 Post Migration Data Clean Up, I thought that a follow up for Drupal 7 would be useful. In this one I have also included the block_custom table for custom blocks, which seems to be a place I have overlooked before. Update links inside node body and custom blocks: UPDATE `field_data_body` SET `body_value` = REPLACE(`body_value`, "http://[temporary site]", "http://[new URL]"); UPDATE `field_revision_body` SET `body_value` = REPLACE(`body_value`, "http://[temporary site]", "http://[new URL]"); UPDATE `block_custom` SET `body` = REPLACE(`body`, "http://[temporary site]", "http://[new URL]"); Update links to files/images within nodes and custom blocks: UPDATE `field_data_body` SET `body_value` = REPLACE(`body_value`, "sites/[temporary site]", "sites/[new URL]"); UPDATE `field_revision_body` SET `body_value` = REPLACE(`body_value`, "sites/[temporary site]", "sites/[new URL]"); UPDATE `block_custom` SET `body` = REPLACE(`body`, "sites/[temporary site]", "sites/[new URL]"); Another useful place if you are looking for post migration is to rebuild your sitemap (using xml_sitemap) and clear all the caches. ...

Read more
Starting the Drupal Serial module from a certain number

Starting the Drupal Serial module from a certain number

Friday, Mar 15, 2013
Recently I have been building a ticketing system in Drupal, which allows logged in users to create support tickets and administrators to comment on them, change them between statuses and close them. All this is mainly done by controlling a content type, called tickets, which only administrators and the creators can see alongside enabling comments and firing a few Rules off to control notifying people of changes and changing between statuses. ...

Read more
Tuning MySql using mysqltuner.pl

Tuning MySql using mysqltuner.pl

Wednesday, Dec 5, 2012
There are lots of details online about how to create and edit web pages/sites and how to make things look pretty, however, there is a lot less about how to get things working nicely on servers be them development or live servers. Of course, hosting websites is maybe not something for everyone and certainly at Will Hall Online, my usual response may well be to get a server to run your website but if you are running a small website, with limited resource requirements, shared hosting can do a fantastic job. ...

Read more
Create An Output File From A SQL Query

Create An Output File From A SQL Query

Monday, Sep 10, 2012
Sometimes, keeping files as hard copy, or just being able to move things in and around using csv files or such like can be great. However, doing so when you don’t have access to a mysql client (like phpmyadmin) can be a bit tricky. Hopefully this script can help you out. Of course you can change things inside it to make a whole wealth of different files with different data inside it. ...

Read more
Updating embedded content from the database

Updating embedded content from the database

Tuesday, Aug 21, 2012
This is part 2 (or a re-visit) of a previous blog post (Drupal Post Migration Data Cleanup) on updating content after moving it to another domain . If you have your data inside a multisite, you probably have some embedded some images/files into node bodies (or such like) and want an easy way to replace all of the instances. OK great. Using the REPLACE function in MySql you can easily replace instances where the url for the files is wrong. ...

Read more
Drupal Post Migration Data Clean Up

Drupal Post Migration Data Clean Up

Thursday, Mar 31, 2011
Post migration data clean up, basically, most of the time when you develop a site you do it either under the default site of Drupal (sites/$new_url) or you do it under a different site (mynewsite.willhallonline.co.uk) with the intention of moving it to its own domain name when you have finished. Moving your data when you have finished on your new site is pretty easy. As most of the parts of your data are in the database, you can almost move to any file location and providing it is in the drupal root you will be fine! ...

Read more
Migration of Drupal Strings and Validation

Migration of Drupal Strings and Validation

Sunday, Nov 1, 2009
Just been hacking away at this to get the idea across of migrating and validating data from one database into the Drupal core (Drupal 6). It relies on the user having created a content type of news from CCK. <?php mysql_connect('localhost', 'user', 'password') or die('Cannot connect to MySql'); mysql_select_db('database') or die('Cannot connect to database'); // get the required data from the database $sql = 'select * from tableName'; $query = mysql_query($sql); // give it a timestamp $unixTimestamp = 1230800640; //starting unix timestamp $increment = 1012745; //could be replace by a rand() //beginning of the mysql insert sql queries $insertToNode = "INSERT INTO `node` (`nid`, `vid`, `type`, `language`, `title`, `uid`, `status`, `created`, `changed`, `comment`, `promote`, `moderate`, `sticky`, `tnid`, `translate`) VALUES "; $insertToNodeCommentStats = "INSERT INTO `node_comment_statistics` (`nid`, `last_comment_timestamp`, `last_comment_name`, `last_comment_uid`, `comment_count`) VALUES "; $insertToNodeRevisions = "INSERT INTO `node_revisions` (`nid`, `vid`, `uid`, `title`, `body`, `teaser`, `log`, `timestamp`, `format`) VALUES "; //get the total number of rows $totalRows = mysql_num_rows($query); $startNid = 3; // the first Node id (Nid) to be added $userUid = 1; // the id of the user (1 = admin) // create the insert queries while($result = mysql_fetch_assoc($query)){ // sanitise strings ready for insertion $headline = mysql_real_escape_string($result['headline']); $content = mysql_real_escape_string($result['content']); $snippet = mysql_real_escape_string($result['teaser']); // create looping additois to database $insertToNode = $insertToNode. ...

Read more