Pixelite: How and why you should update PHP to PHP 5.5 with Drupal

Planet Drupal - lun, 13/04/2015 - 02:00

This post is a follow up to my previous blog post on how to upgrade PHP to 5.4 to support Drupal 8.

Why you should upgrade PHP

If you are looking for reasons to ditch PHP 5.3, here are some:


PHP 5.3 reached end of life in August 2014, this means that if you are running this version, you are running an insecure version of PHP that potentially has security holes in it. This is bad for obvious reasons.

Bundled opcode cache

PHP 5.5 is the first version that bundles an opcode cache with PHP, this means there is also no need to also run APC (unless you need userland caching in APCu).


PHP profiled the 5.4 release compared to 5.3 for Drupal, and that found that:

  • 7% more requests/second
  • 50% PHP memory reduction

PHP 5.5 offers more performance again, and there is a section at the bottom of this article that goes through a real life scenario.

Cool new features

Read through the list of new features, here are some neat things you are missing out on:

$array = [ "foo" => "bar", "bar" => "foo", ];
  • Function array dereferencing
$secondElement = getArray()[1];

And many others.

How to upgrade to PHP 5.5

There are a number of ways to update your server to PHP 5.5.

Upgrade to Ubuntu Trusty Tahr 14.04

Ubuntu Trusty Tahr 14.04 (which is an LTS version), which comes bundled with PHP 5.5.9. This is probably the best solution if you are managing your own Ubuntu box.

Install a PPA on Ubuntu Precise 12.04

If you are running the older Ubuntu Precise 12.04, you can add a PPA

sudo add-apt-repository ppa:ondrej/php5 sudo apt-get update sudo apt-get install php5 php5 -v

It would be worth considering a dist upgrade though, but this at least can buy you some time.

Acquia Cloud UI

If you use Acquia Cloud for hosting there is a convenient PHP version selector in the UI.

More information can be found in the documentation. Be aware, once you upgrade beyond PHP 5.3, you cannot downgrade, so ensure you test your code on a development server first ;)

Common coding issues

Although Drupal 7 core, and most popular contributed modules will already support PHP 5.5, it would pay to do a code audit on any custom code written to ensure you are not using things you should not be. Here are some links you should read:

Below are some of the most common issues I have found in sites:

Call time pass-by-reference

If you have this in your code, you will have a bad time, as this is now a PHP fatal.

foo(&$a); // Bad times. Only variables can be passed by reference

This will cause PHP to throw notices.

$ php -a Interactive shell php > ini_set('error_reporting', E_ALL); php > var_dump(reset(explode('|', 'Jim|Bob|Cat'))); PHP Strict Standards: Only variables should be passed by reference in php shell code on line 1 Strict Standards: Only variables should be passed by reference in php shell code on line 1 string(3) "Jim"

Where you will likely find this in Drupal in my experience is when manually rendering nodes:

This code works in PHP 5.3, but will throw notices in PHP 5.5:

$rendered = drupal_render(node_view(node_load(1), 'teaser'));

The fix is to simply use a temporary variable:

$view = node_view(node_load(1), 'teaser'); $rendered = drupal_render($view);

The reason being that drupal_render() expects a variable to be passed in (as it is passed by reference).

How do you find coding issues

Enable the syslog module, and tail that in your development environment, hunt down and fix as many notices and warnings as possible. The more noisy your logs are, the harder it is to find actual issues in them. While you are at it, turn off the dblog module, this is only helpful if you do not have access to your syslog (as it is a performance issue to be continually writing to the database).

Real world performance comparison

This was taken from a recent site that underwent a PHP 5.3 to 5.5 upgrade. Here are 2 New Relic overviews, taken with identical performance tests run against the same codebase. The first image is taken with PHP 5.3 running:

You can see PHP time is around 260ms of the request.

With an upgrade to PHP 5.5, the time spent in PHP drops to around 130ms. So this is around a a 50% reduction in PHP time. This not only makes your application faster, but also it means you can serve more traffic from the same hardware.


If you have gone through a recent PHP upgrade, I would be interested to hear how you found it, and what performance gains you managed to achieve.

Catégories: Elsewhere

Drupal for Government: Tree cross pollination maps using Drupal! aka debugging drupalgap geofield with genymotion and gapdebug

Planet Drupal - lun, 13/04/2015 - 01:27

DrupalGap continues to rock.  Today I wanted to test the geofield module and get some maps in my apps... duh... it came about as a result of meeting with Tom Cormons from Appalachian Voices. He mentioned a problem - you often need two trees to pollinate eachother, and only have space for one... an app might help neighborhoods coordinate healthy tree communities.  

Anyhow - my dev skills were amok.  I followed the instructions on Tyler Frankenstein's site however I wasn't getting the maps to show up on my phone.  They showed up fine on the web-app side of things (eg https://www.cvillecouncil.us/mobile-application/index.html#node_23 ) however after building and piping to my android phone I couldn't get the maps to show up on my kyocera hydro (c5170...) ... I needed a debug environment... enter gapdebug!  oh yeah... gapdebug only works with android 4.4... my ghetto phone is running android ice cream 4.04... enter genymotion!

Catégories: Elsewhere

Dave Hall Consulting: Managing Variables in Drupal 7

Planet Drupal - lun, 13/04/2015 - 01:02

A couple of times recently the issue of managing variables in Drupal 7 has come up in conversation with other developers. This post outlines the various ways of managing variables in Drupal sites. The three things this guide ensures:

  • Sensitive data is kept secure
  • Variables are correct in each environment
  • You are able to track your variables (and when they changed)
The Variables Table

The most common place you'll find configuration variables is in Drupal's variable table (aka {variable}). The values in this table are often managed via admin forms that use system_settings_form(). Users enter the values click "Save configuration" and the data is stored in the database.

If you prefer to manage your configuration via the command line and know the variable you wish to set you can use drush vset. This does exactly the same thing as admin form, without needing to click on a mouse.

$conf Array

While the variables table is great at storing our variables, there are times when you want to enforce a setting. This might be because you want to prevent users from changing it (accidentally or otherwise) or because you need it to be different in each environment. The $conf array in settings.php always overrides any values in the variable table.

Acquia, Pantheon and platform.sh all provide environment variables so you can use different values in your $conf array depending on the environment.

Exporting Variables

In Drupal 7, the common way to export your variables is by using Strongarm with Features. I'm not going to cover how to do this as there is loads of documentation already available on this topic.

If your variable changes on a per environment basis or if it calculated on the fly, then you won't want to use strongarm+features as the exported values are static. You will need to put them in settings.php.

Note to self: I should debug and reroll my patch for adding support in alter hooks strongarm.

My settings.php is Out of Control!

This is a common problem, especially on more complex sites. To avoid this I recommend creating sites/default/settings/settings.[env].php files. Your settings.php file should check for the environment in an environment variable and then include the appropriate settings.[env].php file.

What About Sensitive Data?

You can encrypt variables on a case by case basis using the encrypt module and some custom code similar to what I recently implemented in the Acquia SDK module (see on store and on read examples). Warning: This doesn't encrypt the data if you're using drush vset.

If you are storing sensitive data in your variables table I would recommend you implement hook_sql_sync_sanitize() which will delete the sensitive data from your db when drush sql-sanitize or drush sql-sync --sanitize are run.

How to Decide?

This little code snippet should help you decide.

<?php // Don't try using this code in your Drupal site. if (!using_version_control()) { // Seriously there is no point in doing this without version control. abandon_all_hope(); drupal_exit(); } if (is_data_sensitive($var)) { $var = encrypt_var($var); if (!we_use_drush_based_workflows()) { learn_and_implement_drush_based_workflows(); // I'm serious! } } implement_hook_sql_sync_sanitize($var); } if (is_unique_per_environment($var)) { store_conf_array($var); } else { store_in_db($var); if (!we_use_features_based_workflow()) { learn_and_implement_features_based_worflows(); // I'm serious! } export_using_strongarm($var); }
Catégories: Elsewhere

Mark Brown: Acer Aspire E11

Planet Debian - dim, 12/04/2015 - 20:52

Recently I was in Seoul in the middle of three weeks of travel and my laptop died on me.  Since I had some work that needed doing fairly urgently I took myself over to Yongsan Electronics Market and got myself a cheap replacement to tide myself over.

What I ended up with was an Acer Aspire E11. There’s a bunch of different models all with very similar plastics, I got one which has a N2940 SoC, 2G of RAM (upgraded to 4G in store), a 500G hard disk and no fans for just over 200000 Korean Won, or about $200. As you’d expect at that price it’s got shortcomings but overall I’ve been extremely happy with it, it’s worth looking at if you need something cheap.

The keyboard in particular is probably the nicest I’ve used 0n a laptop in a long time with a good, definite but not excessive click feel as you press. Battery life is about 5 hours as advertised which is not wonderful but basically fine for me most of the time, and while not exactly Retina it’s clear with good viewing angles and generally pleasant to look at. Everything is plastic but feels very solid and robust, better than a lot of more expensive devices I’ve used, and there’s not much bezel around the screen which means it’s the first laptop I’ve had which has been comfortable to use in a standard economy seat on a plane.

The biggest drawback is performance – it’s a little slow opening applications sometimes and kernel builds crawl with an x86 allmodconfig taking about one and three quarter hours. For e-mail and web browsing there’s no problem at all, I did have to move from offlineimap to mbsync to get my mail to sync in a reasonable time but that’s more to do with the performance of offlineimap than that of the system. Overall in use it feels like the Dell I was using from about 2008-2011 or so, comfortable in use outside of builds, and I do appreciate having a system with no fans.

There were a couple of small tricks getting Debian installed – this is the first system I’ve seen with secure boot enabled by default which took me a few moments to work out (but is really good to see). Once that was disabled the install was smooth other than being bitten by Debian bug#778810 which meant I needed a manual fixup to actually get it to boot from the disk. It’s also got a Broadcom WiFi module which means it doesn’t work at all with mainline but it looked like that was on a standard mini PCI Express module so easily replaceable (I happened to have a USB dongle handy so haven’t bothered) and the wired ethernet just worked.

Like I say I’ve been very happy with it, there’s a bunch of other models with different specs for everything except the case (some touchscreen, some with small 32G eMMC drives) as well. Were it not for my need to do kernel builds I’d probably be keeping it as my primary laptop.

Catégories: Elsewhere

Bartosz Fe&#324;ski: lack of SRS on @debian.org mail servers

Planet Debian - dim, 12/04/2015 - 20:46

Any good reason that we’re not using SRS to make SPF aware servers happy?
That’s kinda strange given that @debian.org is doing only forwarding.

Catégories: Elsewhere

Josselin Mouette: GNOME for system administrators - Jessie edition

Planet Debian - dim, 12/04/2015 - 16:29
The mini-Debconf Lyon 2015, in addition to being a great meeting to meet both friendly and new faces, has been the occasion for me to update and enrich the GNOME for system administrators course.

For those who couldn’t be here, as well as those who were here and disappointed to see me cut through the last third for timing reasons, here are the slides:
Catégories: Elsewhere

Wouter Verhelst: LOADays 2015 talk done

Planet Debian - dim, 12/04/2015 - 13:36

I just uploaded my LOADays 2015 slides to slideshare. The talk seems to have been well received; I got a number of positive comments from some attendees, which is always nice.

As an aside, during the talk I did a short demo of how to sign something from within Libreoffice using my eID card. Since the slides were made in Libreoffice Impress, the easiest thing to do was just to sign the slides themselves, which worked perfectly well. So, having uploaded, downloaded, and verified these slides, I can now say with 100% certainty that slideshare does not tamper with files you upload. They may reformat them so it's easier to view on a website, but if you click on the download link, you get the original, untampered version.

At least that's the case if you sign documents, of course; it's always possible that they check for that and special-case such things. Would surprise me, though.

Catégories: Elsewhere

DrupalOnWindows: Decent PDF generation in Drupal

Planet Drupal - dim, 12/04/2015 - 02:29
Language English

Wether you like it or not PDF is a mainstream adopted format to exchange documents. Your customers will ask, sooner or later, to have some sort of content generated in PDF (be it an invoice, a report, etc...).

Doing a quick search these are the modules that offer some sort of PDF integration in Drupal:

More articles...
Catégories: Elsewhere

Drupal @ Penn State: Dynamic Memory Allocation in Vagrant Virtual Machines on Windows Hosts

Planet Drupal - dim, 12/04/2015 - 01:36

Whenever there is a constraint on the number of developers in a pool, it can make it more difficult to solve issues. As we have been developing Nittany-Vagrant, I have found that there is definitely a smaller pool of developers running on a Microsoft Windows host for their vagrant based virtual machines.

The extra credit problem of the day for me was how to allow vagrant to automatically size a virtual machine's memory pool when utilizing VirtualBox as the VM provider on Windows. This is a well known solution on OSX:

Catégories: Elsewhere

DrupalOnWindows: Calling .Net Framework and .Net Assemblies from PHP

Planet Drupal - sam, 11/04/2015 - 23:48
Language English

You know that the PHP ecosystem is not yet (but heading to) professional or truly business ready. Something as simple as doing good and solid PDF manipulation, interacting with Word and Excel and others are simply a nightmare. You will of course find libraries to handle all that, the problem is that they are all half broken, slow and not even close the the professional offering you can find the in the .Net environment.

More articles...
Catégories: Elsewhere

tanay.co.in: Some quick statistics from scraping the Acquia Certification Registry

Planet Drupal - sam, 11/04/2015 - 19:38

As Acquia Drupal Certification turned 1 recently, I was trying to make sense of how many people have taken the certification exam, especially from India.

The certification team had recently launched the Acquia Certification Registry portal @ http://training.acquia.com/registry where you can search through and browse the list of candidates that have cleared the certification exam(s).

I built a small script that scraped the results, crawling through all 20 pages currently available on the registry portal, into a spreadsheet as well as a MySQL database, that I could run queries later to mine for the data I was looking for.

Finally, after a few minutes, I had a local consolidated database of the data publicly available from the certification registry, which I could run queries against, to find the answers I was looking for.

FInally, I have the numbers that I was interested in...

Total Number of Certifications = 777

(As on the registry on Sat April 11 9am IST)

Number of People Certified = 685

Unites States tops the chart with

307 certifications of

259 certified candidates, followed by

India with 86 candidates!

Number of Certifications - Top 6 Countries

United States








United Kingdom




Number of Certified Developers - Top 6 Countries

United States








United Kingdom




Acquia Certified Developers are spread over 40+ Countries!

On this context, I had a quick chat with Peter Minijak from the Acquia Certification team for a more deeper insight into the numbers. Was surprised to know that this list is going to explode soon to at least 150% as the total number of registered profiles including those who are yet to give their exam currently stands at 60+!

66 Developers have

more than 1 certification!

Acquia also gives a ”Grand Master”title to candidates who have cleared the first 3 examinations. There are

11 such candidates currently.

The same are listed @ http://training.acquia.com/registry/grand-masters  

14 countries have developers holding

more than 1 certification

Feels good to see India at #2, by absolute numbers. But if seen relatively, considering the large number of Drupal shops and Service Integrators in India, I think the number is still small and definitely bound to make a huge leap in the coming months.

NOTE: These numbers were scraped from the Certification Registry portal. They are no where close to being reliable. There could be some bugs from my script or the bad queries I write ;-)  

Catégories: Elsewhere

Steve Kemp: Some things get moved, some things get doubled in size.

Planet Debian - sam, 11/04/2015 - 02:00


We're about three months away from relocating from Edinburgh to Newcastle and some of the immediate panic has worn off.

We've sold our sofa, our spare sofa, etc, etc. We've bought a used dining-table, chairs, and a small sofa, etc. We need to populate the second-bedroom as an actual bedroom, do some painting, & etc, but things are slowly getting done.

I've registered myself as a landlord with the city council, so that I can rent the flat out without getting into trouble, and I'm in the process of discussing the income possabilities with a couple of agencies.

We're still unsure of precisely which hospital, from the many choices, in Newcastle my wife will be stationed at. That's frustrating because she could be in the city proper, or outside it. So we need to know before we can find a place to rent there.

Anyway moving? It'll be annoying, but we're making progress. Plus, how hard can it be?

VLAN Expansion

I previously had a /28 assigned for my own use, now I've doubled that to a /27 which gives me the ability to create more virtual machines and run some SSL on some websites.

Using SNI I've actually got the ability to run SSL almost all sites. So I configured myself as a CA and generated a bunch of certificates for myself. (Annoyingly few tutorials on running a CA mentioned SNI so it took a few attempts to get the SAN working. But once I got the hang of it it was simple enough.)

So if you have my certificate authority file installed you can browse many, many of my interesting websites over SSL.


I run a number of servers behind a reverse-proxy. At the moment the back-end is lighttpd. Now that I have SSL setup the incoming requests hit the proxy, get routed to lighttpd and all is well. Mostly.

However redirections break. A request for:

  • https://lumail.org/docs

Gets rewritten to:

  • http://lumail.org/docs/

That is because lighttpd generates the redirection and it only sees the HTTP connection. It seems there is mod_extforward which should allow the server to be aware of the SSL - but it doesn't do so in a useful fashion.

So right now most of my sites are SSL-enabled, but sometimes they'll flip to naked and unprotected. Annoying.

I don't yet have a solution..

Catégories: Elsewhere


Subscribe to jfhovinne agrégateur - Elsewhere