WPMu Development for Education

Making WPMU work in education, one hack at a time

Archive for January, 2010

Drupal vs. WordPress thoughts from Bates

Posted by Randy on 28th January 2010

Jay Collier at Bates ponders the strengths of Drupal and WordPress MU.  In my experience WordPress is quicker to get going with, and for most web sites it can rise to most any challenge.  And it is the king of multi-site installations.  Drupal has a steeper learning curve, but can better support needs such as a work flow-content approval path, or something less traditional, like a content repository system.  In meeting a business need the technology is normally the least important element — what are your goals, who is the audience, what do they need, etc. — those are the important questions.  Once you have those answers you go looking for a technology.  My advice?  Look at WordPress first — if it doesn’t do what you want, in a quick straightforward way, keep looking.  But in my experience that won’t happen very often.

Evaluating Drupal and Wordpress MU | Bates Web Communications

As part of our new Web Hub program — and in previous discovery projects (2008 | 2007) — I’ve been evaluating open-source content management software. Our two finalists are Drupal and Wordpress MU.

Displaying enterprise data — such as course listings and directory information — has been the greatest challenge in site architecture prototyping. Both software packages provide support for collections of
custom fields, but what’s important is determining the best repository for each type of data and how to present it on public-facing Web sites.

Related Posts

Posted in Data, Technology, Web, WordPress, content, content management, drupal, learning, management, project | Comments Off

Eye catching web sites: Harvard vs. Yale

Posted by Randy on 27th January 2010

Keep Your Graphic Designer on a Short Leash in this month’s Website Magazine suggests that elements such as wild background colors, garish text, visual embellishments (eye candy) and animation/video distract website visitors from important content.  In a case study of a redesign of the CREDO website they found an 84% improvement with a simplified design.  The case study used a new service called AttentionWizard.com which uses computer algorithms to approximate eye tracking studies of a web site.  The idea is these will reveal what point on the page the visitor’s eye should land on.  If it is what you want them to see — like a buy now button — bingo, you are doing well.  If their eyes don’t land anywhere, or on the wrong things it is time to make some adjustments.  I thought it would be fun to compare the Yale and Harvard main websites using the service.

First up Yale.  According to the article Yale’s website does earn extra points for its simple, white background, plain text and simple graphics.  But don’t start celebrating so fast.  The eye tracking study also doesn’t find anything that does grab attention.  There is some focus on the graphic, but the links on the left side don’t register too high, except for the about Yale:

Yale's landing page

Yale Attention Heat Map

Now for Harvard – strong black background, white text — low marks.  On the attention scale they do a little worse — again the image gets the most attention, but otherwise the eye wanders around the screen not really landing on any other focal point.

Harvard landing page

Harvard Attention HeatMap

It is not clear to me on either site what the key objective is.  And in fairness these sites have multiple objectives, mostly trying to give people a lot of options.  It might have been fairer to compare sites with clearer objectives, like a sales-orientated site.  But then I wouldn’t have been able to tweak the classic Yale/Harvard rivalry.  And I may be biased, but while neither site did great, I do think Yale finished with a slight lead.  Go Bulldogs!

Two notes on the article:  1) it is written by the CEO of SiteTuners.com, creators of AttentionWizard.  2) in my experience it is the client who wants the flashy, distracting eye candy.  Most graphic designers I’ve worked with have better taste than that (good article, bad title).   You can use AttentionWizard in a trial version — 1 upload/analysis per day.  Give it a spin on your favorite site!

AttentionWizard FAQ’s

The eye gazing path is represented by the numbered path shown on the AttentionWizard heatmap. The eye gazing path starts with the number 1 and follows in chronological order. The eye gazing path depicts the path that your users eyes will take when they first get to your page. Depending on the image submitted (full page or above-the-fold) the eye gazing path can differ significantly.

Keep Your Graphic Designer on a Short Leash – Website Magazine – Website Magazine

You were led down this path by your internal creative team or outside interactive agency. Because of the limitations of their unique perspective you have been forced to sacrifice conversions in the name of “coolness.” So, you have actually come to think that your baby is quite beautiful and have, in fact, grown very fond of it.

Related Posts

Posted in Design, PLE, Web, Yale, blog, content, mobile, video | Comments Off

OPACPress: Our Talis Incubator proposal

Posted by Joss Winn on 26th January 2010

Yesterday, I submitted a proposal to Talis under their Incubator fund. If successful, I would have the pleasure of working with Paul Stainthorp, E-Resources Librarian at the University of Lincoln, and Casey Bisson,  Information Architect at Plymouth State University. The bid is to develop an idea which I’ve posted about before, based on Casey’s work on Scriblio and our adventures with WordPress MU, in particular, JISCPress.

Anyway, rather than re-iterating the bid here. You can read it in full by clicking here.

Comments are very welcome. Thanks.

Related posts

Posted in Fun, Funding, Hacks, Libraries, OPAC, Open Education, Projects, WordPress, prototypes, talis, wpmudev | Comments Off

The Benevolence of the WP Community

Posted by andrea on 25th January 2010

Over the weekend, there was yet another awesome WordCamp over in Boston. I am still bummed we were unable to go. But! We followed along at home, and there was some great news.

WPcares was launched during the event to raise money for Haiti. The original goal was $1,000. Last I checked, it was over $3,000 and this will be matched in donations from

Wow. This is why I love the community SO FREAKING MUCH.

The WordPress Foundation was also launched.

The point of the foundation is to ensure free access, in perpetuity, to the projects we support. People and businesses may come and go, so it is important to ensure that the source code for these projects will survive beyond the current contributor base, that we may create a stable platform for web publishing for generations to come. As part of this mission, the Foundation will be responsible for protecting the WordPress, WordCamp, and related trademarks. A 501(c)3 non-profit organization, the WordPress Foundation will also pursue a charter to educate the public about WordPress and related open source software.

Please visit their site for more information.

And, visitors to site may have noticed the clean design over there. It is the new 2010 theme, which will be the new default theme for this year.

Update: there will be some important terminology changes. Dougal gives a rundown over here between sites and networks.

I’ll go into this in depth at a later date, when trunk gets more finalized.

Random Posts

 

© andrea for WPMU Tutorials, 2010. | Permalink | No comment | Add to del.icio.us
Post tags:

Need real genuine helpful support? MU Support.

Feed enhanced by Better Feed from Ozh

Posted in News | Comments Off

Class blogrolls: No sweat

Posted by Boone Gorges on 25th January 2010

Last week, in the post where I announced my new WPMU plugin Shared Blogroll, I briefly mentioned the use case that I had in mind, which was of course education-focused. Yesterday and today I did some more work on the plugin itself (MORE AJAX 4EVA) and some of the supporting players. I thought I’d spell it out a little more so that others could implement what is probably the coolest system for shared blogrolls on earth, or at least on WPMU, which amounts to pretty much the same thing.

The plugins

  • Shared Blogroll. This creates a widget that allows bloggers to embed a link category from any other blog on the system on their own blog.
  • Add Users Sidebar Widget. This plugin is already pretty great, as well it should be seeing as it’s written by good-looking Canadians. I made some edits to the plugin to make it a bit more flexible.
    1. First I removed the RSS box from the Add User widget. For most of my users, it’ll confuse; for all of them, it’ll be redundant, since they’ll all be using Wordpress blogs and thus will have feeds that are very auto-discoverable.
    2. As the plugin stands in the repository, links are automatically put into the blog’s default link category (or, if they’re using FeedWordPress, the FWP link category). For most users, that’s something unhelpful like “Links” or “Uncategorized”. I altered the plugin so that the blog owner can choose which link category the added links will be put into. As I’ll discuss below, I think that this will add a lot of flexibility to the way that the plugins can be used together. You can download the text of my modified version of Add Users Sidebar Widget here: add-link-sidebar-widget.txt. Save as .php before uploading – and make sure that you uninstall previous versions of the plugin before uploading, or you might get whitescreened to death.
  • Optional step. The default WP Links widget is set up so that you can’t select to display an empty category of links. As you’ll see below, I want to have instructors create a new category for their blogrolls, and I figured it’d be pretty confusing if they couldn’t create a sidebar widget corresponding to a link category until at least one student had posted a link (thus populating the category). So I wrote a little plugin that replaces the default Links widget with one that allows you to pick an empty links category. Drop this into mu-plugins: link_widget_allow_empty_cat. Be warned, though, that this plugin deregisters the default Links widget, which might have the effect of removing every links widget on your installation of WPMU. (I haven’t tested it.) For me, it’s OK, because I don’t have any active users yet. As an alternative, you could edit the core of WP (making sure to back up, take note of where you made the edit for future upgrades, blah blah blah) in the following way. In wp-includes/default-widgets.php, line 139 reads
    $link_cats = get_terms( 'link_category');

    Replace it with

    $link_cats = get_terms( 'link_category', 'hide_empty=0');

    That should leave all of your pre-existing links widgets in place.

The process

The immediate goal of this setup is to allow a class blogroll to be shared effortlessly between members of a class. (Though I can imagine lots of other very cool uses.) Here are the directions I’m going to give to instructors and students on how to leverage these two plugins to make it happen.

Instructors

  • Create a new Link Category for your class blogroll – let’s say you call it “ENG 110 Blogroll”.
  • Add a Links widget to the sidebar, making sure to select “ENG 110 Blogroll” from the category dropdown.
  • Add an Add Links widget to the sidebar. Again, be sure to select “ENG 110″ blogroll as the target category for added links.
  • Give your blog’s ID number to your students and give them the following directions.

Students

  • After creating a blog, visit the professor’s blog and enter your site’s URL into the Add Link sidebar widget.
  • Add a Shared Blogroll widget to your own blog’s sidebar. Enter the professor’s blog ID number as the source blog, select “ENG 110 Blogroll” from the dropdown list, and Save.

I hope that the instructors and students get into this blogroll sharing thing. It distributes what would otherwise be a huge amount of work for the instructor, or *worse yet*, for me.

Related posts:

  1. New WPMU plugin: Shared Blogroll
  2. Blog-specific email plugin for WPMU users
  3. Streamlining Group Blogs

Posted in Blogroll, WordPress, dev.wpmued, edtech, links, olt-ubc, plugin, wpmu | Comments Off

How not to run a technology department

Posted by Randy on 25th January 2010

In a recent InfoWorld article Bob Lewis offers a strategy to “the promised land, where IT is a strategic partner to the rest of the business, not a subservient order taker content to process work requests while accepting the blame for everything that goes wrong.”  Sound like a familiar problem?  He maintains that the common practice of treating technology services as an internal business treating other departments as customers in a fee for service relationship is at the heart of the problem.

This relationship puts the information technology (IT) professionals in the role of reacting to customer requests and working selfishly to maximize the charging potential of every opportunity.  Efficiencies that might reduce service requests across several customers also reduce charging potential for the IT units.  IT responds to individual customer needs and priorities are set by those units most willing or able to pay.  This all results to an us-vs-them mentality that rarely rewards the parties for considering wider, institutional opportunities and broader implications of technology decisions.  For instance if one department contracts with the central IT programming unit to build a web-based student application, and pays dearly for it, they will be disinclined to ‘give’ it to another deparment (why shouldn’t they pay too?) — and the IT unit builds the application to so specifically meet one department’s needs that it probably can’t be used by others without a lot of rewriting anyhow.  I speak from direct experience — this stuff really happens.

So what is the path to Mr. Lewis’ proposed promised land? When working with other departments IT directors “..say, ‘My job is to help you and the company succeed, ‘ followed by ‘Show me how you do things now.’  NOT ‘I know better than you’ but rather ‘let’s work together so I understand your needs and we can find a solution that works for everyone.’  The conversation starts by asking ‘how can we operate better” rather than a focus on simply delivering software and hardware infrastructure.  Technology planning is aligned with the overall strategic objectives for the organization.  Budgets priorities are set in the discussion over how the application of technology can help meet those objectives in an efficient, timely and cost effective way.  Sounds good to me.

Run IT as a business — why that’s a train wreck waiting to happen | Adventures in IT – InfoWorld

..the familiar litany that says CIOs should run IT as a business, meeting the requirements of its internal customers. This refrain has been endorsed by our holy trinity, too: analyst firms, most consultancies, and ITIL… My advice? Don’t act like a separate business. Do the opposite — be the
most internal of internal departments. Become so integrated into the
enterprise that nobody would dream of working with anyone else.

Related Posts

Posted in Learn, LinkedIn | Comments Off

Bike sharing through community, emergence, technology

Posted by Randy on 25th January 2010

When we were in Paris last summer I was intrigued to see the fleets of Velib bikes.   These are available for public use across the city on a pay-as-you-go model.  You use a credit card at a central kiosk to check a bike out and then return it to the closest kiosk when you are finished with it.  With my frequent daily walks around New Haven CT and the Yale campus it looked like a sure hit to me.  I’d love to have this type of service available.  But it turns out, similar to Amsterdam’s white bike experiment, the Velib program is having problems with theft and damage.  Another problem with these types of systems is often one of distribution — problems arise with too many bikes at the wrong place, and too few at a hot spot.  These patterns shift through the day.  Maybe there are some lessons from ZipCar, and its successful strategies.   They encourage community feedback, keep it simple, invest in technology, and brand with personality.  To this I wonder if the bottom-up ideas of people like Mark Gorton might help point in the right direction.  Here is my quick brain-dump/brainstorm of thoughts on the subject of a community bike sharing service:

  • Simple community – have a membership plan similar to ZipCar’s.  Only members can use bikes.  Make the check out kiosks much simpler, or even eliminate then all together with some type of on-bike locking mechanism.  Lock/unlock would be via cell phone.
  • Reservation only — again like ZipCar any bike use requires an advance reservation, which could be made weeks in advance or on a recurring schedule (think commuters.)  Of course reservations could be made on-the-spot if a bike was available, also like ZipCar.
  • Commuters — have a special membership plan for commuters where they take the bike home at the end of the day.  This assumes the greatest need for bikes is downtown, during the day.  This gets the bikes off the street at times when vandalism and theft are more likely to occur, and gets members more empowered to help the system.  It also helps with distribution.
  • Personality – let members name a bike and then share that information with their friends.  When a friend uses that bike they would be shown the friends name and the name of the bike.
  • Sponsors — let building owners, businesses, universities, and other downtown organizations sponsor bike racks.  And if they had a pre-existing concentration of members in a locations these racks might even be allowed at internal, more private locations.
  • Friends — link accounts with Facebook.  In addition to naming bikes also let friends share bike use information with other friends.  For instance when I reserve a bike the system would tell me if any of my friends has used the same bike in the past.
  • Advocacy — maybe the bike company operates as a service, with local community bike advocacy non-profit organizations handling the physical maintenance chores on the ground.  The local group manages local services and gets a fee for that.  But they also advocate for things like bike lanes and communicate with a membership base, both of which are needed to make the service successful.

So what are we waiting for?

How Fast Can This Thing Go, Anyway?

… it’s hard to argue with results. Over the past five years, Griffith has transformed Zipcar from promising start-up into a real force. Revenue has soared from $2 million to $100 million. In November, the company acquired its largest rival, Flexcar. Zipcar has about 200 employees, it has raised $35 million in venture capital, and it has a growing international presence. How did he do it? Here is Griffith’s game plan–a seven-point strategy for turning a great idea into a thriving company

French Ideal of Bicycle-Sharing Meets Reality

“For a regular user like me, it generates a lot of frustration,” she said. “It’s a reflection of the violence of our society and it’s outrageous: the Vélib’ is a public good but there is no civic feeling related to it.”

White bicycles and the politics of consumption

The news that the Paris city bike scheme Velib is having problems with theft, even if over-stated, marks a throwback to the first “free bicycle” scheme, introduced in the 1960s by the Amsterdam Provos …who donated 50 bikes to the city to start the scheme off. Their scheme caught the public imagination – even prompting a cult single – only for the bikes to be confiscated by the police because they constituted an invitation to theft. Embedded in their story is a story about the role of failure in social innovation – and another one, about a politics of consumption.

5

Posted in Lifestyle | Comments Off

Deleting old MySQL tables across blogs and databases in WPMu

Posted by Reverend on 25th January 2010

OK, so this will probably be the final installment of my “pimp your WPMu databases” series :) Part one was moving from WPMuDEV’s Multi-DB package to SharDB; part two dealt with optimizing tables across a number of databases in MySQL, and the final installation will share some SQL code, once again thanks to Gowtham, for deleting specific tables across various blogs and databases.

Ok, so here is the setup, when we started UMW Blogs we used the spam filter Spam Karma 2. It was a personal favorite of mine, and while a lot more work than Akismet, it did a pretty good job of shutting out spam. Spam karma 2 has since died, and we moved to Akismet well over a year ago now. However, for at least the first 500 or 600 blogs (maybe more) we had Spam karma 2 installed, which inserted two tables into each blog kinda like this:
wp_21_sk2_logs
wp_21_sk2_spams

Where 21 was the blog ID, so across numerous blogs and databases there are a number of blogs with two fields like those above (just a different blog ID number, say wp_581_sk2_logs) filled with spam. It would make sense to drop these tables out as part of an optimization of our databases, but the only question I had was how?

Well I went to Gowtham, the oracle, once again (I hope this well of riches doesn’t go dry for overuse :) ) and he sent me the following script for deleting all tables with _sk2_ in the name. Now I imagine very few folks have this specific issue with Spam Karma 2, so the details of this script may seem irrelevant. But if you think about it, if there is a plugin that inserts tables on numerous blogs spread across various databases, and an uninstall of that plugin doesn’t delete the tables, then such a script would be quite useful to you. Just change the list of databases from my specific setup to yours and instead of the following bit of code:
$sql_q = "SHOW TABLES LIKE '%_sk2_%'";

Put a unique series of characters between the ‘%_uniquecharacters_%’ to delete a series of tables across blogs and databases.

How freaking cool is this? I tested the script on UMW Blogs, and it worked beautifully, UMW Blogs databases just lost another half a gig of spam fat, and I’m am happy to say it’s never been healthier. No heart disease in the future of this WPMu install—though we can never rule out plugin cancer :)

Here is a text version of the script.

And here it is sans the opening and closing PHP calls:

# PHP script to find all tables, whose name contains
# the string '_sk2', in a given set of MySQL databases
# and delete them. This is a 2-step process.
# Run this script as
#
# php mysql_skarma.php > mysql_skarma.sql
#
# Then, run the following command in a terminal
#
# mysql -u USERNAME -p < mysql_skarma.sql
#
# and enter PASSWORD when prompted.
#
# First written: Gowtham, Mon, 25 Jan 2010 08:01:48 -0500
# Last modified: Gowtham, Mon, 25 Jan 2010 09:20:22 -0500

# Connect to the database
# It is expected that you will be able to connect
# to all your databases [listed below] with this
# set of credentials
$host = 'localhost';
$dbuser = 'username';
$dbpasswd = 'password';

# The act of connecting to the MySQL server
$connect = mysql_connect($host, $dbuser, $dbpasswd) or
die('MySQL Connection Error: ' .
mysql_errno() . ': ' .
mysql_error());

# List of databases
$databases = array(
"umwblogs_wpmu_0",
"umwblogs_wpmu_1",
"umwblogs_wpmu_2",
"umwblogs_wpmu_3",
"umwblogs_wpmu_4",
"umwblogs_wpmu_5",
"umwblogs_wpmu_6",
"umwblogs_wpmu_7",
"umwblogs_wpmu_8",
"umwblogs_wpmu_9",
"umwblogs_wpmu_a",
"umwblogs_wpmu_b",
"umwblogs_wpmu_c",
"umwblogs_wpmu_d",
"umwblogs_wpmu_e",
"umwblogs_wpmu_f",
"umwblogs_wpmu_global",
"umwblogs_wpmu_vip1"
);

# FOREACH_LOOP_DATABASES BEGINS
# Loop through the array, 'databases'
# Each array element will be stored in the variable 'database'
foreach ($databases as $database) {

# Connect to the database using details specified
# above - it expects that there is one username-password
# combination that can connect to all your databases
mysql_select_db($database, $connect) or
die('Database Connection Error: ' .
mysql_errno() . ': ' .
mysql_error());

# Select all tables from 'database' that have '_sk2_'
# in their name
$sql_q = "SHOW TABLES LIKE '%_sk2_%'";
$result = mysql_query($sql_q) or
die('Invalid Query: ' .
mysql_errno() . ': ' .
mysql_error());

# WHILE_LOOP BEGINS
# Loop through the list of tables from 'database'
while ($table_details = mysql_fetch_row($result)) {
$table_name = $table_details[0];

# SQL query to DROP the table
# This will be written out to a flat text [SQL] file
# to be imported into MySQL. This is necessary because
# tables with an underscore in their names cannot be
# directly deleted from PHP [to my limited knowledge]
print "DROP TABLE `$database`.`$table_name`; \n";
}
# WHILE_LOOP ENDS

}
# FOREACH_LOOP_DATABASES ENDS

# Close the connection
mysql_close($connect);

Posted in MySQL, UMW Blogs, devwpmued, wordpress multi-user, wpmu, wpmudev, wpmued | Comments Off

Changing the Oil on a Multi-Database WPMu Install

Posted by Reverend on 24th January 2010

And to build on my last post about Moving from Multi-DB to SharDB on WPMu, here is a rundown on some of the work done to further optimize the multiple-databases for our WPMu at UMW Blogs.

First off, we have a plugin install called WordPress MU Sitewide Tag Pages that basically republishes every public post from around UMW Blogs into one blog, the tags blog, which is located at http://tags.umwblogs.org. This plugin has a ton of uses for us, not least of which is sitewide tags and categories, as well as feeds off those sitewide tags and categories for syndication and republishing into course sites. Another function of this blog could be a searchable archive of all the public work done. So, needless to say, this blog is important enough that we have let it run now for almost two years without pruning. And when I checked the wp_posts table of this blog in the database there was what seemed to be 99,066 posts.

And that one table was weighing in at a hefty 425 MBs, which mean it was out-of-control, and I imagine some of our recent performance and down time issues might be related, so I decided to cull this table. So after backing it up, I tweeted looking for advice on how I might delete all posts from the tags blog before a certain day, say August 15, 2009—the week before the Fall semester started this year.

And in no time at all, Michigan’s finest, Gowtham (and sgowtham on Twitter) sent me the following bit of code:

DELETE FROM wp_posts WHERE post_date < "2009-08-15";

Along with the note, “please be sure to replace the right table name in place of wp_posts though.” Which would like like this for the tags blog with the ID 1291:

DELETE FROM wp_1291_posts WHERE post_date < "2009-08-15";

So I just copy that bit of SQL code into the PHPMyAdmin editor that lets you run SQL queries for a specific database like so…

And within a minute 66,000 posts were removed, and the table was now 142 MBs.

Now, let’s stop here for a second. How sick is that? Within minutes I got a solution to my issue and deleted 66,000 posts and potentially saved UMW Blogs a couple of more crashes this coming week, from a friend on twitter who just knew what to do. How much richer am I because of this relationship? How much richer is all of UMW? It’s kinda wild to think about that. And more than that, it doesn’t stop there….

When I removed those 66,000 posts the size of the table was still showing 425 MBs, but there was now a value in overhead column of the table that had a value of 140 MBs. I had o idea how to get rd of this, so asked again in Twitter, and D’Arcy Norman tweeted me back this:

He was right, optimizing the table brought the 425 Mbs down to a slender 140 MBs, and the overhead value was flushed clean. So this got me thinking, hmmmm, what if I could run a script and optimize every table in every database? I mean this site has been running non-stop for almost three years, and has been a work horse. How about giving UMW Blogs an “oil change”—to use Gowtham’s analogy which works beautifully. So, when I tweeted about that optimization question, Gowtham once again sent me a message, and after I gave him the naming conventions of my 18 databases on UWM Blogs, wham, I had a PHP script to optimize every table in UMW Blogs.

People, are you getting the point here? Gowtham is an Engineering Physics grad, a hell of a photographer too, but he knows his shit. And he was willing to share that will me in all of about a few minutes the first time. But for the optimization script, he actually wrote it up and sent it to me via email. I don;t know how long that took him, but it would have taken me hours and hours of research and learning to figure out I could do it. And hours more to beg someone who knew at UMW to write it for me (if that person existed). Well, this process was a matter of minutes.

And, Gowtham not only sent me the SQL Optimization script, but was more than cool with me sharing it, so here is the code to the script as a txt file.

And here it is copied below sans opening and closing PHP calls.

# PHP script to optimize each table in a given set
# of MySQL databases and improve the overall performance.
# First written: Gowtham, Mon Feb 27 09:33:01 EST 2006
# Last modified: Gowtham, Sun, 24 Jan 2010 13:01:58 -0500

# Connect to the database
# It is expected that you will be able to connect
# to all your databases [listed below] with this
# set of credentials
$host = 'localhost';
$dbuser = 'USERNAME';
$dbpasswd = 'PASSWORD';

# The act of connecting to the MySQL server
$connect = mysql_connect($host, $dbuser, $dbpasswd) or
die('MySQL Connection Error: ' .
mysql_errno() . ': ' .
mysql_error());

# List of databases
$databases = array(
"umwblogs_wpmu_0",
"umwblogs_wpmu_1",
"umwblogs_wpmu_2",
"umwblogs_wpmu_3",
"umwblogs_wpmu_4",
"umwblogs_wpmu_5",
"umwblogs_wpmu_6",
"umwblogs_wpmu_7",
"umwblogs_wpmu_8",
"umwblogs_wpmu_9",
"umwblogs_wpmu_a",
"umwblogs_wpmu_b",
"umwblogs_wpmu_c",
"umwblogs_wpmu_d",
"umwblogs_wpmu_e",
"umwblogs_wpmu_f",
"umwblogs_wpmu_global",
"umwblogs_wpmu_vip1"
);

# FOREACH_LOOP_DATABASES BEGINS
# Loop through the array, 'databases'
# Each array element will be stored in the variable 'database'
foreach ($databases as $database) {

# Connect to the database using details specified
# above - it expects that there is one username-password
# combination that can connect to all your databases
mysql_select_db($database, $connect) or
die('Database Connection Error: ' .
mysql_errno() . ': ' .
mysql_error());

# Select all tables from 'database'
$sql_q = "SHOW TABLES FROM $database";
$result = mysql_query($sql_q) or
die('Invalid Query: ' .
mysql_errno() . ': ' .
mysql_error());

# WHILE_LOOP_OPTIMIZE BEGINS
# Loop through the list of tables from 'database'
while ($table_details = mysql_fetch_row($result)) {
$table_name = $table_details[0];

# Print a message to the screen - helps in debugging
echo "$database :: $table_name \n";

# SQL query to optimize the table
$sql_o = "OPTIMIZE TABLE `$database`.`$table_name`";
$optimize = mysql_query($sql_o) or
die('Invalid Query: ' .
mysql_errno() . ': ' .
mysql_error());
}
# WHILE_LOOP_OPTIMIZE ENDS

}
# FOREACH_LOOP_DATABASES BEGINS

# Close the connection
mysql_close($connect);

I put in the drop database sign-in information, uploaded it to UMW Blogs via FTP, and went to the script at http://umwblogs.org/mysql_optimize.php, and a few minutes later all of the tables in all 18 of the databases were optimized.

Is this not awesome, UMW Blogs has gotten the oil change it has been in desparate need of—and I don’t recommend waiting every 4,000 users and blogs, every 2,000 may be wiser. So, thanks to Gowtham, UMW Blogs is purring like a cat, and I really hope it stays that way.

And just to show you I have no shame, something else I saw when the databases were optimizing is that random blogs still have the Spam Karma tables in them, I would think about 500 or 600 blog tables filled with old spam. The tables are labeled wp_blogid#_sk2_logs and wp_blogid#_sk2_spams. For example: wp_21_sk2_logs and wp_21_sk2_spams. So riddle be this Batman of Gowtham, how would you find and drop all tables with _sk2_ in them across 18 databases?

I love the internet, and I can’t thank you enough Gowtham for your selfless support, people like you make this space both fun and wonder-filled.

Posted in MySQL, UMW Blogs, devwpmued, multiple databases, oil change, wordpress multi-user, wpmu, wpmudev, wpmued | Comments Off

Moving from Multi-DB to SharDB on WPMu

Posted by Reverend on 24th January 2010

In the early morning hours yesterday we moved UMW Blogs from multi-db (which is a multi-database setup provided through WPMuDev Premium at a cost) to the ever so free SharDB multi-db setup, and I’m happy to say it worked. We’ve had some “unscheduled downtime” recently at UMW Blogs, and between the ever-growing traffic and a syndication/tags blog that’s all too full with 99,000 posts—it was high time to start cleaning database house. This post will take you through the switch from multi-db to SharDB, which is surprisingly simple. And the following post will be about optimizing a multiple database setup that depends heavily on syndication like UMW Blogs does.

Multi-DB –> SharDB
So, our first step was to move to Ron Rennick’s (of wpmututotials and @wpmuguru fame) SharDB setup because UMW is no longer a subscriber of WPMuDEV Premium, and given upgrades to multi-db are no longer available to us—-we were eager to be rid of it. What’s more, I’m hoping this move to SharDB (accompanied by the database optimization and tags blog clean up) will bring UMW Blogs back to a snappiness we haven’t known for a couple of months now. So here’s to hoping….

When I downloaded SharDB I expected a lot more work than there actually was. The move is rather simple, and save a hiccup or two on my end, it went smooth as silk. The first thing to do is configure the db-settings.php file. UMW Blogs is running on 16 databases (well actually 18, but that is besides the point) on one dedicated server, we don’t have several servers or multiple data centers so I think our setup was rather simple. And while we probably should consider getting another server or two some time soon, as Joss Winn suggested, for right now we’re easy.

[What follows is pretty ugly :) ]

The UMW Blogs db-settings.php configs look like this:
// If you have multiple datacenters you can come up with your own datacenter
// detection logic (php_uname?). This helps ensure the web servers try to
// connect to the nearest database servers first, then distant ones.
define( 'DATACENTER', '' );

function add_slave($read, $host, $lhost = '', $user = DB_USER, $password = DB_PASSWORD) {
global $slaves;
$slaves[] = compact('read', 'host', 'lhost', 'name', 'user', 'password');
}

/* Add your configuration here */

//Use this configuration for a hexidecimal based hash

//Ex. you have 256 databases that follow the naming convention acct_wpmuXX
//where XX is the hexidecimal hash for the blog DB

// how many characters of hexidecimal hash
$shardb_hash_length = 1;
// what is the prefix of your blog database shards (everything before the hexidecimal hash)
$shardb_prefix = 'umwblogs_wpmu_';
// set a string to be used as an internal identifier for the dataset
$shardb_dataset = 'umwblogs';
// do you want to put your primary blog (blog_id 1) in its own 'home' database?
//$enable_home_db = true;
// how many, if any, VIP databases do you have?
$num_vipdbs = 1;
// add this to set the write master read priority (default 1)
//$shardb_master_read = 99;
// add this if all of your databases are on a local server
$shardb_local_db = true;
// use this function to add a read slave host
//add_slave($read_priority, $hostname, $local_hostname, $user, $password);

// instructions for adding vip blogs at the bottom of this confg filei

/* That's all, stop editing! Happy blogging. */

I wasn’t entirely certain about all the details in the config file, so before I did the upgrade I posted a few questions on the WPMu Forums here, and Ron himself bailed me (thanks Ron!). Once I had the db-settings file squared away I uploaded it to the main directory of UMW Blogs. After that, I added two lines to the wp-config.php file:

//SharDB Settings
define(‘WPMU’, ‘1′);
require_once(‘db-settings.php’);

And finally, I uploaded the dp.php file to the wp-content directory, and the shardb-admin.php file to the mu-plugins directory. (Keep in mind I had already deleted the db-config.php and db.php files that were running multi-db setup.)

Once I had everything up, I went to the homepage of UMW Blogs and got this error:

Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_domain_mapping’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)Connected to localhost:3306 but unable to select database ‘umwblogs_umwblogs’ while querying table ‘wp_site’ (global_r)No WPMU site defined on this host. If you are the owner of this site, please check Debugging WPMU for further assistance.

Turns out, multi-db does not require you to change the database name in the wp-config for the mutliple databases. so our database settings were still set to the original single database we started UMW Blogs on: umwblogs_umwblogs. Once I figure this out, I changed the db_name setting to point to our global database:
define('DB_NAME', 'umwblogs_wpmu_global');

Now this aneming convention is particualr to our setup, we have our tables named umwblogs_wpmu_global, umwblogs_wpmu_0, umwblogs_wpmu_1, umwblogs_wpmu_2, etc., up through 9, and then a through f. So our database names look like this:

umwblogs_wpmu_global
umwblogs_wpmu_0
umwblogs_wpmu_1
umwblogs_wpmu_2
umwblogs_wpmu_3
umwblogs_wpmu_4
umwblogs_wpmu_5
umwblogs_wpmu_6
umwblogs_wpmu_7
umwblogs_wpmu_8
umwblogs_wpmu_9
umwblogs_wpmu_a
umwblogs_wpmu_b
umwblogs_wpmu_c
umwblogs_wpmu_d
umwblogs_wpmu_e
umwblogs_wpmu_f
umwblogs_wpmu_vip1

Once I changed the db_name setting in wp-config, SharDB seemed to work fine on every other blog but the main blog: umwblogs.org. After a second of panic, I realized that SharDB was looking for the home blog (or Blog ID 1) in the database _wpmu_c, but I had it in the wpmu_vip1 database. Once I exported the tables from the wpmu_vip1 database into the wpmu_c database, everything worked perfectly. Put the question for me remains, why didn’t SharDB pick up the vip1 database? I had it noted in my db-settings file as follows:

// VIP DB's
if ($enable_home_db === true) {
add_vip_blog(1,'vip1'); // home blog
}

Additionally, when I was doing something in the backend, I came across this error:

Connected to localhost:3306 but unable to select database ‘umwblogs_wpmu_global’ while querying table ‘wp_sitemeta’ (global_w)

I can’t for the life of me remember where I was precisely now, but I’m sure I’ll find it again soon. I was wondering if this might have something to do with a number of global tables we added to the db-config.php file for getting BuddyPress to work with multi-db? Not sure here, kind of fishing for some help, but I know with multi-db we had issues adding global tables for BuddyPress to the global database (same goes for the domain mapping plugin table), and one way to ensure those tables were created in the global database was through the following list of code I stole from D’Arcy, and he breaks the whole thing down better than I ever could here. Now I imagine SharDB doesn;t have this issue, but just wanted to get a sense if anyone else playing with the move from MultiDb to SharDB had any ideas.

// Usage: add_global_table(TABLE_NAME)
// EX: add_global_table(’something’);
add_global_table(‘umwblogs_wpmu_global’);
// BuddyPress
add_global_table(‘bp_activity_sitewide’);
add_global_table(‘bp_activity_user_activity’);
add_global_table(‘bp_activity_user_activity_cached’);
add_global_table(‘bp_friends’);
add_global_table(‘bp_groups’);
add_global_table(‘bp_groups_groupmeta’);
add_global_table(‘bp_groups_members’);
add_global_table(‘bp_groups_wire’);
add_global_table(‘bp_messages_messages’);
add_global_table(‘bp_messages_notices’);
add_global_table(‘bp_messages_recipients’);
add_global_table(‘bp_messages_threads’);
add_global_table(‘bp_notifications’);
add_global_table(‘bp_user_blogs’);
add_global_table(‘bp_user_blogs_blogmeta’);
add_global_table(‘bp_user_blogs_comments’);
add_global_table(‘bp_user_blogs_posts’);
add_global_table(‘bp_xprofile_data’);
add_global_table(‘bp_xprofile_fields’);
add_global_table(‘bp_xprofile_groups’);
add_global_table(‘bp_xprofile_wire’);
add_global_table(‘wp_domain_mapping’);

Other than that SharDB is up and running on UMW Blogs, an given it may be one of the most unstable WPMu sites in the world give we have over 100 plugins and 130 themes, it has been solid as a rock thus far, so fine work Ron.. But to make sure we don’t push our luck too much, now it’s time for the database optimization drill, post forthcoming.

Posted in SharDB, UMW Blogs, WordPress, devwpmued, multi, multiple databases, plugin, wordpress multi-user, wpmu, wpmudev, wpmued | Comments Off