<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>corprewland &#187; drupal</title>
	<atom:link href="http://www.corprew.org/blog/tag/drupal/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.corprew.org</link>
	<description>(dis)information organization</description>
	<lastBuildDate>Fri, 19 Feb 2010 23:38:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>drupal and taxonomy</title>
		<link>http://www.corprew.org/blog/2008/04/17/drupal-and-taxonomy/</link>
		<comments>http://www.corprew.org/blog/2008/04/17/drupal-and-taxonomy/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 07:38:39 +0000</pubDate>
		<dc:creator>corprew</dc:creator>
				<category><![CDATA[computer programming]]></category>
		<category><![CDATA[acls]]></category>
		<category><![CDATA[bees]]></category>
		<category><![CDATA[cmses]]></category>
		<category><![CDATA[database hacking]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[drupal5]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[node-based-cms]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[organic systems]]></category>
		<category><![CDATA[simple solutions to complex problems]]></category>
		<category><![CDATA[taxonomy]]></category>
		<category><![CDATA[taxos]]></category>

		<guid isPermaLink="false">http://www.corprew.org/blog/2008/04/17/drupal-and-taxonomy/</guid>
		<description><![CDATA[Drupal 5 has a few problems in its security layer, as I&#8217;ve mentioned other places, and some of them stem from the sort of &#8216;it-works-for-me&#8217; philosophy of open source. This is particularly a problem in a complex system like Drupal, which in most installations is made up of a few dozen modules in addition to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.drupal.org/">Drupal 5</a> has a few problems in its security layer, as I&#8217;ve mentioned other places, and some of them stem from the sort of &#8216;it-works-for-me&#8217; philosophy of open source.   This is particularly a problem in a complex system like Drupal, which in most installations is made up of a few dozen modules in addition to the core.</p>
<p>The current issue I&#8217;m having is that nodes created by the aggregation module get their taxonomy stripped when they&#8217;re updated because of how another module uses the security functionality, which is just <em>hilarious</em> in a site that&#8217;s largely organized organically by taxonomy. So, after talking with the people I&#8217;m working for on the site, I ended up creating a simple PHP script to run through cron that fixes the issues &#8216;the hard way.&#8217;</p>
<p>If you check out this query&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> fix_object<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sqlcon</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT term_data.name name, term_data.tid termid, node.nid nodeid, node.title title FROM node LEFT JOIN term_node  ON ( term_node.nid = node.nid ) LEFT JOIN term_data ON ( term_data.tid = term_node.tid ) WHERE node.type = 'aggregation_item ' AND node.title LIKE 'Xxxxx &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;%'&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Perform Query</span>
  <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// ... and so on...</span></pre></div></div>

<p>You can see that this is a fairly normal sql query that looks for all the nodes of type aggregation_item and titled a particular pattern.  Because of the way the joins are structured, that means that any nodes that have lost their taxonomies will have NULL for termname and termid.  Those nodeids with NULL termids can then have the proper taxonomy entries stuffed back into them&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> insert_taxo_4_node<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$taxo_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO term_node (nid, tid) VALUES (&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$node_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;,&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$taxo_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// Check result</span>
  <span style="color: #666666; font-style: italic;">// This shows the actual query sent to MySQL, and the error. Useful for debugging.</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$message</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Invalid query: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$message</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Whole query: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I&#8217;m largely posting this up in case people run into the same problem &#8212; this is a hilariously simple fix for a difficult to fix problem in drupal, but it&#8217;s a generic information architecture issue of what to do when the system that you&#8217;re working on is unreliable.  I should probably mention that the issues with security in drupal aren&#8217;t related to authentication, but instead are related to item ACLs denying access to things for strange reasons, and are not crucial security bugs in the OMG MUST PATCH NOW sense.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.corprew.org/blog/2008/04/17/drupal-and-taxonomy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>oh, yeah, and&#8230;</title>
		<link>http://www.corprew.org/blog/2008/04/04/oh-yeah-and/</link>
		<comments>http://www.corprew.org/blog/2008/04/04/oh-yeah-and/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 20:27:21 +0000</pubDate>
		<dc:creator>corprew</dc:creator>
				<category><![CDATA[briefnotes]]></category>
		<category><![CDATA[bees]]></category>
		<category><![CDATA[bloom]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[embodied philosophy]]></category>
		<category><![CDATA[iphone dev]]></category>
		<category><![CDATA[macosx dev]]></category>
		<category><![CDATA[semantics]]></category>

		<guid isPermaLink="false">http://www.corprew.org/blog/2008/04/04/oh-yeah-and/</guid>
		<description><![CDATA[I&#8217;ve currently got about a half dozen small projects going of various sorts (but am always looking for more and/or an actual full time job given that ), but one group that&#8217;s been a real pleasure to work with for the last month or so has been the North Atlantic Bloom Project, I&#8217;m making them [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve currently got about a half dozen small projects going of various sorts (but am always looking for more and/or an actual full time job given that ), but one group that&#8217;s been a real pleasure to work with for the last month or so has been the <a href="http://bloom.apl.washington.edu">North Atlantic Bloom Project</a>, I&#8217;m making them a website that includes various features like maps, instrument data that populates into websites for site navigation and the like, and is based on drupal.</p>
<p>My current interests (this week) are macintosh development, semantics (RDF), embodied philosophy and category (Lakoff), drupal, iPhone development, good coding practices, and project lifecycle management (from soup to nuts.)  My interests next week will be getting a website off the ground that I unexpectedly ended up owning after a contract fell through.  That was suprising and not entirely pleasant, but will see what can be done to have matters turn out positively.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.corprew.org/blog/2008/04/04/oh-yeah-and/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>being liberal in what you accept &#8212; implementation interoperability semantics</title>
		<link>http://www.corprew.org/blog/2008/04/04/being-liberal-in-what-you-accept-implementation-interoperability-semantics/</link>
		<comments>http://www.corprew.org/blog/2008/04/04/being-liberal-in-what-you-accept-implementation-interoperability-semantics/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 19:35:30 +0000</pubDate>
		<dc:creator>corprew</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bloom]]></category>
		<category><![CDATA[conservative]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[implementation details]]></category>
		<category><![CDATA[interoperability]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[liberal]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[msft]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[property semantics]]></category>
		<category><![CDATA[rfc1122]]></category>
		<category><![CDATA[robustness]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[strcasecmp]]></category>

		<guid isPermaLink="false">http://www.corprew.org/blog/2008/04/04/being-liberal-in-what-you-accept-implementation-interoperability-semantics/</guid>
		<description><![CDATA[I&#8217;ve been working for the scientists over at the North Atlantic Bloom 08 as part o the team making their collaboratory. This project has mostly been based on Drupal, which is a content management system (in the web sense, not the ECM sense) based largely on PHP. One part of this is taking a lot [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working for the scientists over at the <a href="http://bloom.apl.washington.edu/">North Atlantic Bloom 08</a> as part o the team making their collaboratory.  This project has mostly been based on <a href="http://www.drupal.org/">Drupal</a>, which is a content management system (in the web sense, not the ECM sense) based largely on PHP.</p>
<p>One part of this is taking a lot of content over email &#8212; the scientists creating a lot of the content on the site are <a href="http://bloom.apl.washington.edu/content/map">in the middle of the North Atlantic</a>.  Because of this, I&#8217;ve been using the drupal module mailhandler for a lot of things that would normally be done directly through the site.</p>
<p>Basically, changing the comparison from <code>$data[0]=='taxonomy'</code> to a case-insenstive comparison:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">==</span><span style="color: #990000;">strcasecmp</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'taxonomy'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></div></div>

<p>allows users to send in messages and have their mostly unambiguous intention followed.  This is, in general, a good thing, and reflects the general net protocol practice of &#8220;be conservative in what you send, be liberal in what you accept.&#8217;  This is a general guide to good behavior and successful implementation and is generally called the <a href="http://en.wikipedia.org/wiki/Robustness_Principle">Robustness Principle</a>.  I advise everyone to check out <a href="http://tools.ietf.org/html/rfc1122">RFC 1122</a>, because it has many entertaining things to say about the nature of the Internet at the protocol level.</p>
<p>Anyway, so when you can actually figure out what the person meant to be doing, you should probably accept it.  This is a generic problem that pops up every now and then with computers.  Surprisingly often, it pops up with case sensitivity at the protocol level.  Here&#8217;s another <a href="http://markmail.org/message/hmhlvwq3bvlnqg36">moment for me with that same issue from about 7 years ago in Apache SOAP</a>:</p>
<p>I proposed changing it to:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> pds.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">==</span> propertyName.<span style="color: #006633;">compareToIgnoreCase</span><span style="color: #009900;">&#40;</span>pds<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
      <span style="color: #009900;">&#123;</span> 
        <span style="color: #000000; font-weight: bold;">return</span> pds<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getWriteMethod</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>from:</p>
</pre>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> pds.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>propertyName.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>pds<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
      <span style="color: #009900;">&#123;</span> 
        <span style="color: #000000; font-weight: bold;">return</span> pds<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getWriteMethod</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This does more or less the same thing, but is in Java.  This was a case where the apache implementation wasn't interoperating with the Microsoft implementation because the MSFT implementation had a different valid interpretation of the SOAP specification than the Apache server did.  Both implementations had completely reasonable behavior, but when the MS SOAP implementation responded to Apache, it did so with its own capitalization semantics (based on COM -- PropertyName) instead of the Apache SOAP capitalization semantics (based on Java -- propertyName).  So, this is an ongoing problem that keeps showing up again and again.</p>
<p>I appear to be destined to run into it and advocate for the robustness principle in every technology i use, apparently.  Either that, or it's just a slow day and I'm rambling.</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.corprew.org/blog/2008/04/04/being-liberal-in-what-you-accept-implementation-interoperability-semantics/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

