Last week, I managed to achieve the prestigious Drupal 9 Grandmaster title. This week I completed the puzzle with Drupal 7, because legacy projects need love and attention as well.
Currently PHP developers face a great problem with PHP version - most OS repos already have outdated versions (CentOS has 5.4 which has passed its end of life!), but just swapping out versions is just not an option - especially with the version requirements of different frameworks / libraries. Furthermore, usually to have more than one version meant recompiling, and keeping up with updates - and no one wants that. Here's how to setup a server (virtual of physical), with ISPConfig3 hosting panel, multiple PHP versions, latest Apache and Mariadb in less than a half hour, with zero compiling. You can then manage your virtual hosts and their PHP version from a nice UI.
With most languages, when you develop you get the (wonderfully helpful) option of setting breakpoints, stepping through your code, adding watches and inspecting the overall state at any specific point in time. PHP differs in that, being a scripted language hosted in another process (eg Apache) it normally doesn't offer that. Here's how to enable your IDE to do get all the nifty features.
After playing around with CentOS 7, I was amazed at how simple things that are traditionally annoying as heck are - if you get the config right, of course. One of these is getting a Linux share viewable on Windows clients, with Active Directory authentication and authorization, which I'm going to describe in this post.
CentOS 7 is out, and it brings some much needed features for web developers! For starters, MySQL is replaced by MariaDB (much better performance for InnoDB, and a better client), and PHP is 5.4 out of the box. In addition, multitudes of tweaks have been made to the system, making it more responsive.
The following is a guide (with screenshots) for installing a basic LAMP stack with the new OS, on an empty machine (in this case, a virtual machine), using the NetInstall image (Minimal is not yet available, but being worked on).
Had some performance issues with a client, recently. The server is an absolute beast, and should be able to easily handle the single website hosted on it. Alas, pages took forever to load (D7). A simple top showed that load was at about 60, and CPU utilization was at 10% for user and ... 95% for system. Wait what?
First day of the year in the office, and a call came up "site isn't working". Browsing to the site, I noticed it couln't connect to the database. Thinking it was probably some glitch, I logged in remotely to the server, to find that the filesystem was readonly. After trying to figure out why me, being root, could not do anything to the filesystem... it rebooted. My first filesystem crash.
I spent the past few days in the VERY unpleasant situation where I had to remove tons of spam-sending scripts from a couple of websites I host. These were in relation to unsecured, unmaintained Joomla! installations, and exploited the cache folder. I won't bother you with the why or how, just know that the vulnerability existed, and has been fixed for versions 2.x and up -- NOT 1.x. Here's the simple way to secure yourself without changing the Joomla site code.
So you've configured Apache just like you want to. You've even added an SSL certificate to allow your users to securely navigate on your site. And you test it, and everything works, across all browsers you have access to... and you receive a dreaded call that there is a certificate error on a client (typically some higher up, because that is just your luck). What the hey?
Sometimes you need to save data from your webpage to an excel file. Though there are many libraries that can accomplish that the "proper" way, it is much faster (and easier!) to just output an HTML table to a file with the "xls" extension. However, there are a couple of things to note to make theming look as it should!
Field Collections are basically multifields in Drupal 7. They're so much user-friendlier than having referenced nodes, and so much lighter. However, if you try to add items to them (that is, an unlimited field collection field) in hook_node_presave , you get stuck in an endless loop. If you have XDebug or similar, you will see the extremely unhelpful message " Maximum function nesting level of '100' reached, aborting!". So what now?
Having a Linux server querying Windows Active Directory for credentials gives your users a wonderful, unified experience - they only need a single logon for the intranet, and their machine. However, sometimes you need to browse the AD tree to see if/what is going on. Two things I've learned while debugging follow.
One of the things I love about Drupal is the taxonomy system. It's convenient and stable... except when it's not. I got 404s for the term URLs (both system and alias) and the cryptic message "Notice: Undefined index: href in menu_local_tasks() (row 1973 in path2site/includes/menu.inc).". Well, here's what worked.
We all know that Drupal provides the FormAPI, in which very powerful form elements exist (in our case, the tableselect element). This magical element behaves like a table, but has a checkbox for each line, and associated JS/CSS to handle checking rows. But it is normally impossible to add additional form elements on each row ( there have been many workarounds, but all seem hackish) due to the way Drupal handles form submission. This is how to have a clean (and simple!) way to go around those restrictions.
Today I came to work. It being Monday and all, seeing that PHP stopped talking to Oracle (which it was doing wonderfully until Friday), and that all reports are hence broken (which were not until Friday) is not a good start of the week. Add the cryptic Oracle errors, and you're set for nerve wrecking debugging.