Web Design and Build

Opencart unable to access admin after updating Last updated:13 June 2018

Spent this morning updating a client’s site to Opencart 1.5.6.4. All went well until I tried to log in to admin, when the admin login screen just refreshed, no error message, nothing in error log. After some digging, I identified that although the site was ussing SSL, the form was being submitted to a non-SSL URL. So it failed. The solution was to edit the admin config.php file to set the HTTP_SERVER constant to use https.

define('HTTP_SERVER', 'http://yourdomain.com/admin/');

There are lots of mutterings on various boards about this, but didn’t see this as a solution…Hope it helps.

Page Builder data lost after migration Last updated:18 August 2016

I’ve spent a lot of time this morning looking into an issue with a client site migration where Page Builder data was lost after the migration.

I have migrated many many WordPress sites by exporting the database, replacing the old URL with the new URL in the exported SQL and re-importing. Never had an issue. But in this case I did, and it’s related to how Page Builder stores data. This data is serialized, and the serialization stores both the data and its length. So a snippet of stored data looks like this:

s:160:"<p><img class="alignleft size-full wp-image-2348" src="http://test.co.uk/wp-content/uploads/2014/05/Tulips.jpg" alt="Tulips" width="200" height="150" /></p>"

Super…so if you run a global replace on the domain name you end up with this:

s:160:"<p><img class="alignleft size-full wp-image-2348" src="http://production.co.uk/wp-content/uploads/2014/05/Tulips.jpg" alt="Tulips" width="200" height="150" /></p>"

Which looks fine, but it isn’t because the serialization is now incorrect as the length of the serialized string has changed from 160 characters to 166 characters. Result: lost Page Builder data.

The correct update should be:

s:166:"<p><img class="alignleft size-full wp-image-2348" src="http://production.co.uk/wp-content/uploads/2014/05/Tulips.jpg" alt="Tulips" width="200" height="150" /></p>"

Clearly doing this is impracticable and fortunately there’s a plugin that handles this which is WP Migrate DB.

jQuery UI slider on touchscreen devices Last updated:13 May 2015

I’ve been meaning to have a look at updating my vertical scrollbar code so it works on a touchscreen. Finally found time this weekend to have a look…with rather limited results. I created three versions of the page, one using touchpunch, one with touchpunch improved, and one with a basic mapping of touch events to mouse events.

Device OS Browser TP TP improved Mapping
Versus tablet Android 4.0.4 Android browser Fails Fails Fails
Samsung Galaxy Ace Android 2.3.6 Android browser Fails Fails Fails
Apple iPhone 3G iOS 4.2.1 Safari Works Works Works
Samsung Galaxy Ace 2 Android 4.1.2 Android browser Works Works Works
Apple iPad Mini 1 iOS 8 Safari Works Works Works
Nokia Lumia 635 Windows 8.1 IE11 Works Works but with errors Works

Conclusion so far…Touchpunch works on newer devices only. If you have access to a different device, test the different pages and let me know the result.

imagejpeg issues with PHP 5.4 Last updated:27 November 2014

Came across an interesting little issue this afternoon while debugging an issue with a very old osCommerce installation. This particular site uses an on the fly product thumb generator (product_thumb.php) which worked fine with PHP 5.3 but failed with PHP 5.4.

After a bit of digging I tracked the issue to this line in the original code:

imagejpeg($src, '', 100);

In PHP 5.4 this fails, and needs to be replaced with:

imagejpeg($src, NULL, 100);

Perhaps this will save someone a bit of time. I didn’t find this problem noted elsewhere.

Making this site responsive Last updated:21 June 2014

I’ve been thinking about making this site responsive for some time, but never quite got round to it, in part because only about 1% of the traffic is from mobile devices, but I have finally got around to it. Now this site has grown up over the last, errr, five or six years, and I was expecting it be a bit of a nightmare.

Not so! The css file is pretty large anyway, but to date I have added only 94 css statements to media queries for small screens, and I think I’m nearly there, the only major challenge left is the photography slideshows. I have done this backwards according to conventional wisdom, in that I’ve started with a desktop site and reverse-engineered a mobile site. I can’t quite get my mind around why that piece of wisdom anyway… Just for comparison, bootstrap.css has more than 5000 entries.