August 2007

Today’s Thought Bubble

Today’s thought bubble is about learning. Recently while studying sets, I found that I had confused the concept of the element of a set (denoted using ∈) and subsets (denoted using ⊂ or ⊆). It made me think that many of my moments of dawning understanding have been marked by the discovery of error.

In psychology, a most useful tool for studying the function of the brain is error. Visual illusions are used to study the functioning of the visual cortex. By tricking it we can tease apart its intricate workings.

So today’s thought is:

Can common errors be used to tease apart the process of learning?

Thought Bubbles

Comments (1)

Permalink

A fix for cat2email in WordPress 2.1 and above

Club Troppo, a site that I administer, relies on the cat2email plugin to post certain categories to interested users (there are lots). When I upgraded to WP 2.1, a lot of users began to complain that they were getting improperly formatted files. The headers would be something like this:

--===============2045766128707237696==
Content-type: text/html; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"

Obviously problematic, as many email programs would then render HTML mails as plain text. Hilarity ensues.

Well first off, there’s a tiny bug in the cat2email code. It should put out ‘Content-Type’, not ‘Content-type’. Fix this and you get a different set of incorrect headers:

Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hmm, still useless.

The culprit, it turns out, is WordPress. In 2.1 and 2.2, the wp_mail function was modified to use the PHPMailer class. If you crack open wp-includes/pluggable.php, you’ll see that the wp_mail function always forces conversion to plaintext. Pretty dodgy.

What it ought to do is check for custom headers and work with them. I’ve submitted a patch to the WordPress mob, and if you really need it, see below.

--- /Users/jacques/Downloads/wordpress/wp-includes/pluggable.php
+++ pluggable.php
@@ -187,7 +187,15 @@
$phpmailer->AddAddress("$to", "");
$phpmailer->Subject = $subject;
$phpmailer->Body = $message;
- $phpmailer->IsHTML(false);
+ if ( strstr( $headers, 'Content-Type: text/html' ) )
+ {
+ $phpmailer->IsHTML(true);
+ }
+ else
+ {
+ $phpmailer->IsHTML(false);
+ }
$phpmailer->IsMail(); // set mailer to use php mail()

do_action_ref_array(‘phpmailer_init’, array(&$phpmailer));

Update: Looks like a more robust fix is scheduled for WordPress 2.3.

Geekery

Comments (0)

Permalink

Today’s Thought Bubble

Inspired by sudden discussion in Australia of the relationship betwixt religion and politics:

I don’t mind politicians bring religion to parliament, so long as I can bring atheism to the voting booth.

Thought Bubbles

Comments (0)

Permalink