<?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>Spice World! &#187; Wordpress</title>
	<atom:link href="http://www.cyberspice.org.uk/blog/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cyberspice.org.uk/blog</link>
	<description>The life and times of a jet setting software engineer!</description>
	<lastBuildDate>Fri, 02 Dec 2011 14:52:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Talk: Introduction to WordPress Plugins</title>
		<link>http://www.cyberspice.org.uk/blog/2009/08/05/talk-introduction-to-wordpress-plugins/</link>
		<comments>http://www.cyberspice.org.uk/blog/2009/08/05/talk-introduction-to-wordpress-plugins/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 11:18:44 +0000</pubDate>
		<dc:creator>cyberspice</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[PHPNW]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.cyberspice.org.uk/blog/?p=248</guid>
		<description><![CDATA[Last night I gave my first pukka pecha kucha talk at the monthly PHPNW. The talk is a lightning talk with 20 slides with 20 seconds a slide. I.e. 6 minutes 40 seconds in total. Since I hadn&#8217;t even decided I was going to talk until last Friday and I had no talk prepared I [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I gave my first pukka pecha kucha talk at the monthly <a href="http://phpnw.org.uk/">PHPNW</a>.  The talk is a lightning talk with 20 slides with 20 seconds a slide.  I.e. 6 minutes 40 seconds in total.  Since I hadn&#8217;t even decided I was going to talk until last Friday and I had no talk prepared I was still preparing the slides on the train to Manchester where the meetings are held.  </p>
<p>I didn&#8217;t have a VGA adapter for my MacBook and had to borrow one to connect it to the project.  I think I need to buy one.  I bought a DVI adapter when I bought the machine but not the VGA one as I thought who needs them with modern monitors.  But of course most projectors have VGA only connections so such adapters are a necessary component of the presenter&#8217;s toolkit.</p>
<p>The talk seemed to go well and was appreciated by the audience and plugins seemed to be my topic of conversation for the rest of the evening.  There was some interest in my <a href="http://www.cyberspice.org.uk/blog/wordpress-coppermine-widget/">WordPress Coppermine Widget</a> plugin and techniques I had used in the Javascript for it.  I think this will become the subject of another blog post.  </p>
<p>I went a little awry with my mental arithmetic and ran over by about a minute.  When <a href="http://www.lornajane.net/">Lornajane</a> gave her talk she had the slides change automatically after 20 seconds so you know when the talking time for a slide is up.  I will steal this idea!</p>
<p>My slides are available as a <a href="http://www.cyberspice.org.uk/downloads/WordpressPlugins.pdf">PDF download</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberspice.org.uk/blog/2009/08/05/talk-introduction-to-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Automatic Update Bug &#8211; Follow Up</title>
		<link>http://www.cyberspice.org.uk/blog/2009/07/16/wordpress-automatic-update-bug-follow-up/</link>
		<comments>http://www.cyberspice.org.uk/blog/2009/07/16/wordpress-automatic-update-bug-follow-up/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 19:01:59 +0000</pubDate>
		<dc:creator>cyberspice</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.cyberspice.org.uk/blog/?p=242</guid>
		<description><![CDATA[The bug I raised on WordPress yesterday as documented in this blog post has been closed as a &#8216;duplicate&#8217;. Looking through the bugs about a month ago someone else raised a very similar bug report and proposed a very similar solution. That bug report was closed with &#8216;wontfix&#8217;. The basic comment is that (a) they [...]]]></description>
			<content:encoded><![CDATA[<p>The bug I raised on WordPress yesterday as documented in  <a href="http://www.cyberspice.org.uk/blog/2009/07/15/wordpress-automatic-update-bug/">this</a>  blog post has been closed as a &#8216;duplicate&#8217;.  </p>
<p>Looking through the bugs about a month ago someone else raised a very similar bug report and proposed a very similar solution.  That bug report was closed with &#8216;wontfix&#8217;.  The basic comment is that (a) they know about it; (b) they think changing the behaviour will break shared hosting; (c) group write support is not supported in WordPress anyway.</p>
<p>The comments in the bug do confirm something I spotted yesterday when looking at the latest release revision of <em>wp-admin/includes/file.php</em> which is that you can completely over-ride the write checking mechanism in WordPress 2.8 and above if you define the constant <em>FS_METHOD</em> to be &#8216;direct&#8217;.  A bit hacky but useful.  It means I can use decent permissions and still use auto-update.  Time to upgrade to 2.8.1 I think.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberspice.org.uk/blog/2009/07/16/wordpress-automatic-update-bug-follow-up/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress Automatic Update Bug</title>
		<link>http://www.cyberspice.org.uk/blog/2009/07/15/wordpress-automatic-update-bug/</link>
		<comments>http://www.cyberspice.org.uk/blog/2009/07/15/wordpress-automatic-update-bug/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 18:15:13 +0000</pubDate>
		<dc:creator>cyberspice</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.cyberspice.org.uk/blog/?p=238</guid>
		<description><![CDATA[LornaJane wrote an article on her blog about WordPress automatic update asking for FTP. As I&#8217;ve been having problems with the automatic update too and since I also don&#8217;t want to install FTP I changed permissions as she suggested. Unfortunately, even with &#8216;other&#8217; (world) write permissions, I was still being asked for FTP details. After [...]]]></description>
			<content:encoded><![CDATA[<p>LornaJane wrote an article on her blog about <a href="http://www.lornajane.net/posts/2009/Wordpress-Automatic-Update-Asking-for-FTP">WordPress automatic update asking for FTP</a>.  As I&#8217;ve been having problems with the automatic update too and since I also don&#8217;t want to install FTP I changed permissions as she suggested.  Unfortunately, even with &#8216;other&#8217; (world) write permissions, I was still being asked for FTP details.  After some discussion on IRC it turns out that not only do you need the right permissions but you need the files with the right owner i.e. the Apache process.  This didn&#8217;t seem right.  Why an earth do you need the right ownership if you can write anyway.   Also if you have to have the files owned by the Apache process <strong>any</strong> scripting running on the server can access and change the files.  Its a security risk.  So I decided to dig deeper.</p>
<p>Grepping the WordPress source for the text line &#8216;There was an error connecting to the server, Please verify the settings are correct.&#8217; showed me the relevant code is in <em>wp-admin/includes/file.php</em>.  The function that requests the FTP details is <em>request_filesystem_credentials()</em>.  This function is called if <em>get_filesystem_method()</em> returns a method other than &#8216;direct&#8217;.  It seemed that <em>get_filesystem_method()</em> was at fault.   The relevant code snippet is below.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">        <span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'getmyuid'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fileowner'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$temp_file</span> <span style="color: #339933;">=</span> wp_tempnam<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">getmyuid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #990000;">fileowner</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                        <span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'direct'</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Examining the function it seems that it tries to creates temporary file (typically in <em>wp-content</em>) and if successful compares the ownership of that file with the process.  If equivalent it decides that it can use &#8216;direct&#8217; mode.  The problem is it uses <em>getmyuid()</em> which <a href="http://us.php.net/manual/en/function.getmyuid.php">according to the documentation</a> returns the owner of the file that called the function and not the owner of the process running the code.  I.e. the owner of  <em>wp-admin/includes/file.php</em>.  It doesn&#8217;t matter who the owner of the apache process is.  There is another function<br />
<em>posix_getuid()</em> which returns the process owner.  So I have modified the  <em>get_filesystem_method()</em> function as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">        <span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posix_getuid'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fileowner'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$temp_file</span> <span style="color: #339933;">=</span> wp_tempnam<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">posix_getuid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #990000;">fileowner</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                        <span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'direct'</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'getmyuid'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fileowner'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$temp_file</span> <span style="color: #339933;">=</span> wp_tempnam<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">getmyuid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #990000;">fileowner</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                        <span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'direct'</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span></pre></div></div>

<p>I.e it checks to see if <em>posix_getuid()</em> is supported and if it is it uses that instead.  This allows me to have my WordPress files owned by a different owner than the apache process.  I have set the <em>wp-content</em> to a member of a group containing the apache process owner and made them group writeable.  As long as apache can write the temp file WordPress can use automatic update.  This is still some what insecure but better than having all the WordPress files either owner by the apache process or world writeable.</p>
<p>Note that I am currently running WordPress 2.7.1.  Looking at WordPress 2.8.1 the <em>get_filesystem_method()</em> function has changed but not significantly.  I am raising a bug.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberspice.org.uk/blog/2009/07/15/wordpress-automatic-update-bug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Coppermine WordPress Widget</title>
		<link>http://www.cyberspice.org.uk/blog/2009/03/29/coppermine-wordpress-widget/</link>
		<comments>http://www.cyberspice.org.uk/blog/2009/03/29/coppermine-wordpress-widget/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 17:00:11 +0000</pubDate>
		<dc:creator>cyberspice</dc:creator>
				<category><![CDATA[Geek]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.cyberspice.org.uk/blog/?p=168</guid>
		<description><![CDATA[I&#8217;ve not been well this weekend. Its the remnants of a fluey cold exacerbated by getting too cold in the wind and rain when using public transportation on Thursday and Friday. However every cloud has a silver lining and sitting in bed, in between snoozes, has given me the chance to get on and develop [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve not been well this weekend.  Its the remnants of a fluey cold exacerbated by getting too cold in the wind and rain when using public transportation on Thursday and Friday.  However every cloud has a silver lining and sitting in bed, in between snoozes, has given me the chance to get on and develop a WordPress plugin and widget that integrates with, and displays images from a <a href="http://coppermine-gallery.net/">Coppermine gallery</a>.</p>
<p>This is the first plugin and widget for WordPress I have developed and its been a bit of a learning exercise.  Its no way completed but the basics are there and you can download the plug-in <a href="http://www.cyberspice.org.uk/downloads/wp-cpg-plugin.0.01.zip">here</a>.  (Edit: The plug-in is now supported officially on the WordPress site.  You can get the latest one from <a href="http://wordpress.org/extend/plugins/wp-cpg-widget/">here</a>). Currently the only known bug is that you add the widget to a sidebar before you have configured the default Coppermine database settings.</p>
<p>Currently the widget just displays a fixed number of random images from the whole gallery.  You can see it in action in the left side bar.  Clicking an image takes you to that image&#8217;s album in the gallery.  Imminent additions I will make are a configurable number of images and columns; selectable queries e.g. the latest additions to the gallery, random from an album or albums, and so on; and pop-ups on mouse-over showing a larger version of the image together with image title and description.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberspice.org.uk/blog/2009/03/29/coppermine-wordpress-widget/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>First post</title>
		<link>http://www.cyberspice.org.uk/blog/2008/09/26/first-post/</link>
		<comments>http://www.cyberspice.org.uk/blog/2008/09/26/first-post/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 22:28:54 +0000</pubDate>
		<dc:creator>cyberspice</dc:creator>
				<category><![CDATA[Sundry]]></category>
		<category><![CDATA[BLOG]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.cyberspice.org.uk/blog/?p=6</guid>
		<description><![CDATA[It about sums it up really (from the great xkcd web comic). I&#8217;m sitting here waiting for a big build to get to the place where I want it to purposefully break, so that I can extract some files, and so I decided to finally get my blog back in to use again. So here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><center><a href="http://xkcd.com/303/"><img src="http://imgs.xkcd.com/comics/compiling.png" alt="I'm not slacking off, my code's compiling!" /></a></center></p>
<p>It about sums it up really (from the great <a href="http://xkcd.com/">xkcd</a> web comic).  I&#8217;m sitting here waiting for a big build to get to the place where I want it to purposefully break, so that I can extract some files, and so I decided to finally get my blog back in to use again.  So here&#8217;s the first post.  What&#8217;s the purpose of the blog?  Well mainly general ramblings; a way that my family and friends can keep up with my activities as I jet around the world; and talk about private projects.</p>
<p>So there you are!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberspice.org.uk/blog/2008/09/26/first-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

