MySQL server has gone away and Drupal

So if you got this problem, it's not really a Drupal problems, it's a problem with mysql configuration. The easy way to fix it is entering to my.ini and search for the string max_allowed_packet and set it to 32M or more.

Have fun!

Correct Way to Translate Content in Drupal

Ok, this will be a small post about keeping a multilanguage web page in Drupal7. As you know  Drupal is powerfull, but a bit complicate when configuring it. This WILL NOT be a tutorial, but a general map of instruction to translate your website. So let's see howto do it.

How Drupal knows what is the current language on your page.

There's a lot of ways of how drupal can recognise the current language. In fact you choose one when configuring the languages that are going to be on Drupal. But I really recommend using the URL method. This work as follow. Suppose you have a domain www.domain.com. When using URL for internationalization, your webpage in spanish are going to be on www.domain.com/es. So your node1 should be www.domain.com/es/node/1, in english it will be www.domain.com/en/node/2 (node2 because that's your translated module). There are other ways like having a global variable, but it will mess up your SEO, because google really hates having the same URL with different content (ok, its the same content but in a different language).


Translating Content

For translating content, you have to install the i18n module. When installed, a new tab called translate will appear when editing your node. The way you translate a content is creating a new node that is related to the original node. 

Translating WebForms

This will be the same as content. You create a clon of the original webform and relate it to the original.


Translating Blocks

You are going to need to activate the block Language Module. Works the same as Content.

Translating things in Views

So, lets say you create your awesome view and have put some global text button, or put a main title on it. the way you have to translate that is using the Content Translation module that comes with core of Drupal. After that you have to search for the string you want to translate, include the HTML if your title or global text have that, or else it will not appear in your search list. But!, and this is a very big but, when translating string, make sure youre currently on the language the translate string is. For example is you create a title in Spanish, let's say "Hola Mundo" (yes with the span tags to separe Hola from Mundo), you have to search that string using the admin in spanish, like www.domain.com/es/admin/translateblahblah or else your string will appear in the wrong language.

Menus and URL

This is the last thing you want to translate. For me its easy to create a new menu item in a different language. And why do it last? Because the URL of your content will exist only after your content is created. 

So, what thing's cannot be done easily?

My only problem right now is looking  for a way to translate the URL of a View in Page form. If you know, please tell me in the comment. Good luck!


Image corrupt or truncated in Firefox

Ok this will be a small entry. I got this problem in a Drupal7 Web Page using a slider module, the classic rotating image block.

It was kinda strange, because even in Internet Explorer the images were ok (IE!). So after trying the same webpage in Opera and Safari, and seeing that it worked ok, I disabled my Firebug extension and it worked like a charm!. I enable it, and the problem was gone.

So next time you have this problem, a corrupt image in firefox only, maybe you should deactivate any Firefox plugin youre having right now, specially Firebug. Hope it help someone.

Improving the Performance of BigDump

BigDump its my favorite way to move a Drupal Database from one server to another. Lately I had a "feeling" that this migration was becoming slower and slower. I really dont know if it is because of the way Drupal7 store the data, or because the new WAMP versions just come with a bad default configuration.

Anyway I was decided to confront this problem and find some interesting things that we can use to improve BigDump. So I made some experiments in my CoreI5 with 8GB of Ram and here is what i found:

About Drupal 7 and WAMP Mysql

Well this entry is mainly for Drupal7 users with Mysql as their main database in a WAMP server, I guess a lot of people have that configuration as a developing server. well seems like Drupal7 change their storage engine, instead of MyISAM, the default storage engine of Drupal6, its now use InnoDB. There are a lot of opinions about what is better but Seems like InnoDB can get you more performance if you give it an adequate quantity of RAM memory.  Now a simple site in Drupal, lets say a Blog, will usually weight between 5 to 10 MB in database data. That quantity of data doesn't work with the default configuration  of a Mysql WAMP installation, you will surely have a Server Gone Away error or Time Limit error, that's why we need to use BigDump for such quantity of data.

First: Configuring Mysql

Ok open your my.ini (in Linux it should be my.cfg but I not quite sure where it is)  file to start modifying it, Don't know where to find it? Follow this simple image and do it baby:



After some trial an error messing up this file , here are some configuration that you should try in order of importance:
  • innodb_flush_log_at_trx_commit = 2, by default it is set on 1, putting it on 2 means that your log will be stored temporaly in RAM instead of saving it on the HD every time you do an insert delete or update. This configuration have a side effect that it may corrupt the Log if crazy stuff happens to your RAM but you will not loose too much if your server is not your web hosting. Changing this variable makes my BigDump script run from 190 seconds to only 90 seconds, almost doubling the speed of this. If by any reason you cannot change this variable, maybe you can put your SQL exported script inside a transaction:

This is the export tool of PhpMyAdmin, check that option in Green and all your Data will be inside a Transaction
  • innodb_buffer_pool_size = 1024M, Ok I put 1024MB of RAM but you can put more according to the quantity of RAM in your rig. The default I think it is 1M or 16M, just changing this variable improve the speed from 90 seconds to only 50! 
  • Moar!!!: This blog gave me some more good ideas about other variables that we can tweak, but just with these two you can get an improvement of quad the speed.
Dont forget to remove the # on the start of the line, # is used for code comments. Yes you know that, but you already forget to delete it, check it again ;)

Second: Configuring PHP

This is optional really, but giving more memory to PHP improve the efficiency of the BigDump Script in 2 to 3 seconds, its not really too much but it will really help when you have Drupal installed

  • memory_limit 1024M :Play with it if you have more RAM, but 1024 worked fine for me.

 
PHP.ini after modifying it.





So to recap, change those 3 values showed to you and your BigDump script will fly!. Have fun

THIRD: Host File (update Jul2014):

After a hard drive format on my main disk, I installed again WAMP, and discovered that is was slow as hell, in a CoreI7 machine with 16GB of RAM, so I follow some advice to improve the general Wamp performance. One of those tricks is to modify the hosts file of windows, configure my.ini (of mysql) to listen to 127.0.0.1 and to disable IP6. Please take a look at those tricks here.

FOUR: Mysql Bind parameter (update Jul2014):

In  my.ini use the following under the [wampmysqld] tag.

bind-address = ::

Find this information in stack overflow

Outlook 2007 Errors: 0x8004010D and 0x80004005

Well this is a reminder about those two errors that appear in Outlook.

The error 0x80004005

This is one tricky  b@astard message, it really doesn't tell you whats going on. This error appeared to me when I tried to receive new emails in Outlook 2007. For what I have discovered, it just tell you that you can receive new mails. It may appear if you .pst files weights more than 4Gb and youre using Windows XP, or maybe there's an Antivirus blocking the entry of new mails.

The error 0x8004010D

This one is easy, its about your .pst file. As I told you before, thers a limit of space of 2Gb or 4Gb, after that the file cannot grow more. This will happen if youre still using Windows XP or use a FAT hard drive instead of NTSF.

Solutions?

Well, I dont really know what to do, but you can check this tool to change the size of the PST file and split it in more parts. Hope this help anyone.

More Links:


How to Fix the Socket Exception in Wamp2.2 and Netbeans

So I have this setup going on:

  • Windows 8 64bits
  • Wamp 2.2
  • PHP 5.4.3
  • Apache 2.4.4
  • And by default Xdebug  2.2.0-5.4-vc9
  • Netbeans 7.2 

The normal setup that comes with the new WAMP 2.2. When I was trying to debug a simple drupal project I got the tipical please  configure you php.ini according to this:

[xdebug]
xdebug.remote_enable = on
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remove_port = 9000

Nice, so I set up my PHP.INI  with the info above and start debuging again and BAM: Socket Exception on NetBeans with some instruction to disable watches. Thats the usuall stuff that netbeans tells when xdebug is not well configured.  So heres comes the solution:

Want to easily open up php.ini? Just leftclick your wampserver icon and navigate to it



THE MIGHTY SOLUTION:

1) Download the latest release of xdebug. Now you got to be very carefully chosing the adecuate file. In my case I downloaded : PHP 5.4 VC9 TS (64 bit).

Now, How do you choose the one?. Easy. The first part of the name is the version of PHP you use, so I have to choose those that start with PHP 5.4. Then comes the version of Visual Studio that this .dll has been compiled. Usually you got to choose the same one has your PHP and Apache have been compiled and for Wamp2.2 it is VC9. Now what about TS? TS means Thread Safe and for what I know is the one thats work well with newest apaches and phps. I downloaded another version (this one: PHP 5.4 VC9 (64 bit) , notice it doesnt say TS) that wasn't threat safe and I got the Netbeans message that It couldn't connect to the port.... so make sure is TS using my configuration above. Now dont forget the 64 bits part or 32bits part, its depend of the version of WAMP youre using.

2) Find this chain in your PHP.ini : zend_extension, comment it and add this one zend_extension = "c:/wamp/bin\php/php5.4.3/zend_ext/php_xdebug-2.2.3-5.4-vc9-x86_64.dll". And yes move your dowloaded xdebug to that address. And restart. 


 This is what's will look like your php.ini after the changes. Usually the xdebug info is at the bottom of your php.ini

3) Woalla, now youre debugging =).

Fixing Wamp and Undefined function pg_connect() in Windows7

So this is an update to my post on Fixing Wamp not so friendly extension.
I was trying to configure WAMP in WIndows7 so I can play with postgres 8.4. So I put on the extension php_pgsql and php_pdo_pgsql and it doest work.

To fix this you must find the libpq.dll file in C:\wamp\bin\php\php5.X.X whatever your version is) and put it on C:\Windows\System32 AND  to c:/wamp/bin/apache/apachex.x/bin (this is the difference with my post) .


 Please note that just in case you must install a WAMP of the same bitage that your postgres version. In my case Wamp 64 bits didnt work on my Postgres of 32 bits, so i reinstalled and used the Wamp of 32bit.

Hope it help anyone!