Development Blog

MySQL 5.6 Update – Strict Default

Yesterday I updated an in-house server’s MySQL version from 5.5 to 5.6 and ran into what seemed to be a ton of new problems, but it was all due to a new default MySQL configuration setting. If you’ve just upgraded and you’re getting lots of errors about default values and invalid value types (empty strings for integer fields, etc.), it’s probably the same issue. MySQL 5.6 defaults to more strict data handling for InnoDB (and other transactional) tables.

It would obviously be better to fix the errors, but if you’re working with a lot of old scripts and need a quick temporay fix, try editing your database configuration file (my.cnf) to change this:




For more information, see:

Flat Flashlights from Mock-Epic LLC

Flat FlashlightsLast week we launched a new retail e-commerce website from our sister company, Mock-Epic LLC. I really like this product – magnetic flat flashlights with bright LED bulbs and full color artwork on a high-quality plastic label. They are from the SmashLight® family of products from Bentcil®, and we’re making them available retail, in small quantities and bulk.

The SmashLight® Messenger™ is our lowest price option, with an on/off pressure switch, large artwork area, and extra flat (.25″) design.

The SmashLight® Glow™ is .5″ thick and includes a physical on/off button and a fantastic backlit art area illuminated by 2 additional LED bulbs.

This is a product I’ve decided to sell because I like it so much… they’re hanging on my refrigerator, metal filing cabinet, electrical box and stashed away in half a dozen other places. I hope you like it too. For more information, see Mock-Epic LLC or

PHP Broken Array from json_decode Object

I ran into an odd PHP thing (bug?) today. I had an object that had been extracted from a string using json_decode. After type-casting it to an array, any entries stored with numeric keys were inaccessible when calling by key, though iteration worked fine.

Here’s a simplified example:

// make an associative array
$myList = array(
// json encode to string
$myList = json_encode($myList);
// json decode to object
$myList = json_decode($myList);
// typecast back to array
$myList = (array) $myList;
// test output
$test1 = (array_key_exists(4, $myList))
	? $myList[4] : 'nothing!';
$test2 = (array_key_exists('nine', $myList))
	? $myList['nine'] : 'nothing!';
echo 'test1: '.$test1.', test2: '.$test2;

Read more

Get Field Label Text in Joomla 2.5 JForm

I’m switching back and forth between projects in Joomla 3.X and Joomla 2.5… to get the field label text (not the HTML tags, just the text) from a JFormField object is simple enough in Joomla 3.X, since the class has a getAttribute() method, so:

$field = $form->getField('myfield');
$label = $field->getAttribute('label');

I could be mistaken, but didn’t see the same functionality in Joomla 2.5. The closest I’ve come up with is to get the full label, then strip out the HTML tags, like:

$field = $form->getField('myfield');
$label = strip_tags($field->__get('label'));

…which is ugly, but seems to work in the cases I’ve tested. Anyone know of a better way to access the element attributes directly in Joomla 2.5?

ProcessForm 3.0.18 Security Update

We’ve just posted a security patch update to the old/archived script ProcessForm. It is strongly recommended that any existing users update to the latest version. We’re working hard on a complete re-write of the script, but in the meantime, will continue releasing patch updates as issues are found.

New eCommerce Site:

We’re launching a new custom Joomla eCommerce site this week. I’m especially excited about this one, because it’s one of my own ventures, via Mock-Epic LLC. The first retail site is, which sells twisted pens (some of which we make here in-house). We hope to have a total of three retail sites online before this summer. Looking forward to it!

Joomla 2.5 – stuck redirecting to index.php for 404

I’ve just spent the last few hours troubleshooting why a Joomla 2.5 site I’m working on was redirecting to the home index.php page for bad URLs instead of loading my template’s custom error.php page. Instead of the 404 response code, it was returning a 303 response: 303 See other

From what I can tell, it was because in the Global Configuration settings, I had the site offline for testing. So apparently even if logged in as a user who can view the offline site, it still won’t load the error page until the site is back online. When I put it back online, the 404 response was loading as expected… now I know.

Retrieving Custom Profile Data from Joomla User Account

I’ve been experimenting with modifying a copy of the Joomla “profile” plugin (/plugins/users/profile) and adding custom profile fields to use in other Components. Retrieving those stored profile values required some research, but it turns out it’s pretty straight-forward:

$User = JFactory::getUser();
$Profile = JUserHelper::getProfile(User->id);

From there, it may be easiest to just use the print_r() function to see what properties are available. In my case, they were in the “profile” property of the $Profile object, which was an array. So:

$favorite_goat = $Profile->profile['favorite_goat'];

Joomla 2.5+ Deprecated JRequest::checkToken() Replacement

I’ve become very accustomed to using Joomla’s JRequest class in custom Components. Since that class is now deprecated, I’m having to find new work-arounds, most involving the JInput class. Pretty much ever form had been using JRequest::checkToken() to guard against CSRF attacks, like:

if (!JRequest::checkToken())
$this->setError('Invalid (or expired) request token.');

To get around using JRequest, I’m now using this:

$app = JFactory::getApplication();
$token = JSession::getFormToken();
if (!$token || !$app->input->get($token, null, 'alnum'))
$this->setError('Invalid (or expired) request token.');

…which seems to work in pretty much the same way. In the old JRequest::checkToken() method, it was also redirecting to the login page if no session was detected, which I’m generally skipping.

WordPress Custom Post Types and 404 Error

If you’re working on a custom post type in WordPress and make a change to the post type or category slug (or add a new one), and you’re getting 404 errors when visiting the pages at the new address, chances are you just need to refresh the WordPress rewrite rules for permalinks. You can do this in your code by calling the flush_rewrite_rules() function:

…or, go to the WordPress admin under Settings > Permalinks and hit the “Save Changes” button, which also triggers the function. This is usually the best and quickest fix if making changes while developing. If using the flush_rewrite_rules() function, be sure to only call it on plugin or theme activation and deactivation.