Alex Moreno


A Drupal Developer in London

Apache not sending changes in js and css (virtual box)

I am using a solution of vbox (virtual box) and shared folders in our windows work environment (yes, unfortunatelly, but the IT team is in his right to decide which machines we have to use).

Everytime the vbox start, it mounts "automagically" one of the shared folders in the linux host (centos and archlinux, one day I will explain why). So then, apache has all what he needs in /var/www/html/ (simply mounted with "mount /var/www/html") (see automatically mount directories in vbox).

So far, everything was working fine... until I started to make small changes in small files. Absolutely surprising because when I deleted the complete code in the css or js file, for example, and I updated the browser, the screen appeared white, so everything seemed ok. But not at all, dealing with small changes, like adding a line in your css simply add no effect, the change is here, but seems that Apache or the browser didn't like it, simply it was being ignored.

After a while struggling about the browsers cache and even restarting the virtual box I finally decided to dig into Google.

I found the problem in the frankooh blog and it seems that it is a vbox problem, exactly a vboxsf problem with Apache.

The solution is simple, go to you apache configuration (in centos /etc/http/conf/httpd.conf) and uncomment the line:

EnableSendfile Off

After restarting Apache all the changes were sended to the browser without problems, even the small ones.

PS: be carefull with case sensitive off != Off 

Drupal developer in London

My name is Alejandro Moreno Lopez. I'm an spanish developer living in London, degree in Computer Science, who has specialized in PHP and Drupal development.

 

Debug Cron white screen in drupal

Debugging cron issues and errors is one of the most tricky things in Drupal. If you are dealing with a big site, with people adding nodes, inserting content which you can't allways force to be commited in the right way, and things like that, it is not unusual to find a cron broken by some "misterious" node.

Well, it is quite easy to find this "misterious" offender, just logging the cron activity. How, very easy, with my new module "cron_killing_finder".

It is published in my "Drupal SandBox": http://drupal.org/sandbox/programadoresweb/1895746

Just download it and follow the really simple instructions:

"Just activate it and go to /admin/reports/dblog. You'll find a "Node hook update_index: NID" string with the cron executions which tells you in last term which node is executed each time. If cron breaks, the last node reflected in the log will be the offender node, very simple :-)."

Hopefully it will be a new "complete" project, so you'll don't have to use git to download it.

warning: date(): It is not safe to rely on the system's timezone settings

The error is quite enoying:

warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'GMT/0.0/no DST' instead

But it is quite simple to correct. It is not a drupal problem, but a linux/apache. Just go to your php.ini, for example /etc/php.ini in CentOS and add this line:

date.timezone = Europe/London

reboot apache and the problem will have dissapeared.

categorias: 

Validation file in Drupal without theme / template

 

Sometimes you need to upload files to, for example, validate an affiliate with whom you want to start to work.

The problem, is that these affiliate files need to be "clean", no template, no theme, just the code or validation string which they send.

The solution can be very complicated, like creating a new theme just for a group or a contect of pages... or as simple as creating a node with the string which we need and executing a php code with an exit command. Something like this:

 

valicationStringLikeUZasdBNf6asdfT2asdfafjpdadf===58QYg==

<?php

exit;

?>

 

so, when you open this node, you'll see a blank page like the one in the screenshot.

Well, i don't like to use php inside nodes, this practice must be avoided, but for this case, the code is enough simple and, the most important thing, it doesn't break the cron execution. So, everyone happy :-).

Do you have a different or improved idea for this? Please, share :-)

 

Automatically mount directories in centos / virtualbox

If you try to mount a shared folder in centos, runing under a virtual box, you'll probably have problems trying to fix this directory, mounting automatically each time the system reboots.

In any other distribution, like ubuntu, you just have to go to your /etc/fstab and add this line:

varhtml                 /var/www/html   vboxsf  defaults        0 0

The problem is centos is that when the system arrives to this line, the vboxsf module has not been loaded yet.

The solution is quite simple, execute a mount command when everything has been loaded. This can be done in /etc/rc.local:

mount  /var/www/html

Your fstab must give information about this directory (like you've seen in mine), or use the large version of mount command.

As you can read in rc.local:

This script will be executed *after* all the other init scripts.

So, there is probably a better way to do this, but this one does the trick too :-).

categorias: 

Get Drupal fields for a particular content type

 

Sometimes in Drupal you need to get the fields for a particular content types. 

"$type = 'mytype';

$fields = content_fields();

$type_fields = array();

foreach ($fields as $field_name => $field_data)

{

  if ($field_data['type_name'] == $type)

  {

    $type_fields[$field_name] = $field_data;

  }

}"

 

in drupal7 is easier, since we have a direct function:

field_info_instances($entity_type = NULL, $bundle_name = NULL)

 

 

get current drupal theme

very simple:

        global $theme_key;

      echo $theme_key;

 

if we need more information, we can use this:

       $themes = list_themes();

       $theme_object = $themes[$theme_key];

 

        // print all the object fields

       var_dump($theme_object);

 

via http://drupal.org/node/46961#comment-88354

changing vhost.conf without restarting apache

Sometimes you need to change some parameters to your apache virtual host. Then, when you need to check the changes, in plesk you'd probably will have to execute the next command to see the changes:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain exampledomain.com

Otherwise, restarting apache (/etc/init/apache2 restart) could not make the trick.

I allways forgot this little trick... never more, because Programadores Web will remind it me :-).

categorias: 

Programadores drupal y php en España

De verdad que España me parece cada vez más lejana. Estoy viendo una oferta de trabajo y de verdad que los sueldos son "tercermundistas".

El país no va a salir de la economía agro-inmobiliaria en la que se ha basado hasta ahora si se está ofreciendo por un senior lo que en Londres se ofrece para un junior de cualquier tecnología. Menciono Londres por poner un ejemplo que conozco bien (porque vivo y trabajo en Londres), pero en el resto de Europa ocurre exactamente igual.

Muchos podréis argumentar que el coste de la vida aquí es muy superior... sin embargo no es así. Proporcionalmente la carne, la leche, el periódico, ... las cosas básicas cuestan lo mismo que en España... la vivienda tres cuartos de lo mismo, si quieres vivir en el centro de Madrid no vas a pagar mucho menos de lo que pagarías por el equivalente en Londres.

Así pues, ofreciendo 25 a 30 mil euros a un senior, nada menos que un senior, como va España a atraer talento? Ese mismo rol en uk se está pagando entre 45 y 60k libras, podéis hacer el cambio a euros.

Lo más sangrante es cuando se lee en las ofertas de trabajo, título mínimo fp. Pero vamos a ver, si necesitas un ingeniero de software no necesitas un arquitecto de bases de datos... si estás buscando alquien que sea capaz de resolver cualquier problema, y que salga barato, posiblemente esa persona no vaya a poder centrarse en desarrollar productos de calidad (sino en escribir código todo lo rápido que se pueda y en resolver problema tras problema).

No es el camino mi vieja, querida (y cada vez más lejana) España :-(.

categorias: