<?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>Torkil Johnsen &#187; joomla</title>
	<atom:link href="http://www.torkiljohnsen.com/category/joomla/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.torkiljohnsen.com</link>
	<description>My personal piece of cyberspace</description>
	<lastBuildDate>Mon, 28 Nov 2011 11:18:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Joomla 1.6 caching explained</title>
		<link>http://www.torkiljohnsen.com/2010/10/05/joomla-1-6-caching-explained/</link>
		<comments>http://www.torkiljohnsen.com/2010/10/05/joomla-1-6-caching-explained/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 09:00:39 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[joomla]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[joomla 1.6]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=554</guid>
		<description><![CDATA[Klas Berli&#x10D, the man mainly responsible for the rewritten cache functionality in Joomla 1.6, has written two nice articles that explains the different types of caching available in Joomla 1.6. Joomla 1.6 caching explained Joomla 1.6 caching for developers]]></description>
			<content:encoded><![CDATA[<p>Klas Berli&#x10D, the man mainly responsible for the rewritten cache functionality in Joomla 1.6, has written two nice articles that explains the different types of caching available in Joomla 1.6.</p>
<p><a href="http://www.bzzzz.biz/blog/joomla/joomla-1.6-caching-demistified-jennifer-series.bzzzz" class="more-link">Joomla 1.6 caching explained</a></p>
<p><a href="http://www.bzzzz.biz/blog/joomla/joomla-1.6.-cache-changes-for-extension-developers-jennifer-series-2.bzzzz" class="more-link">Joomla 1.6 caching for developers</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/10/05/joomla-1-6-caching-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Collection of Joomla Security Tips</title>
		<link>http://www.torkiljohnsen.com/2010/09/18/collection-of-joomla-security-tips/</link>
		<comments>http://www.torkiljohnsen.com/2010/09/18/collection-of-joomla-security-tips/#comments</comments>
		<pubDate>Sat, 18 Sep 2010 12:11:40 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[joomla]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=405</guid>
		<description><![CDATA[This is a post where I have collected a lot of tips and links from wherever I could find them. Originally I was going to wait for Joomla 1.6 to publish this and make sure to adjust the list according to what 1.6 will look like, but 1.6 is still in beta, and I grow [...]]]></description>
			<content:encoded><![CDATA[<p>This is a post where I have collected a lot of tips and links from wherever I could find them. Originally I was going to wait for Joomla 1.6 to publish this and make sure to adjust the list according to what 1.6 will look like, but 1.6 is still in beta, and I grow tired of waiting, so this is a list targeted at Joomla 1.5.<br />
<span id="more-405"></span><br />
<b>Disclaimer:</b> This post is <em>not</em> to be considered final by any means. Please help out people like yourself by adding more stuff to the comments or tweet them to me <a href="http://twitter.com/torkilj">@torkilj</a>, and I&#8217;ll update this list accordingly! </p>
<h2>Table of contents</h2>
<ol>
<li><a href="#choosing_a_host">Choosing a host for your Joomla site</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#setup_and_configuration">Setting up and configuring the website</a></li>
<li><a href="#running_the_website">Running the website</a></li>
<li><a href="#developer_checklist">Developer&#8217;s checklist</a></li>
<li><a href="#if_you_get_hacked">What to do if your site gets hacked</a></li>
<li><a href="#resources">Further reading, other resources</a></li>
<li><a href="#acknowledgements">Acknowledgements</a></li>
</ol>
<hr style="display:block; margin-top: 2em;" />
<a name="choosing_a_host"></a><br />
<h2>Choosing a host for your Joomla site</h2>
<p>First of all, you should find a proper hosting provider. You could ask others in the Joomla community for their recommendations, and you could check out the <a href="http://resources.joomla.org/directory/support-services/hosting.html">shortlist of hosting providers</a> on the Joomla Resource Directory. These have at least gone through a manual screening process where their server setup has been checked for the most common pitfalls. </p>
<p>If you&#8217;re considering a host, here&#8217;s a brief list of requirements that you can run by your hosting provider to see if they fit the bill:</p>
<ol start="1">
<li>
<h3>Secure communication</h3>
<p>Make sure your host supports secure connections. It will cost you around $30/year to get a 256-bit SSL certificate to secure your backend. If you need to transfer files, make sure that SFTP or SCP is an available option to you, instead of having to use plain FTP.
</li>
<li>
<h3>PHP configuration</h3>
</li>
<ul>
<li>As with any software: Don&#8217;t use outdated versions, like PHP4</li>
<li>Disable potentially harmful PHP functions</li>
<li>Use open_basedir (with care, see comments after this article by Nicholas)</li>
<li>Turn magic quotes off</li>
<li>Don&#8217;t register globals</li>
<li>Allow users to set local php.ini files</li>
</ul>
<li>
<h3>Apache configuration</h3>
</li>
<ul>
<li>Enable .htaccess</li>
<li>Enable mod_rewrite</li>
<li>Enable mod_security</li>
<li>Enable suPHP</li>
</ul>
</ol>
<p><a name="installation"></a><br />
<h2>Installation</h2>
<ol start="4">
<li>
<h3>Connect securely</h3>
<p>Use SFTP or SSH when you connect to your server, and do not store your password in for instance your FTP client. This of course also goes for any subsequent connections to the server after you have finished your install.
</li>
<li>
<h3>Follow your own best practices</h3>
<p>If you have already set up one site where you follow all the basic security measures you want to follow, and you have already implemented the security extensions of your choice, there is no need to reinvent the wheel: Use a backup tool like <a href="http://extensions.joomla.org/extensions/access-a-security/site-security/backup/1606">Akeeba Backup</a> or something similar, take a backup of the site and use that backup as a starting point for your new site.</p>
<p>Kudos to <a href="http://twitter.com/hermanpeeren">@hermanpeeren</a> for the tip!
</li>
<li>
<h3>Do not use the standard DB prefix jos_. </h3>
<p> Many SQL injection attacks are based on the assumption that your database tables are named &#8220;jos_&#8221;. In case you did use jos_, you can still <a href="http://magazine.joomla.org/topics/item/108-the-prefix-has-nothing-to-do-with-telephony">change it with a simple PHP script</a>.</li>
<li>
<h3>One database user per installation</h3>
<p> Do not give the same database user access to multiple installations, and do not use the server&#8217;s root user for your database connection.</li>
<li>
<h3>Consider db user password quality</h3>
<p> Use a long and complicated password for your database, and when installation is done, for your login. It&#8217;s too easy to decrypt an MD5 or SHA1 hash these day. There are even <a href="http://md5.web-max.ca/">webapps that help you do it</a>. If someone gets hold of your database of hashed passwords, it&#8217;s only a matter of time before they are broken. There are lots of good tips for password quality in this previous article I wrote, &#8220;<a href="http://www.torkiljohnsen.com/2010/08/18/how-to-create%E2%80%94and-remember%E2%80%94a-different-password-for-every-single-login/">How to create—and remember—a different password for every single login</a>&#8220;, and there are also a lot of good tips in the article&#8217;s comments.</p>
<p>In general, when it comes to passwords: Don&#8217;t write them down anywhere, and if you have to, at least <a href="http://www.torkiljohnsen.com/2010/09/18/collection-of-joomla-security-tips/#comment-81103415">store them securely</a>.</li>
<li>
<h3>Don&#8217;t install sample content</h3>
<p> Sample content identifies you and your installation, and makes you easy to find and target. Don&#8217;t install sample content on what is to be a live website, because forgetting to remove absolutely all sample content is just too easy. </li>
</ol>
<p><a name="setup_and_configuration"></a><br />
<h2>Setting up and configuring the website</h2>
<ol start="10">
<li>
<h3>Use correct file- and directory permissions</h3>
<p> Avoid 777 of course. It seems this can&#8217;t be repeated enough times though. Extensions like suPHP will take care of setting proper permissions, so talk to your host and make sure they support it.</p>
<p>This will also make the need for the Joomla FTP-layer redundant, so you won&#8217;t neet to use your FTP username and password anywhere.</li>
<li>
<h3>Uninstall stuff you don&#8217;t need</h3>
<p> Brian Teeman has a saying: &#8220;<a href="http://brian.teeman.net/joomla-gps/joomla-hidden-secrets-presentation-at-joomladaysnl.html">Nothing appears on my website that I didn&#8217;t put there</a>&#8220;. Uninstall core components, modules, plugins, templates and other extensions that you&#8217;re not using, including templates and even images. Extensions on your website are all potential security liabilities, either because they add security holes or because they help attackers identify potential security holes. </p>
<p>Observe for instance that installing the <a href="http://joomlacontenteditor.net">JCE WYSIWYG editor</a> will also install TinyMCE, as it is bundled with JCE. Joomla comes with TinyMCE installed as it&#8217;s default editor, so then you&#8217;ll have two TinyMCE installations.</p>
<p>Some core stuff can&#8217;t be uninstalled through the normal uninstaller. This is because they are marked as &#8220;core&#8221; elements in the database. In the components, modules and plugins database tables, there are fields called &#8220;core&#8221; which is set to 1 for these extensions. Change this value to 0 to make them possible to uninstall.
</li>
<li>
<h3>Global configuration setup</h3>
<ol style="list-style:upper-latin">
<li>
<h4>Disable registration/login</h4>
<p>If you don&#8217;t want people to register and/or login on the frontend, make sure you disable the functionality.</li>
<li>
<h4>Disable XML-RPC</h4>
<p>Disable the XML-RPC-server if you don&#8217;t need it.</li>
<li>
<h4>Replace default Joomla meta information with your own data</h4>
<p>Make sure you replace, or at least replace, the default metadata. These will show up in your sourcecode and in Google.</li>
<li>
<h4>Use SEF urls</h4>
<p>Regular URLs <a href="http://forum.joomla.org/viewtopic.php?f=432&amp;t=391251">gives away the fact that Joomla is running your system</a>. But then again, so can a lot of other things. Like for instance a template graphic, a static file, a code structure. Changing from regular to SEF URLs won&#8217;t render the regular URLs useless either, so this is not a very strong security measure. Make sure you also enable the .htaccess-file, see below.</li>
<li>
<h4>Move logs and cache outside the site root</h4>
<p>Change the log and cache paths in the administrator to a folder outside the site root so that they can&#8217;t be accessed through a web browser, or protect the folders in some other way.</li>
</ol>
</li>
<li>
<h3>Remove generator information</h3>
<p><a href="http://forum.joomla.org/viewtopic.php?f=432&amp;t=391251">Remove the generator tag</a> from the head-section of your website.</li>
<li>
<h3>Delete the default user account</h3>
<p> The userid 62 and the username &#8220;admin&#8221; represents a weakness, but there&#8217;s no easy way to replace these during installation. In the administration, the easiest thing you can do is to add a new super administrator, log in as the new super administrator, then demote the admin user to a lower usergroup and then delete the user all together. As our greek friend <a href="http://twitter.com/nikosdion">@nikosdion</a> demonstrates, you can also <a href="http://magazine.joomla.org/topics/item/148-62-reasons-to-fire-your-super-admin">fix this and add users below id 62 with some easy SQL</a>.</p>
<p>Here&#8217;s some quick SQL to help you change the user id and username of the default account right after installation:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="sql"><pre class="de1"><span class="co1">-- Change 3 in both queries with the userid you want</span>
<span class="co1">-- Change jos_ with your own db prefix</span>
<span class="co1">-- Change yourusername with your new username</span>
<span class="kw1">UPDATE</span> jos_users <span class="kw1">SET</span> id<span class="sy0">=</span><span class="nu0">3</span><span class="sy0">,</span> username<span class="sy0">=</span><span class="st0">'yourusername'</span> <span class="kw1">WHERE</span> id<span class="sy0">=</span><span class="nu0">62</span>;
<span class="kw1">UPDATE</span> jos_core_acl_aro <span class="kw1">SET</span> <span class="kw1">VALUE</span><span class="sy0">=</span><span class="nu0">3</span> <span class="kw1">WHERE</span> <span class="kw1">VALUE</span><span class="sy0">=</span><span class="nu0">62</span>;</pre></div></div></div></div></div></div></div>


</li>
<li>
<h3>Enable the .htaccess-file</h3>
<p> The default .htaccess-file has some basic security built in. In Joomla versions earlier than 1.5.15, you should also make sure <a href="http://forum.joomla.org/viewtopic.php?p=1788498#p1788498">it restricts access to critical files</a>. In versions newer than 1.5.15 (1.5.20 is the latest version at the time this writing), you still have to uncomment parts of the .htaccess-file to activate this security measure.&nbsp;</li>
<li>
<h3>Enhance the .htaccess-file</h3>
<p> Nicholas K. Dionysopoulos (that&#8217;s <a href="http://twitter.com/nikosdion">@nikosdion</a> in twitterish) also has a nice <a href="http://snipt.net/nikosdion/the-master-htaccess/">Master .htaccess-file</a> with lots of other goodies included, that&#8217;s really worth a peek. For instance: Restrict directory listings, force https on certain pages, blocking of some common exploits, file injection protection, fingerprint attack blocking, and more.</li>
<li>
<h3>Encrypt communication, or at least the login</h3>
<p>A nice <a href="http://brian.teeman.net/joomla-gps/protect-joomla-passwords-on-public-wifi-networks.html">article by Herman Peeren</a> highlights the dangers of not logging in to your site with SSL, and suggests that if you can&#8217;t set up SSL you at least look into an extension called <a href="http://extensions.joomla.org/extensions/access-a-security/site-security/11519">Encrypt configuration</a>.
</li>
<li>
<h3>Make fingerprinting your site harder</h3>
<p>One of the easiest ways for an attacker to decide if your site is a potential Joomla! target is to perform a rudimentary visual fingerprinting. Both Joomla! and PHP comes with many static resources, special features and even easter eggs that can make it easy to identify what software you&#8217;re using, and what versions they are.</p>
<p>There is a great post in the October 2010 Joomla Community Magazine about this: &#8220;<a href="http://magazine.joomla.org/issues/Issue-Oct-2010/item/214-only-a-ninja-can-kill-another-ninja">Only a ninja can kill another ninja</a>&#8220;, by <a href="http://twitter.com/nikosdion/">@nikosdion</a>.
</li>
<li>
<h3>Choose your extensions wisely</h3>
<ol>
<li>
<h4>Avoid extensions with encrypted sourcecode</h4>
<p> You can&#8217;t fix bugs in encrypted sourcecode yourself, and you&#8217;ll be left at the mercy of the extension producer should something bad surface. This is mostly a personal preference of mine, as I like probing around in people&#8217;s code both to learn and to get a general feeling for the actual quality of the software I&#8217;m running.</li>
<li>
<h4>Avoid dead extensions</h4>
<p>If a extension&#8217;s homepage is returning a 404 error, or hasn&#8217;t been updated in ages, it&#8217;s a good indicator that you should check out if this extension is still being maintained or not, before you decide to install it.</li>
<li>
<h4>Avoid legacy extensions</h4>
<p> Stick to extensions with fresh 1.5 compatible code. Joomla 1.0&#8242;s EOL has passed now, over a year ago, time to move on.</li>
</ol>
</li>
<li>
<h3>Add extra layers of security</h3>
<ol>
<li>
<h4>Protect /administrator with extra measures</h4>
<p> You could require an extra password to access /administrator, or even restrict access to certain IP addresses. Some security plugins, like jSecure can help you accomplish stuff like this too. (<a href="http://magazine.joomla.org/topics/item/66-things-to-do-before-your-site-gets-hacked">thanks to @nikosdion again</a>)</li>
<li>
<h4>Consider installing security extensions</h4>
<p> Lots of opportunities on the JED in the categories <a href="http://extensions.joomla.org/extensions/access-a-security/site-security/site-protection">site protection</a>, <a href="http://extensions.joomla.org/extensions/access-a-security/site-security/site-monitoring">site monitoring</a> and <a href="http://extensions.joomla.org/extensions/access-a-security/site-security/login-protection">login protection</a>. Many of these will help you with the items in this list.</li>
<li>
<h4>Monitor your site for unwanted changes</h4>
<p>Lots of tools can be used here, for example there is a Windows tool out there called Akeeba SiteDiff, which you can use with Akeeba Backup, and which will compare the state of your site with the last known good state. <a href="http://www.dionysopoulos.me/blog/proactive-security-is-sensible-security">Read more about Akeeba SiteDiff</a>.
</li>
<li>
<h4>Add a custom ACL solution</h4>
<p> Joomla 1.5&#8242;s default ACL is not very restrictive, and you may be giving out more access privileges than you&#8217;d like. Brian Teeman has <a href="http://brian.teeman.net/joomla-gps/joomla-15-acl-explained.html" id="x_oz" title="a nice table showing who gets to do what exactly">a nice table showing who gets to do what exactly</a>. Consider adding a <a href="http://extensions.joomla.org/extensions/access-a-security/backend-a-full-access-control">custom ACL solution</a> for better access control.</li>
</ol>
</li>
<li>
<h3>Avoid exposing information</h3>
<p> Disable the display of errors on live sites, so that system paths and server information is not shown. Set display_errors to 0 in a local php.ini for instance, or use <a href="http://www.electrictoolbox.com/set-php-config-options-apache-htaccess-file/" id="qbgb" title="php_value in a .htaccess-file">php_value in a .htaccess-file</a>.</li>
<li>
<h3>Don&#8217;t send out username/password in plain text e-mails</h3>
<p>Sending a plain e-mail is like sending a postcard; it&#8217;s not wise to include anything sensitive in it. Joomla does this by default (!) each time you add a new user to your users list, or when a user signs up. </p>
<p>One way to avoid this is to override the language files; the text that goes out in the account creating confirmation e-mails is located in the language file, so this can be tweaked to not include the password. </p>
<p>In Joomla 1.6 you can also override a single language string without having to create a whole language pack, which makes this easier. There is also a plugin for 1.5 called <a href="http://extensions.joomla.org/extensions/languages/language-edition/13147">Translation Override</a>, which may prove to be useful for this purpose. (thanks to <a href="http://twitter.com/jlleblanc/status/24868684341">@jlleblanc</a>, <a href="http://twitter.com/nikosdion/status/24868750005">@nikosdion</a> and <a href="http://twitter.com/ot2sen/status/24871628779">@ot2sen</a> for the tips)
</li>
</ol>
<p><a name="running_the_website"></a><br />
<h2>Running the website</h2>
<ol start="23">
<li>
<h3>Stay updated</h3>
<p>There&#8217;s one newsfeed for <a href="http://feeds.joomla.org/JoomlaSecurityNews">Joomla Security News</a> and one <a href="http://feeds.joomla.org/JoomlaSecurityVulnerableExtensions">feed for news about vulnerable extensions</a>.</p>
<p>You should use the information to avoid insecure extension, because you can bet that those looking to hack your website are also keeping up to date with news on new vulnerabilities. &#8211; Read the result of Brian Teeman&#8217;s &#8220;<a href="http://docs.joomla.org/Investigation_of_exploits">Investigation of Exploits</a>&#8221; from August 2010. &#8211; Read the <a href="http://docs.joomla.org/Vulnerable_Extensions_List">vulnerable extensions list</a> in the docs wiki, and subscribe to <a href="http://feeds.joomla.org/JoomlaSecurityVulnerableExtensions">it&#8217;s feed</a>. </p>
<p>Note that you can also subscribe to changes on a wiki page like the one above, to be notified whenever it changes. If you go to the <a href="http://docs.joomla.org/Vulnerable_Extensions_List">vulnerable extensions list</a> and register an account and log in, you will get a button in the top menu that allows you to subscribe to changes on that page.</li>
<li>
<h3>Install security patches immediately</h3>
<p> Pay attention to mailing lists announcing insecure extensions and updates to extensions you&#8217;re using, including Joomla itself of course.</li>
<li>
<h3>Backup your site regularly</h3>
<p> If your server host does not do backups for you, you could <a href="http://www.opensourcesupportdesk.com/blog/80-joomla-component/393-how-to-backup-your-joomla-site-to-the-cloud">backup your site to the cloud</a>, or make good use of a <a href="http://extensions.joomla.org/extensions/access-a-security/site-security/backup">backup extension</a>.</p>
<p>Make sure to test that the backup works and always store the backup off-site.</li>
</ol>
<p><a name="developer_checklist"></a><br />
<h2>Developer&#8217;s checklist</h2>
<ol start="26">
<li>
<h3>Use an IDE</h3>
<p>IDEs can help considerably with code quality, development and testing.</li>
<li>
<h3>Use a versioning system</h3>
<p> Stuff like SVN and Git will be a lifesaver the day something is hacked or modified without your knowledge, or goes to hell in another way. It also makes it easier to maintain and roll out different versions of your software. Use versioning even if you&#8217;re the only one doing development, it&#8217;s well worth it.</li>
<li>
<h3>Test locally, deploy globally</h3>
<p> Run different configurations for your test sites and live sites: Stuff that gives away information should never be done where it&#8217;s visible to the public, in particular debugging. Errors should not be shown on a live site, especially not those who disclose paths or system information. As an extensions developer though, all you can do here is probably just advise your customers. This type of setting has to be done on the server.</li>
<li>
<h3>Use CSRF-protection</h3>
<p><a href="http://docs.joomla.org/How_to_add_CSRF_anti-spoofing_to_forms">http://docs.joomla.org/How_to_add_CSRF_anti-spoofing_to_forms</a></li>
<li>
<h3>Don&#8217;t chmod files or folders to 777!</h3>
<p> Not only is this a bad idea security wise, it also tells people reading your code that you&#8217;re lazy at best, and furthermore that you don&#8217;t know what you&#8217;re doing.</li>
<li>
<h3>Filter data</h3>
<p> Filter data the user inputs and escape outputting of user-provided content, which is especially useful for preventing SQL injection and XSS attacks. <a href="http://docs.joomla.org/Tutorial:How_to_make_your_Joomla_addon_more_secure_WIP">Read more about this and see examples</a>.</li>
<li>
<h3>Keep your codebase small</h3>
<p> Reuse previously road-tested code where you can, and stay DRY (Don&#8217;t Repeat Yourself). Less code equals less potential security risks and less code maintenance costs for you.</li>
<li>
<h3>Use Nooku Framework</h3>
<p> If you&#8217;re creating a Joomla extension, you should consider using <a href="http://nooku.org">Nooku Framework</a>, which reduces your codebase with around 80% and does a lot of things automatically, where you in Joomla would have to write code manually. Directly related to security, Nooku gives you automatic CSRF protection (automatic form tokens and token control), automatic data filtering and soon also automatic output escaping by default. </li>
<li>
<h3>No executable code in class files</h3>
<p> In your class files, stick to one class pr file and leave no executable code.</li>
<li>
<h3>Use _JEXEC</h3>
<p> use a _JEXEC test in files, especially templates or files with executable code, to make sure the file is loaded from within the application. Files with just a PHP class in them do not need this.</li>
<li>
<h3>Keep names and versions hidden</h3>
<p> Don&#8217;t display extension names and versions in the code or on your site. &#8220;Powered by Superapp version 1.5&#8243; on page footers that use your application, combined with a listing of Superapp version 1.5 being vulnerable on the list of vulnerable extensions, makes your clients easy targets. At least don&#8217;t display this info until Joomla gets a better upgrading system so that people can update outdated extensions in a painless manner. </p>
<p>Worth reading in this context: <a href="http://googlewebmastercentral.blogspot.com/2009/11/new-software-version-notifications-for.html">New Software Notifications in Google Webmaster Tools</a>. </li>
</ol>
<p><a name="if_you_get_hacked"></a><br />
<h2>What to do if your site gets hacked</h2>
<ol start="37">
<li>
<h3>Take your site offline</h3>
<p>If malicious code has been injected into your site, you&#8217;d not want others to get their computers infected or compromised. For tougher cases: Add an IP filter so that only your IP-address can access your site while your fixing it.</p>
<h4>Remember: Offline does not mean unavailable</h4>
<p>Setting a website in maintenance mode is merely a visual thing that indeed will execute all plugins and component requests, but merely render the offline template. So if someone has found a loophole to get into your site, and you want to shut them out while you fix the problem, setting the site in maintenance mode will not help you.</p>
<p>Nicholas Dionysopoulos published <a href="http://www.dionysopoulos.me/blog/how-offline-is-joomla-offline-mode">a blog post</a> with information on this subject which is useful. He outlines one possible way around this issue, where he uses .htaccess to redirect all request to offline.html directly, bypassing Joomla completely. This means you have to have an offline-page of pure HTML to serve too of course. He also adds an exception so that you yourself can access the Joomla page from a specific IP-address. </p>
<p>Read <a href="http://www.dionysopoulos.me/blog/how-offline-is-joomla-offline-mode">the original blog post</a> for a more in-depth explenation and code sample.
</li>
<li>
<h3>Find other people with similar errors</h3>
<p>First thing to do would be to <a href="http://forum.joomla.org/search.php">search the Joomla forums</a> or search the web to try to find scenarios similar or identical to yours. This can save you a lot of time in the recovery phase, since you may benefit from other people&#8217;s findings.
</li>
<li>
<h3>Make sure your computers haven&#8217;t been compromised</h3>
<p>Malicious software on any computer with is used for accessing the site or it&#8217;s FTP accounts for instance, can be used by an intruder to gain access to your online user accounts. Use a scanner software to scan for malware, trojans, viruses, spyware, etc. A list of available software packages can be found in the Joomla documentation under &#8220;Local security&#8221;.
</li>
<li>
<h3>Verify that you have the latest versions</h3>
<p>Check that you have the latest Joomla version and the latest versions of your extensions, and that you&#8217;re not using any extension versions with known vulnerabilities. See lists of vulnerable extensions on the <a href="http://docs.joomla.org/Vulnerable_Extensions_List">Joomla documentation wiki</a> and in the <a href="http://feeds.joomla.org/JoomlaSecurityVulnerableExtensions">Joomla security newsfeed</a>.
</li>
<li>
<h3>Locate modified files</h3>
<p>Log in to your server and use the find command to find out which files have been changed recently.</p>
<p>This command will list all files in the current folder where the <strong>file modification time (mtime) is less than three days old</strong>:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1"><span class="kw2">find</span> . <span class="re5">-mtime</span> <span class="re5">-3</span></pre></div></div></div></div></div></div></div>


<p>This command will list all files in the current folder where the <strong>last change of file status (ctime) happened less than three days ago</strong>:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1"><span class="kw2">find</span> . <span class="re5">-ctime</span> <span class="re5">-3</span></pre></div></div></div></div></div></div></div>


<p>This command will list all <strong>files changed at least one day ago but less than three days ago</strong>:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="bash"><pre class="de1"><span class="kw2">find</span> . <span class="re5">-ctime</span> +<span class="nu0">1</span> <span class="re5">-a</span> <span class="re5">-ctime</span> <span class="re5">-3</span></pre></div></div></div></div></div></div></div>


</li>
<li>
<h3>Find out what&#8217;s changed on your server</h3>
<p>If files have been modified on your server, or files have been uploaded for instance, you can check the timestamps on those files to find out when the attacker was on your site. This is typical in the case of sites being <a href="http://en.wikipedia.org/wiki/Website_defacement">defaced</a> or malicious code being injected somewhere.  Most of the time, the attacker will have gained access to your site shortly before modifying or uploading files to it. By checking your access logs for the period around that time, you may find some clues as to how the attacker gained access and which IP-address the attack came from, thus enabling you to track down things more easily in the logs.</p>
<p>You can also try searching for suspicious POST requests made to for instance non-form addresses on your site. </p>
<p>Use any information gained from this to block out further attacks and patch weak spots in your system.
</li>
<li>
<h3>Check your crontab/task scheduler</h3>
<p>Check your crontab and make sure there are no things in there that you didn&#8217;t put there yourself. If you can&#8217;t access your crontab or don&#8217;t know how to, ask your hosting provider for help.
</li>
<li>
<h3>Report the attack to your host</h3>
<p>Get your host to help you flush out the problems and make sure the attacker has not left any hidden backdoors to make it easy for him to regain access to your site.
</li>
<li>
<h3>Change your passwords</h3>
<p>Change passwords and, if you can, usernames to all access points to your site: MySQL databases, FTP users, administrators, SSH accounts, control panel logins, etc. Use <a href="http://www.torkiljohnsen.com/2010/08/18/how-to-create%E2%80%94and-remember%E2%80%94a-different-password-for-every-single-login/">strong passwords</a>!
</li>
<li>
<h3>Restore a working backup, or reinstall completely</h3>
<p>Wipe your server clean and roll back to a known, safe backup. Make sure all security holes have been patched before you reopen the site. You should also consider deleting the entire installation and just reinstall Joomla and your extensions from scratch, so that you are certain not to include any backdoors a hacker may have left behind prior to the attack.
</li>
<li>
<h3>Report security issues you may find</h3>
<p>If you find soft spots in Joomla or any Joomla Extensions, report them on the <a href="http://forum.joomla.org/viewforum.php?f=432">security forum</a>, but without outlining to the public how to hack one million Joomla sites in 10 seconds. Also contact extension developers directly to give them a chance to produce a patch for their users. </p>
<p>When you report problems on the security forum, use the <a href="http://forum.joomla.org/viewtopic.php?f=428&#038;t=272481">post assistant tool</a> to make sure you include all the required information so that people are able to help you properly.
</li>
<li>
<h3>Official tips lists</h3>
<ul>
<li><a href="http://forum.joomla.org/viewtopic.php?f=432&#038;t=335090">Has your site been compromised? Read this</a>.</li>
<li><a href="http://docs.joomla.org/Security_Checklist_7">Go through this Security Checklist</a></li>
<li><a href="http://forum.joomla.org/viewtopic.php?p=1988191#p1988191">Read this before asking security support questions</a></li>
</ul>
</li>
</ol>
<p><a name="resources"></a><br />
<h2>Further reading, other resources</h2>
<ol start="49">
<li>
<h3>Read Nicholas&#8217; blog</h3>
<p><a href="http://www.dionysopoulos.me/" title="Nicholas K. Dionysopoulos">Nicholas K. Dionysopoulos&#8217; blog</a> is currently, by far, the best source of new information on this subject.
</li>
<li>
<h3>Follow Jeff Channel (<a href="http://twitter.com/jeffchannell">@jeffchannel</a>)</h3>
<p>Jeff has found several security holes both in the Joomla core and in well-known Joomla extensions. He tweets regularly about security, and you could probably also hire him to do a security audit of your extension.
</li>
<li>
<h3>Joomla security forum</h3>
<p>Discuss at <a href="http://forum.joomla.org/viewforum.php?f=432">the Joomla 1.5 security forum</a>.</li>
<li>
<h3>Security checklist</h3>
<p><a href="http://docs.joomla.org/Category:Security_Checklist">Joomla official security checklist</a></li>
</ol>
<p><a name="acknowledgements"></a><br />
<h2>Acknowledgements</h2>
<p>Thanks to <a href="http://brian.teeman.net" id="c3u." title="Brian Teeman">Brian Teeman</a> for valuable input and to <a href="http://www.dionysopoulos.me/" id="p7_x" title="Nicholas K. Dionysopoulos">Nicholas K. Dionysopoulos</a> for his numerous articles on this subject!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/09/18/collection-of-joomla-security-tips/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Advancing from Joomla MVC to Nooku HMVC</title>
		<link>http://www.torkiljohnsen.com/2010/09/14/advancing-from-joomla-mvc-to-nooku-hmvc/</link>
		<comments>http://www.torkiljohnsen.com/2010/09/14/advancing-from-joomla-mvc-to-nooku-hmvc/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 20:25:47 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[joomla]]></category>
		<category><![CDATA[Nooku]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=465</guid>
		<description><![CDATA[I just read a really helpful blogpost over at corephp.com about how you can reuse a model in Joomla Framework&#8217;s MVC structure. Thought I&#8217;d give an example of how this is solved in Nooku Framework, and then move on and look at how Nooku has taken MVC a few steps further. The Joomla way, courtesy [...]]]></description>
			<content:encoded><![CDATA[<p>I just read a really helpful blogpost over at corephp.com about <a href="http://www.corephp.com/blog/joomla-mvc-load-a-model-from-anywhere/#more-2058">how you can reuse a model in Joomla Framework&#8217;s MVC structure</a>. Thought I&#8217;d give an example of how this is solved in Nooku Framework, and then move on and look at how Nooku has taken MVC a few steps further.<br />
<span id="more-465"></span></p>
<h2>The Joomla way, courtesy of corePHP.com</h2>
<p><code>JLoader::import('joomla.application.component.model');<br />
JLoader::import( 'items', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_foo' . DS . 'models' );<br />
$items_model = JModel::getInstance( Items', 'FooModel' );<br />
$items_model->setState( 'id', $myItemId );<br />
$items_model->get_item();</code></p>
<p>A detailed explanation of this code can be found in <a href="http://www.corephp.com/blog/joomla-mvc-load-a-model-from-anywhere/#more-2058">the original blog post</a>. Basically, this code imports the core model class, then the component&#8217;s model and instantiates it. Then it sets a state and fetches an item. Easy enough. The point made by corePHP is that you can do this from anywhere, not just from one particular view, but also from say, modules or even other components.</p>
<h2>The same MVC code, Nooku style</h2>
<p><code>KFactory::get('admin::com.foo.model.items')<br />
->id($myItemId)<br />
->getItem();</code></p>
<p>Shorter yes, but not very different you say, somewhat disappointed, since you were expecting white rabbits to jump out of a hat as soon as &#8220;Nooku&#8221; was mentioned. </p>
<p><strong><em>And where is that 80% source code reduction those Nooku developers always brag about?</em></strong> </p>
<p>If you just look at the character count, you will see that we have reduced the amount of code by 75% already. We coders like to talk lines though, so going from 5 to 3 lines looks like nothing more than a 40% reduction, right? Well… no, actually, there&#8217;s more to it! Lets look at the details: </p>
<ul>
<li>The Nooku Framework loads the classes you need, based on the identifier string &#8220;admin::com.foo.model.items&#8221;, so you don&#8217;t have to think about calling JLoader. </li>
<li>Nooku has a <a href="http://martinfowler.com/bliki/FluentInterface.html">fluent interface</a>, and methods return the object so you can chain calls together. (notice only one semicolon)</li>
<li>Notice: There is no id method (line 2) in the model. The call is therefore caught by the magic <a href="http://php.net/__call">__call</a> method in the framework model we&#8217;re using, which will act as a state setter for the model, and effectively it sets the id state to be $myItemId. Short &#038; sexy.</li>
<li>And now to the most interesting part: In a web application framework like Nooku, getting an item from a model based on an ID is perhaps simplest thing you can do. It&#8217;s only logical that the framework should be able to handle usecase out of the box. Therefore it&#8217;s very likely that in the Nooku version of this code, you wouldn&#8217;t find a FooModelItems class at all. What happens instead, is that when KFactory::get() is called and the class is not found, the framework falls back to a default class, which is more than capable of handling this usecase.
<p><strong>So the really big code reduction here is that you don&#8217;t have to write the model class at all.</strong></li>
</ul>
<p>While I enjoyed corePHP&#8217;s tutorial on reusing a model and really agree with the concept of reusing code, it kind of just scratches the surface of what you can really do with very little code. So I am going to give a short intro to HMVC, with a practical Nooku example.</p>
<h2>Moving on from MVC to HMVC</h2>
<p>Yes, HMVC. That&#8217;s MVC with an H in front of it. HMVC looks like something more than just MVC too, doesn&#8217;t it? And it is! I won&#8217;t go into the details Martin Fowler style, but instead just give you a taste of what you can do with it.</p>
<p><strong>Short explanation of HMVC:</strong> HMVC stands for Hierarchical Model View Controller. Normally, in MVC, you would have one controller setting states in one model, you&#8217;d be fetching data from the model and displaying them in a view. The three classes working together here (MVC) is called a triad. In HMVC though, you can have one triad call up and use another triad, so that multiple MVC triads are used together. You could even chain this further and have the second triad call up a third one. </p>
<p><strong>Here&#8217;s a practical real-life example</strong> which I have lifted off the <a href="http://nooku.assembla.com/code/nooku-examples/subversion/nodes">com_harbour extension</a> written by Christian Hent (<a href="http://twitter.com/christianhent">@christianhent</a>):</p>
<p>In com_harbour, you have a port view, where information about a port is shown. This could be for example &#8220;The Port of New York&#8221;. Within the port view, you want to also display all the boats which are registered under this port. </p>
<p>Lets look at the code:</p>
<h3>The basics: Showing the port info</h3>
<p>I&#8217;ll not bore you with the details here. It&#8217;s a bit different than Joomla (read: easier), but you should be able to understand it:</p>
<p><code><br />
&lt;h1&gt;&lt;?= $port-&gt;name; ?&gt;&lt;/h1&gt;<br />
&lt;h2&gt;&lt;?= @text(&#39;description&#39;); ?&gt;&lt;/h2&gt;<br />
&lt;p&gt;&lt;?= $port-&gt;description; ?&gt;&lt;/p&gt;<br />
&lt;h2&gt;&lt;?= @text(&#39;boats&#39;); ?&gt;&lt;/h2&gt;<br />
…<br />
</code></p>
<h3>The HMVC part: Showing the port&#8217;s boats</h3>
<p>Now, here I want to display the list of boats that hail to this port, and I accomplish that with these lines of code:<br />
<code><br />
&lt;?=<br />
    KFactory::tmp('site::com.harbour.controller.boat')<br />
        ->harbour_port_id($port->id)<br />
        ->layout('table')<br />
        ->browse();<br />
?&gt;<br />
</code></p>
<p>That&#8217;s it!</p>
<p><strong>Line–by-line explanation:</strong></p>
<p>Line 1: &lt;?= is a shorttag for &lt;?php echo. This is parsed in Nooku and makes those handy shorttags compatible across webservers.<br />
Line 2: Fetch the boat controller object, using KFactory::tmp() this time, so always creating a new object.<br />
Line 3: Set harbour_port_id = $port->id<br />
Line 4: Set layout = &#8216;table&#8217;<br />
Line 5: Call the controller&#8217;s Browse action (Browse as the B in <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete" title="Browse Read Edit Add Delete">BREAD</a>)</p>
<p>So what am I really doing here? Well, you could look at it as if I was displaying contents I had just fetched from this URL:<br />
<code>index.php?option=com_harbour&#038;view=boats&#038;layout=table&#038;harbour_port_id=X</code></p>
<p><strong>In other words: </strong>The boat controller is called, it will in turn set the harbour_port_id as a state in the model and register what layout to use. Then, when the browse action is called (Observe: Browse = show multiple items, Read = show one item), the model will return all items that matches it&#8217;s current state and they will be displayed in the table layout.</p>
<p>…and all of that happens with one line of code, in our ports view.</p>
<p>This is just one of the basic ways that <a href="http://www.nooku.org/framework.html">Nooku Framework</a> makes life as a Joomla developer worth living again :)</p>
<h3>Read more on HMVC</h3>
<p><a href="http://www.torkiljohnsen.com/2010/12/28/split-views-using-nooku-framework/">Split views using Nooku Framework</a><br />
<a href="http://www.codewalkers.com/c/a/Miscellaneous-Code/A-Sample-Web-Application-with-the-HMVC-Design-Pattern/">http://www.codewalkers.com/c/a/Miscellaneous-Code/A-Sample-Web-Application-with-the-HMVC-Design-Pattern/</a><br />
<a href="http://net.tutsplus.com/tutorials/php/hvmc-an-introduction-and-application/">http://net.tutsplus.com/tutorials/php/hvmc-an-introduction-and-application/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/09/14/advancing-from-joomla-mvc-to-nooku-hmvc/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Taking Joomla Forward</title>
		<link>http://www.torkiljohnsen.com/2010/08/13/taking-joomla-forward/</link>
		<comments>http://www.torkiljohnsen.com/2010/08/13/taking-joomla-forward/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 13:24:26 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[joomla]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=329</guid>
		<description><![CDATA[I write code, so I care mostly about what&#8217;s happening to the Joomla Framework. Or should I say not happening? The Joomla project needs more coders and less talkers, to put it bluntly, much like a boat won&#8217;t get anywhere with just captains and no rowers. More and more people in the Joomla community seems [...]]]></description>
			<content:encoded><![CDATA[<p>I write code, so I care mostly about what&#8217;s happening to the Joomla Framework. Or should I say not happening? The Joomla project needs more coders and less talkers, to put it bluntly, much like a boat won&#8217;t get anywhere with just captains and no rowers. More and more people in the Joomla community seems to realise this and are taking up responsibility and working outside the core code to make the improvements needed in various areas. Let&#8217;s take a look…<br />
<span id="more-329"></span></p>
<h2>The frameworks and the CCKs</h2>
<p>The Joomla Framework and the Joomla content component are two of the most vital parts of Joomla if you ask me. Now, look at the number of extensions that exists that are replacing these core parts in improved ways: </p>
<p>K2, jSeblod, FLEXIcontent, Sobi2 and others are dominating in the CCK/ACL section of things, improving content management in Joomla greatly. Gantry, Morph and T3 are template frameworks looking to make template production easier and templates more stable and feature rich. And for the core framework itself there are multiple replacements available, like <a href="http://nooku.org">Nooku</a>, which is Joomla flavoured and my favourite. Others again, like <a href="http://jomsocial.com">JomSocial</a>, are just to replacing the Joomla core framework with <a href="http://www.jomsocial.com/docs/Installation">something entirely different</a>.</p>
<p><strong>So what am I really saying here?</strong></p>
<p>This shows that Joomla is not providing the functionality that the community needs. It is not able to keep up with the pace of which the world is moving, so people go elsewhere to get their fix, or they create their own solutions to scratch their own itch. Joomla is, as Hannes Papenberg points out, <a href="http://groups.google.com/group/joomla-dev-cms/browse_thread/thread/286c8777f46b7527/1e9bc2e240295fbd?#1e9bc2e240295fbd">already years behind</a> in development, and while Joomla 1.6 may and may not be too far away, it is still outgunned by solutions already available to us. Even by Joomla extensions.</p>
<h2>So, development is too slow. What can we do?</h2>
<p>A clear choice, as <a href="http://groups.google.com/group/joomla-dev-cms/browse_thread/thread/a477a550bb051f29/8d6104dbe4b804d5?lnk=gst&#038;q=years+behind#8d6104dbe4b804d5">suggested by Daniel Chapman</a> and others, is for Joomla to pick up existing best-of-breed GPL frameworks that are Joomla compatible, and integrate them into the core, to make up for lost time.</p>
<blockquote><p>This would bring J! up to date almost overnight, and reduce the confusion and bloat of having different fw&#8217;s for every major extension you install.<br />
<em>- Daniel Chapman</em></p></blockquote>
<p>Don&#8217;t get me wrong: I&#8217;m a supporter of the idea of a slim and light core. Today&#8217;s core is packed with outdated extensions that have passed their expiration date a long time ago. When the framework changes, very often all the components have to be changed too. I hardly ever even use them personally. They have become a burden, and should be removed:</p>
<p>The content component is poor on features compared to most of the CCKs, and don&#8217;t get me started on com_contacts or com_weblinks. Com_search does an awful job at searching and does not prioritise the search hits at all. Routing is a pain, <a href="http://twitter.com/nikosdion/statuses/20960916821">even for seasoned developers</a>. Com_mailto, com_newsfeeds, com_contact, com_banners… They all have extensions that does the job better.</p>
<p>I&#8217;m not saying we should pack Joomla with cool new extensions, just that we need a solid foundation to build on and make it easier to create cool, quality extensions. <a href="http://www.torkiljohnsen.com/2010/07/15/what-is-nooku-framework-and-why-should-i-care/">And that&#8217;s where frameworks come in handy</a>.</p>
<p><strong>So why won&#8217;t Joomla adapt external frameworks?</strong></p>
<h2>Volunteer contributions are worthless</h2>
<p>I am no Deep Throat insider, but in my opinion, <a href="http://community.joomla.org/blogs/leadership/1074-investing-in-joomlas-development.html">the decision</a> to give a salary to two core developers and not any other contributors at all, was a landmark in Joomla history. With this, Joomla effectively put a price tag on the projects estimated value of volunteer community contributions, and the value was $0. If I had still been a working group member and contributor, and then suddenly seeing Open Source Matters decide that two people should be paid for their work while the rest of us were deemed unworthy, I would not be very happy.</p>
<p>Paying developers like this can also get in the way of the natural flow of contributors in FOSS projects. A paid developer suddenly has lots of reasons to cling on to his job and shut other contributors out. Instead, lead developers should be encouraged to open things up, or even pass on their responsibility at some point to someone with new ideas and loads of fresh motivation. Money just may be too good of a motivation not to do so.</p>
<p>I think this is part of the cause of Joomla&#8217;s low <a href="http://en.wikipedia.org/wiki/Bus_factor">bus factor</a>. The decreasing community contributions is a problem that is <a href="http://groups.google.com/group/joomla-wg-production/msg/fd610ace7e13d650?">beginning to sink in with the leadership too</a>. Strength may not necessarily be in numbers, but a lack of numbers is taking it&#8217;s toll. </p>
<h2>Community is taking charge</h2>
<p>This and other things, for instance the Joomla leadership&#8217;s deliberate ignoring of the first community organized international Joomla event, <a href="http://jandbeyond.org">J and Beyond 2010</a>, is truly a sad turn of events for the project itself. Not only was the JAB10 event ignored, it was also officially and directly counteracted, by <a href="http://www.joomla.org/announcements/general-news/5277-inaugural-joomla-world-conference-announced.html">joomla.org promoting other events instead</a>.</p>
<p>If someone decided to take it upon themselves to host an event to promote <strong>my</strong> product, and pay for it themselves too, I would make sure that they got as much attention and credit for their work as I could possibly give them.</p>
<p>On the bright side for Joomla though, community is stepping in where leadership is having issues. Like with <a href="http://www.alltogetherasawhole.org/">ATAAW</a>, <a href="http://jandbeyond.org">JAB10</a> (see also <a href="http://search.twitter.com/search?q=%23jab11">#jab11</a>!), <a href="http://joomlaforward.org">JFWD</a>, <a href="http://magazine.joomla.org/">JCM</a> and <a href="http://people.joomla.org/groups/viewgroup/119-Joomla+UX.html">J!UX</a>, consisting of volunteers aiming to contribute to Joomla in various ways.</p>
<h2>Your turn</h2>
<p>If you made it this far, you&#8217;re obviously interested in Joomla, and probably using it already. What are your hopes for the future? Do you thing there is still hope for even the most zealous Joomla fans out there? In which direction would you like the project to go?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/08/13/taking-joomla-forward/feed/</wfw:commentRss>
		<slash:comments>64</slash:comments>
		</item>
		<item>
		<title>What is MVC, and why should I care?</title>
		<link>http://www.torkiljohnsen.com/2010/07/17/mvc-explained-with-benefits-and-examples/</link>
		<comments>http://www.torkiljohnsen.com/2010/07/17/mvc-explained-with-benefits-and-examples/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 09:02:25 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[joomla]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[Nooku]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=170</guid>
		<description><![CDATA[Those of you following blogs and tweets in the Joomlasphere and reading about Nooku, might have read and learned about MVC and HMVC already. If not, here is a short explanation on MVC, and why you should care about design patterns and MVC in particular, especially if you&#8217;re a Joomla user. Design patterns Design patterns [...]]]></description>
			<content:encoded><![CDATA[<p>Those of you following blogs and tweets in the Joomlasphere and reading about Nooku, might have read and learned about MVC and HMVC already. If not, here is a short explanation on MVC, and why you should care about design patterns and MVC in particular, especially if you&#8217;re a Joomla user.<span id="more-170"></span><br />
<a name="design_patterns"></a><br />
<h2>Design patterns</h2>
<h3>Design patterns are reusable solutions</h3>
<p>First of all, MVC is an <em>architectural design pattern</em>. Yeah, that&#8217;s a mouthful. What is a <em>design pattern</em>? Well think of it like this: Patterns are stuff that repeats itself, right? So a <em>design</em> pattern is a design that repeats itself, or you could say &#8220;is reused&#8221;. A design can in development terms be thought of as a solution, so when you hear the words &#8220;design pattern&#8221;, you can think <em>reusable solution</em>. </p>
<p>Reusable solutions are smart ways of solving similar problems without reinventing the wheel. An architectural design pattern like MVC is in other words a reusable solution to an architectural problem. Many computer softwares aren&#8217;t that different architecturally, so MVC is a solution that can be used in many circumstances.</p>
<p>By giving names to these design patterns, for instance MVC, developers can easily communicate between one another how they are approaching or solving issues in their applications. For instance, if a PHP class in my code is called ArticleController (where &#8220;Controller&#8221; is the C in MVC), another developer that reads this code will immediately understand what the responsibility of this class is and what it should be able to do, because he understands the responsibility of the Controller in the MVC pattern. </p>
<h3>&#8230;like the wheel</h3>
<p>Speaking of not reinventing the wheel; the wheel itself could be seen as a design pattern: </p>
<p>We use the wheel in for instance cars, bicycles, buses and trains. So the wheel has indeed become a reusable solution to one common challenge: Making a vehicle easy to move. The wheels themselves are different on each vehicle because they are adapted to suit special circumstances, but the wheel concept itself is the same: Once the solution has been identified, it&#8217;s just a matter of putting it to good use. </p>
<p>So if you and I are building a vehicle that&#8217;s going to solve the challenge of transporting us from A to B, and I suggest that &#8220;we should put wheels on this thing&#8221;, then you&#8217;ll basically know what I&#8217;m thinking and we&#8217;ll also have a common understanding of how we&#8217;re going to build it. If we were to travel on a snow covered surface though, you could have suggested that we used a pair of skis as our solution, instead of the wheels. I would of course have slapped my forehead and agreed with you, without needing to see complicated blueprints or having long committee meetings.</p>
<p>That&#8217;s the advantage of having design patterns!</p>
<p>Jeff Atwood also has another nice MVC analogy in a blog post of his, see the link in the <a href="#references_and_footnotes">references &#038; footnotes</a> at the bottom.</p>
<p><a name="mvc"></a><br />
<h2>The building blocks of MVC</h2>
<p>The MVC pattern splits your code into three parts, often referred to as a triad: The Model, View and Controller. Here is a brief outline of what job each part does, particularly in the Joomla and Nooku Frameworks. </p>
<p>Note: This will teach you how to talk the talk, but not walk the walk! Oleg Nesterov&#8217;s presentation &#8220;Joomla Extension Kung Fu&#8221; provides some nice PHP code examples you can look at though to see MVC in action. See the link in the <a href="#references_and_footnotes">references &#038; footnotes</a> at the bottom of this article. I&#8217;d also recommend looking into the <a href="http://nooku.assembla.com/code/nooku-framework/subversion/nodes">Nooku Framework sourcecode</a> to see how MVC is implemented in PHP there.</p>
<p>Here are the basics though:</p>
<h3>Controller</h3>
<p>The controller is in charge, as the name would suggest. When you do a request, like for instance in a Joomla site entering example.com/index.php?option=com_content&#038;view=article&#038;id=13 in your browser, the controller in the content component takes care of getting the request data. For this request, we have the variables option, view and id visible in the URL. From that, the controller will set the model state so that the model, which is fetching the data for us later on, will know that it needs to fetch article number 13. The controller will then tell the article view to render itself. </p>
<h3>View</h3>
<p>The view decides what ends up on the screen. It will use the model to fetch the data it needs, load the template and display the content inside that template. In this case, the view requested is &#8220;article&#8221;, singular. In Nooku Framework, the view will automatically deduct from this that it needs to fetch a single item instead of a collection of items, as &#8220;articles&#8221; (plural) would have suggested. This is a small part of the &#8220;magic&#8221; happening underneath the hood in Nooku, which makes it so easy to work with.</p>
<h3>Model</h3>
<p>The model handles the data. If you need something added, edited, deleted or fetched to or from the database, the model is the class that will do the heavy lifting. The controller will set it&#8217;s states (like filtering, ordering etc), and then the model will do whatever it is told to do.</p>
<h2>Benefits and advantages of MVC, for all of us</h2>
<p>Why should you care about MVC and demand that your developers do the same? </p>
<h3>A clear separation of the code</h3>
<p>First of all, MVC splits your code into three distinct parts, each of which have clear responsibilities and limitations. When you&#8217;ve used this pattern for a while, deciding where to put a piece of code or look for a piece of code becomes intuitive and straight forward. This makes many parts of development a lot easier, because the design pattern dictates where the code should be located and what the code should do.<br />
It also makes it easier for other developers who know MVC to read and understand the code you have written, and after that, also extend or contribute to it, or even replace parts of it. </p>
<h3>Visual flexibility</h3>
<p>At the heart of MVC there is the desire to separate the presentation of data from the manipulation of data, partially because we want to reuse as much code as possible, but also because we want to be able to present one set of data in multiple ways. In the Joomla CMS for instance (version 1.5 and up), you have templates, and you can change templates to easily get a list of articles to look completely different without modifying the Joomla core code. Each template has the power to implement it&#8217;s own overrides for any view in any component in Joomla. Consequently, anyone can use their own template to make a component look exactly like they want to, given that the component in question follows the MVC design pattern of course. </p>
<h3>Formatting flexibility</h3>
<p>A new presentation of content need not only mean a new HTML template though: A list of articles can very well be displayed in a completely different format, like CSV, RSS, PDF or JSON. This can allow us to easily be able to reuse it in other parts of your website or even on other websites. So while the presentation or format of the data is different, the functionality used to fetch the data from the database is exactly the same every time. </p>
<h3>Replaceable parts</h3>
<p>On the opposite side: If I suddenly decide I want to store my articles in flat files instead of in a database, I can just modify the part of MVC that stores and fetches data, and leave the presentation part alone. The presentation of the data is in other words decoupled from the part of the application that communicates with the storage of the data.  </p>
<h3>Workflow</h3>
<p>My personal experience is that when working in teams, the separation of responsibilities in MVC makes it easy to divide the workload between team members. If a task on my task list just says &#8220;Article model&#8221;, then these two words also describe pretty well what it is that I need to do.</p>
<h2>Where to go from here?</h2>
<p>So how do I find out if my favourite component X follows the MVC pattern or not? Easy in most systems! In Joomla you can open the component&#8217;s folders, either administrator/components/com_x/ or components/com_x/ in a file browser or FTP client, and look for folders named &#8220;models&#8221; and &#8220;views&#8221;. If you find none, then the component is likely not using MVC the Joomla way. </p>
<p>If so, make sure to send the component&#8217;s developer an e-mail with a link to this article ;)</p>
<h2>Conclusions</h2>
<p>Design patterns are like wheels: They make things roll smoothly!</p>
<p><strong>The benefits of the MVC design pattern:</strong> It provides a logical and predictable architecture to work with and collaborate on, it allows us to reuse larger parts of our code, and it allows us to modify parts of our code while other parts can remain untouched. Less code equals less maintenance, and more decoupling of code gives better flexibility and extensibility.</p>
<p>More importantly: MVC is the Joomla standard, so if you&#8217;re building extensions for Joomla you should use MVC like the rest of us.</p>
<p><a name="references_and_footnotes"></a><br />
<h2>References &#038; further reading</h2>
<ol>
<li><a href="http://www.martinfowler.com/eaaDev/uiArchs.html">GUI Architectures</a>, by Martin Fowler</li>
<li><a href="http://www.slideshare.net/onesterov/joomla-extensions-kung-fu">Joomla Extension Kung Fu</a>, presentation by Oleg Nesterov given at J and Beyond 2010</li>
<li><a href="http://www.slideshare.net/HermanPeeren/design-patterns-illustrated">Design patterns illustrated</a>, presentation by Herman Peeren given at J and Beyond 2010</li>
<li><a href="http://www.codinghorror.com/blog/2008/05/understanding-model-view-controller.html">Understanding Model-View-Controller,</a> by Jeff Atwood</li>
<li><a href="http://blog.astrumfutura.com/archives/373-The_M_in_MVC_Why_Models_are_Misunderstood_and_Unappreciated.html">The M in MVC: Why Models are Misunderstood and Unappreciated</a>, by Pádraic Brady</li>
<li><a href="http://publib.boulder.ibm.com/infocenter/adiehelp/v5r1m1/index.jsp?topic=/com.ibm.etools.struts.doc/topics/cstrdoc020.html">Benefits of the MVC design pattern</a>, by the IBM Corporation</li>
<li><a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Wikipedia article on MVC</a>, which clearly states that MVC was coined by a Norwegian guy, so you&#8217;re obviously in good hands here! :)</li>
<li><a href="http://c2.com/cgi/wiki?PatternsForBeginners">Patterns for beginners</a>, by Falk Bruegmann</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/07/17/mvc-explained-with-benefits-and-examples/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>What is this Nooku Framework thing really? And why should I care?</title>
		<link>http://www.torkiljohnsen.com/2010/07/15/what-is-nooku-framework-and-why-should-i-care/</link>
		<comments>http://www.torkiljohnsen.com/2010/07/15/what-is-nooku-framework-and-why-should-i-care/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 00:43:21 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[joomla]]></category>
		<category><![CDATA[Nooku]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=146</guid>
		<description><![CDATA[Let me try to explain, in non-technical terms, what a framework is and why using the Nooku Framework is a good idea. Preface No, not &#8220;preface&#8221; as in &#8220;this is the start of a long and boring novel&#8221;. It&#8217;s just two quick preliminary pieces of information that you need to be aware of: Nooku Framework [...]]]></description>
			<content:encoded><![CDATA[<p>Let me try to explain, in non-technical terms, what a framework is and why using the Nooku Framework is a good idea.<br />
<span id="more-146"></span></p>
<h2>Preface</h2>
<p>No, not &#8220;preface&#8221; as in &#8220;this is the start of a long and boring novel&#8221;. It&#8217;s just two quick preliminary pieces of information that you need to be aware of:</p>
<ol>
<li>Nooku Framework is not to be confused with <a href="http://www.nooku.org/content.html">Nooku Content</a>. Nooku Content is more a competitor of <a href="http://joomfish.net">Joom!Fish</a>: It&#8217;s a Joomla component used for translating content. Nooku Content is also distributed only among paying partners in a partner programme. Nooku Framework however, is a programming framework, and it&#8217;s free and open source software (FOSS). Both products are backed by the same developers though, hence the similar names.</li>
<li>When I say framework, I really mean <em>software framework</em>, a term which Wikipedia <a href="http://en.wikipedia.org/wiki/Software_framework">defines and explains</a> really nicely. But don&#8217;t click that Wikipedia link for now. Instead, let <strong>me</strong> give you the short story, from a Joomla perspective:</li>
</ol>
<h2>What is a framework?</h2>
<p>A framework allows you to reuse common programming code, which is a good thing. Let me explain why by comparing a framework to something a lot easier: Your e-mail signature. In your e-mail software, like Outlook or Apple Mail, you write your e-mail signature once in your settings, then automatically use it whenever you send an e-mail. </p>
<p>This means:</p>
<ul>
<li>You spend less time writing your e-mail.</li>
<li>Time saved means you have more time to do what&#8217;s important: Focusing on the contents of your e-mail.</li>
<li>You get the signature right each time; In a stressful situation you might forget to include your phone number or even type your name incorrectly, but not when you&#8217;re using a predefined signature.</li>
</ul>
<p>The same thing goes for software frameworks from a programmer&#8217;s perspective:</p>
<ul>
<li>It saves you time by eliminating the need to do repetitive tasks, which means you can focus on what&#8217;s important: Finishing the application and making sure it meets the requirements.</li>
<li>You get less bugs in your system, because the parts handled by the framework have been used and tested earlier, and are usually  bug free. So the more framework code you use, the less bugs you should experience. More time saved.</li>
<li>An added bonus: A framework with multiple users allows people to find bugs together, in their shared, common code.</li>
</ul>
<h2>So what&#8217;s the difference between Nooku, Joomla and the Gantry Frameworks?</h2>
<p>I see many people asking this question, so I just had to answer it once and for all:</p>
<p>Nooku and Joomla try to accomplish the same thing: To make developing Joomla <em>components</em>, <em>plugins</em> and <em>modules</em> easier. This is primarily stuff happening under the hood you might say. <a href="http://www.gantry-framework.org/">Gantry</a> is a framework made by Rockettheme to make developing <em>templates</em> easier, which is more the facade of your website. </p>
<p>In other words, you can&#8217;t compare Gantry to the other two. Instead you should compare Gantry to the <a href="http://www.prothemer.com/morph/">Morph</a> Framework, which is rumoured to be Nooku based in the future, but that&#8217;s a whole different story.</p>
<h2>Why do I prefer Nooku Framework over Joomla&#8217;s own framework then?</h2>
<p>I have been a part of the Mambo/Joomla community since 2004, and I have written components both using the Joomla Framework and the Nooku Framework. So I have tried and tested both, and have decided to use Nooku for the following reasons:</p>
<ul>
<li><strong>It&#8217;s better.</strong> For me as a programmer. It reduces the amount of code I need to write by something close to 80%<sup><a href="#footnote1">1</a></sup>, which means more time for me to spend on creating new and cool stuff, and less bugs for you to get annoyed over. The only two programmers that I know of that have looked into Nooku and still decided they preferred the Joomla Framework, have been <abbr title="Open Source Matters">OSM</abbr> employees. I.e. the guys who are paid to develop the Joomla Framework.</li>
<li><strong>It makes me better.</strong> Nooku reuses solutions to common problems (called using design patterns) to a greater extent, and <a href="http://www.torkiljohnsen.com/2010/07/11/the-joomla-database-schema-smells/">unlike Joomla</a> it forces me to adhere to conventions and standards. No slacking around in other words. The predictability in the coding combined with strict data filtering gives my components easier extensibility and my clients better security. I&#8217;ve recently also started using HMVC, and I&#8217;m loving it.</li>
<li><strong>It&#8217;s Joomla compatible.</strong> Any Joomla website that needs custom functionality can start using Nooku to build that functionality, today. It installs like any other extension, and does not interfere with what&#8217;s already on your Joomla site and using the Joomla Framework.</li>
<li><strong>It&#8217;s cheaper.</strong> I know; too obvious. Less time spent programming + Less bugs = Lower development and maintenance costs.</li>
<li><strong>It&#8217;s the second generation.</strong> Yes, literally the second generation. You may now know, but both the Joomla and  Nooku Frameworks were built basically by the same guy: <a href="http://johan.janssens.me">Johan Janssens</a>. In fact, Johan is <a href="https://www.ohloh.net/p/joomla/contributors">still considered to be the largest contributor</a> to the Joomla codebase (by far!), even though he stopped working with Joomla in January 2008. He took with him the knowledge and lessons learned, and started from scratch to build something better: Nooku.</li>
<li><strong>It&#8217;s got a developer community.</strong> Unlike Joomla, development at the framework level is moving forward at a rapid pace, there is lots of activity, and developers are sharing and contributing code between themselves. In the web development industry, things are moving forward very quickly, and for the sake of myself and my clients, I need to keep up and stay sharp.</li>
</ul>
<p>So I choose Nooku.</p>
<p>If you&#8217;re a programmer yourself, go check it out at <a href="http://www.nooku.org/framework.html">http://www.nooku.org/framework.html</a>. If not, you should talk to whoever does the programming for you and make sure that they do.</p>
<h4>Footnotes</h4>
<ol>
<li><a name="footnote1"></a>The 80% figure is borrowed from <a href="http://nekkidninjas.com/index.php/2009/10/12/ninjaboard-countdown-to-launch-day-6">NinjaBoard&#8217;s comparison</a>. This, though, dates back to October 2009, after which the Nooku Framework has improved further, so the number should probably be higher than 80%.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/07/15/what-is-nooku-framework-and-why-should-i-care/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>The Joomla database schema smells</title>
		<link>http://www.torkiljohnsen.com/2010/07/12/the-joomla-database-schema-smells/</link>
		<comments>http://www.torkiljohnsen.com/2010/07/12/the-joomla-database-schema-smells/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 20:28:16 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[joomla]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=117</guid>
		<description><![CDATA[Back in 2006 I was a member of the standards and guidelines workgroup in Joomla, and during my involvement there I produced the Joomla 1.5 database schema as a DB Designer EER diagram, so people could view the database in a visual way. I recently also set up the Joomla 1.6 database schema, this time [...]]]></description>
			<content:encoded><![CDATA[<p>Back in 2006 I was a member of the standards and guidelines workgroup in Joomla, and during my involvement there I produced the <a href="http://www.torkiljohnsen.com/2006/04/30/joomla-15-database-schema/">Joomla 1.5 database schema</a> as a DB Designer EER diagram, so people could view the database in a visual way. I recently also set up the <a href="http://www.torkiljohnsen.com/2010/07/11/joomla-1-6-database-schema/">Joomla 1.6 database schema</a>, this time using MySQL Workbench which is a better tool for the job, and also GPL and available on multiple platforms. During my work with setting up the 1.6 schema, I came across lots of oddities and lacks of normalization, and a severe lack of naming conventions and guidelines became obvious.<br />
<span id="more-117"></span></p>
<h2>Improvement suggestions</h2>
<p> I have listed a few of these below, and please add comments to this post if you find some of your own or you disagree with me, and I&#8217;ll adjust this list accordingly.</p>
<h3>Naming conventions</h3>
<p>I primarily want to address the lack of standards in this schema, <a href="http://forum.joomla.org/viewtopic.php?p=298129#p298129">which I even reported back as early as in 2006 when creating the 1.5 schema</a>. In coding, the concept of <a href="http://en.wikipedia.org/wiki/Convention_over_configuration">convention over configuration</a> gives predictability, simplicity and reduces the amount code you have to write later on. Same goes for database schemas and Joomla: The better the schemas follow the naming conventions, the less PHP code you&#8217;ll have to write later on. Convention also eliminates ambiguity, and developers won&#8217;t be <a href="http://www.python.org/dev/peps/pep-0020/">tempted into guessing</a>. Just <em>having</em> a convention for column names in the database would be a nice first step, both for Joomla and 3rd party developers alike. Right now, column names for instance are a sweet mix of abbreviations and non-abbreviations, both underscored and camelCased names. Plus, the column <em>id</em> is used to name most INT primary key names but not all.</p>
<p><strong>A prime example of Joomla&#8217;s lack of conventions</strong> can be seen in the <em>content</em> table, where we have these five foreign key columns: <em>catid</em>, <em>sectionid</em>, <em>language</em>, <em>checked_out</em> and <em>asset_id</em>. The first is abbreviated with no underscore, the second is also without underscore but not abbreviated, the third does not look like a foreign key because it has no &#8220;id&#8221; in it&#8217;s name like the others, but it holds the language code for the article, and thus references language.lang_code (Who would have known?). The fourth contains has no &#8220;id&#8221;-hint, and no hint to the fact that it refers to users.id. Finally, the fifth column is not abbreviated but with underscores (the way I like it personally). Five different naming conventions in one single table, if we should at all should acknowledge &#8220;checked_out&#8221; as some sort of readable standard foreign key for <em>user.id</em>. </p>
<p><strong>Also check out</strong> and compare <em>content.created_by</em> and <em>categories.created_user_id</em>. They both reference the same column. Weird huh? See the lack of convention? Which format do you prefer?</p>
<h3>Table names</h3>
<p>For consistency, I would propose changing using plural names on tables. Just a little something I got used to while using <a href="http://nooku.org">Nooku</a>. Most tables are already pluralised, and tables normally contain multiple rows, so it makes most sense to use pluralisation as the standard and thus renaming the following tables:</p>
<ol>
<li>content renamed to <em>contents</em></li>
<li>content_frontpage renamed to <em>contents_frontpage</em></li>
<li>content_rating renamed to <em>contents_ratings</em></li>
<li>menu renamed to <em>menus</em></li>
<li>modules_menu renamed to <em>modules_menus</em></li>
<li>session renamed to <em>sessions</em></li>
</ol>
<h3>Primary keys</h3>
<p>Primary keys are important, as they are used for row identification, and will therefore play a big part in the PHP code we write for our applications and extensions.</p>
<h4>Names</h4>
<p>Most tables have a primary key column named &#8220;id&#8221;, but not all tables follow this rule. The languages table has lang_id, update_sites has update_site_id, update_categories has categoryid, etc. In other words: Lots of inconsistensies and no clear naming convention. </p>
<p>Nooku is a good example of a framework that imposes a convention which allows the PHP-code to interpret the database structure automatically, and only requires you to write code for those few special cases that don&#8217;t fit the blueprint at all. Nooku uses the following convention for primary key names: <em>componentname_tablename_id</em>. For the articles table in <em>com_content</em>, the Nooku table name would have been <em>content_articles</em>, and the primary key would have been <em>content_article_id</em>. Notice the plural formed table name and the singular column name. Logical, since the table represents a collection of items, and the column identifies a single one.</p>
<p>Next, I would wish for the foreign keys to also use the full name of the column they are referencing. So instead of those abbreviated catid columns all over the place, you use for instance category_id.</p>
<h4>Field types</h4>
<p>A lot of the tables have an auto increment INT type of primary key, which is to be expected, but there is no clear standard as to what datatype this field should be. Some are unsigned, some are not, some are INT, some are INT(10) and some INT(11). There is no reason why these should not just follow a common standard.</p>
<h4>The INT key sickness</h4>
<p>Very often you will find yourself using a primary key column for your table named something_id, and it will have the field type in the shape of a large integer. This is typical for relational databases, so don&#8217;t be alarmed, but don&#8217;t stop thinking either. The primary key in a table is something that can uniquely identify each and every record in that table. If you already have such a column, then there is no need to add another integer. </p>
<p>Consider these examples from the Joomla database:</p>
<p>The <strong>language</strong> table has a lang_id INT(11) column. This really seems redundant, as the lang_code field, CHAR(7), uniquely identifies the language just fine. In the menu table, and all other tables using multilingual features, you have the column <em>language</em> which is also a CHAR(7), and references lang_code. It&#8217;s weird, and bad code, to use a foreign key to reference a column that&#8217;s not a primary key, and not even unique. It&#8217;s also hard to see the connection from <em>menu.language</em> to <em>languages.lang_code</em> too. As before: Consistent naming would really help; why not call it menu.lang_code instead?</p>
<p>Similarly, in the <strong>redirect links</strong> table, the old_url-field is what really should identify redirect links. You can&#8217;t have multiple redirects for one old url, hence every row in this table is uniquely identified by it&#8217;s old_url column, so that should be the table redirect_links&#8217; primary key. Consequently, the id INT field seems redundant here too.</p>
<h2>An oddity: ACL</h2>
<p>Viewlevels are in the database connected to usergroups via JSON-encoded data in the column <em>viewlevel.rules</em>. The column name is misleading, but it is even more strange to see foreign keys stacked up in a pure JSON-encoded field like this, instead of for instance creating a table for <em>usergroups_viewlevels</em>, to connect the <em>usergroups</em> and <em>viewlevels</em> tables, similar to for instance <em>modules_menu</em>, which connect modules to menu items.</p>
<p>There is probably an explenation here, and it probably got something to do with performance, pragmatism or laziness. I just think it&#8217;s bad database design, that&#8217;s all. Maybe someone out there, who has been deep into the ACL system, can explain this to me?</p>
<h2>Also strange: Extension update sites</h2>
<p>This part of the database seems incomplete and unfinished, even though this schema is supposed to be a beta. For instance the <em>update_sites_extensions</em> table allows null values in it&#8217;s two fields <em>extension_id</em> and <em>update_site_id</em>, and a unique key is nowhere to be found in the table. This might just not be a feature due for Joomla 1.6, but then I would not see the reason for introducing these tables in the first place.</p>
<h2>Other things</h2>
<p>There are so many other things, but I can&#8217;t be bothered to write them all down. I actually started writing a section in this article about recommendations for normalization, changes in column names, types and usages, but the list already had six elements before I was finished going through two of the ten or twelve large tables in this schema.</p>
<p>This database schema suffers because of legacy issues, and a parts of it probably dates back even as far as the Mambo days. You can really see the same things happening in the user interface. Or should I say not happening? Instead of being a constantly renewed, improved and refactored CMS and framework, Joomla bears both the visual and codewise smell of patchwork and old legacy code. </p>
<p>Because of the obvious lack of progress in the Joomla project, I fear that this will be the last database schema for Joomla I will make; The web world is moving forward, but Joomla seems to be stuck. We strive to provide our clients and ourselves with the best tools of the trade, and that&#8217;s what I&#8217;ll keep doing. I hope I am proven wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/07/12/the-joomla-database-schema-smells/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Joomla 1.6 database schema</title>
		<link>http://www.torkiljohnsen.com/2010/07/11/joomla-1-6-database-schema/</link>
		<comments>http://www.torkiljohnsen.com/2010/07/11/joomla-1-6-database-schema/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 17:40:43 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[joomla]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=73</guid>
		<description><![CDATA[As some might remember I made a visual representation of the Joomla 1.5 database schema back in 2006. I have now set up an EER representation of the Joomla 1.6 database schema too, that you can download for free. This schema was made after the 1.6 beta 2 release, and it was built using MySQL [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.png"><img src="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema-150x150.png" alt="joomla 1.6 database schema thumbnail" title="joomla 1.6 database schema thumbnail" width="150" height="150" style="float:right; margin-left: 20px;" class="size-thumbnail wp-image-120" /></a>As some might remember I made a visual representation of the <a href="http://www.torkiljohnsen.com/2006/04/30/joomla-15-database-schema/">Joomla 1.5 database schema</a> back in 2006. I have now set up an EER representation of the Joomla 1.6 database schema too, that you can download for free. This schema was made after the 1.6 beta 2 release, and it was built using <a href="http://wb.mysql.com/">MySQL Workbench</a>, which is both GPL and available as a free download for multiple platforms.<br />
<span id="more-73"></span><br />
First of all: If you find any errors in this schema, make sure you leave a comment for me at the bottom. Because of the lack of conventions for naming primary key columns, I am left to do a lot of guesswork here when drawing up table relations, so there may be errors. Pretty much the only table that&#8217;s easy to read is the menu table, which has descriptive column comments. Make sure you read the notes below the download links too.</p>
<p><strong>Update: </strong>With the release of 1.6 beta 5, I just did a diff between the schema for 1.6 beta 2 and 1.6 beta 5, and they are identical.</p>
<p><strong>DOWNLOAD available in different formats:</strong></p>
<ul>
<li><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.mwb">MySQL Workbench format (.mwb), 90 kB</a> needs <a href="http://wb.mysql.com/">MySQL Workbench</a> to use.</li>
<li><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.png">PNG format, 2652 * 2658 pixels, 800 kB</a></li>
<li><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.pdf">PDF format, 1 MB</a></li>
<li><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.svg">SVG format, 2 MB, to view directly in modern browsers</a></li>
</ul>
<h2>Schema modifications</h2>
<p>Here are some modifications that <u>I personally have done</u> in various places in the schema to be able to reproduce it visually in MySQL Workbench, and make it more readable. This does mean that that <u>this schema is not 100% identical</u> to an actual Joomla 1.6 installation, because of these changes. For instance it also has foreign key relations drawn in, whereas MySQL&#8217;s MyISAM tables don&#8217;t support those. This schema should therefore only be used as a visual supplement to Joomla development.</p>
<p>Here are the changes that makes this schema differ from an actual Joomla 1.6 installation:</p>
<h3>Invisible relations</h3>
<p>This is not something I have changed, but something I deliberately did not touch. For claritys sake, some foreign relations to the users table have been left out. For instance created_by, modified_by, locked_by, created_user_id, modified_user_id and checked_out all reference the field <em>users.id</em>. If I was to set up all these relations, the schema would become so crowded with relationship indicators that it would be virtually unreadable.</p>
<p>There is also a &#8220;relation&#8221; here between the tables viewlevels and usergroups, but that&#8217;s not solved in SQL: All usergroups that belong to a viewlevel are put into an array that is JSON encoded and stored in the <em>viewlevel.rules</em> field. This is not a foreign key in SQL, so the relation is not show in the schema.</p>
<h3>Changed column types</h3>
<p>If a column is referencing another column in the database (like a foreign key), these columns need to be the same datatype. A lot of the time, this is not the case in Joomla, for some strange reason. To represent real foreign key relations in MySQL Workbench, this needed to be changed, or else <abbr title="MySQL Workbench">MWB would not even allow the relations to be made at all. We have had issues like these all the way back since Joomla 1.0. Hopefully they are picked up and fixed soon, because fixing this should not be a problem for backwards compatibility. </p>
<p>Here are the columns I have had to change:</p>
<ol>
<li>modules_menu.moduleid has been changed from an INT to an INT(11), since it references modules.id</li>
<li>In two places, asset_id foreign key was of datatype INT, but referencing asset.id it should have been INT(10), so those foreign key relations have changed, and this affects the following tables; categories, content</li>
<li>Similar to asset_id, catid columns were also of datatype INT, whereas they should have been INT(11) since they are referring to categories.id, which is an INT(11). This occured in the following tables: banners, contact_details, content, newsfeeds, weblinks</li>
<li>user_usergroup_map.user_id, messages_cfg.user_id, messages.user_id_from, messages_user_id_to all reference user.id, hence they can&#8217;t be an unsigned INT, but has to be a signed INT.</li>
<li>Multiple occurences of user_id references user.id, so they must be INT, not INT(11). This affects the following tables: user_profiles, session (although the field is named <em>userid</em> in the session table, without the underscore).</li>
<li>schemas.extension_id has been changed from INT(11) to INT, since it references extensions.extension_id</li>
<li>update_sites_extensions.update_site_id changed from INT to INT(11), since it references update_sites.update_site_id, which is an INT(11). Both columns in update_sites_extensions got a NOT NULL attribute added, since they make no sense without it.</li>
</ol>
<h3>Changed column ordering</h3>
<p>Column ordering in some tables has been changed so that foreign keys are listed just below primary keys, as I feel that this is cleaner and makes the relations easier to read. The changes were so many that I gave up trying to write a complete list.</p>
<p>All in all, this schema badly needs an overhaul, to say it mildly. I have written a short blog post explaining <a href="http://www.torkiljohnsen.com/2010/07/11/the-joomla-database-schema-smells/">why I think the Joomla database schema smells</a>.</abbr></p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/07/11/joomla-1-6-database-schema/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Installing Phing on MAMP (Mac OSX)</title>
		<link>http://www.torkiljohnsen.com/2009/04/06/installing-phing-on-mamp-mac-osx/</link>
		<comments>http://www.torkiljohnsen.com/2009/04/06/installing-phing-on-mamp-mac-osx/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 09:54:38 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[joomla]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mamp]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[phing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web apps]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/2009/04/06/installing-phing-on-mamp-mac-osx/</guid>
		<description><![CDATA[Just bumped into Phing, and thought I&#8217;d share my experiences. Installing Phing is easy enough. Phing is a build system in the shape of a PHP Pear package, that can do many things. To quote Hans Lillelid, this could include for instance configuring, packaging, uploading and testing. Ideal for building installable Joomla zip-files, which is [...]]]></description>
			<content:encoded><![CDATA[<p>Just bumped into Phing, and thought I&#8217;d share my experiences. Installing Phing is easy enough. Phing is a <em>build</em> system in the shape of a PHP Pear package, that can do many things. To quote <a href="http://www.slideshare.net/hozn/phing-building-with-php">Hans Lillelid</a>, this could include for instance configuring, packaging, uploading and testing. Ideal for building installable Joomla zip-files, which is what I am using it for right now.<br />
<span id="more-70"></span><br />
This is how I set up Phing to run on my local MAMP-based webserver. MAMP = Apache, MySQL and PHP, on a Mac, much like WAMP and LAMP for Windows and Linux respectively. </p>
<p>These are just very brief instructions, specifically on how I did this on my own system. A complete documentation on Phing can be found on at <a href="http://phing.info/docs/guide/current/">phing.info</a>. You don&#8217;t actually need MAMP either, it was just what I was working with to begin with. </p>
<p>Open the application Terminal. You can find pear by doing a locate call: locate pear.<br />
Currently MAMP requires you to install it into /Applications, so you should find pear (for php5) here: /Applications/MAMP/bin/php5/bin/.<br />
Make sure MAMP is using the correct php version, by starting MAMP and checking your preferences.</p>
<p>1: Go to the correct folder:<br />
cd /Applications/MAMP/bin/php5/bin/</p>
<p>2: Make sure pear can locate the package:<br />
./pear channel-discover pear.phing.info</p>
<p>3: Install phing:<br />
./pear install phing/phing</p>
<p>Phing should now be installed. Run the command &#8220;ls -al&#8221; and you should see phing in the same folder as pear.</p>
<p>You can now run this command:<br />
./phing -h<br />
This will give you an overview of the phing&#8217;s options. </p>
<p>From here you can for instance just run:<br />
./phing -f /path/to/your/build.xml</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2009/04/06/installing-phing-on-mamp-mac-osx/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.668 seconds -->

