Outside Links collection sticky icon

Sometimes you find just the right resources that fulfill certain need and nothing much should be added to them, in those cases I will just collect them on this page and add short comment why is this so.

How to combine Git and Drush to have perfect workflow for site maintenance, information and examples are here
http://www.jenlampton.com/blog/keeping-your-drupal-site-date-git-and-drush

Setting upt perfect Git + Drush workflow, read here
http://www.acquia.com/blog/using-git-drush-win-workflow

Quickly import DB on server

If you want to quickly import DB on your linux do this combo command, before just create that Database you want to have.

gunzip < data.mysql.gz | mysql -u root -p db_name

Quick out of memory or out of time debugging

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
ini_set('memory_limit', ''728M');
ini_set('max_execution_time', 120)

add this to index.php and see what is the output, act on that.

Huge load time, over 700 MB of memory and WSOD when adding/editing node

On a big site with more then 20 000 nodes, when creating particular node I first experienced WSOD, then as I reported errors, max_time_execution passed, then when this was raised memory limit passed. So I raised both to high limits, memory to 1gb and maxe_execution time to forever. Then I run the node/add and what I have to see is

Page execution time was 30257.61 ms. Memory used at: devel_boot()=2.21 MB, devel_shutdown()=707.38 MB, PHP peak=711.75

Remove some crayze chars like � �

I was doing an import of data from some old DB, that had some chars like � � in them, so how to remove them and keep all the other UTF-8 chars in them?

I used iconv("UTF-8", "UTF-8//IGNORE", $vars). And it saved me from going crayze myself.

Create unique username before user_save

When using user_save to create new user, you want to have username unique, if you are importing data or just want to be safe that someone hasn't have chosen username you already have in DB (and not to get nasty error PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry...). Here is some nice code to run on that username variable before saving an object.

function _prepare_unique_user_name($orig_name) {
$name = '';
if ($orig_name) {
/* filter characters (look at user_validate_name) */

How to set your innodb_pool size, what is the size of your DB

Want to know how much is your DB big, what value to set for innodb_pool in your mysql settings? Use this function

mysql -u root -p -Bse "SELECT ENGINE,SUM(DATA_LENGTH),COUNT(ENGINE) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') AND ENGINE IS NOT NULL GROUP BY ENGINE ORDER BY ENGINE ASC;"

and you will get numbers that you can use to set your my,cnf

Krumo/Devel output in watchdog

If you want to have Krumo/Devel style output in watchdog, just do this.

watchdog('debug',kprint_r($var, TRUE, NULL));

$_SERVER['HTTPS']='on' on reverse proxies - nginx and SSL

When using nginx and SSL and you have a problem that CSS or JS files are using HTTP in their urls and everything else is in HTTPS. The thing you need to do is use this magic

$_SERVER['HTTPS']='on';

put it in settings.php and also if you have wordpress, do the same, put it in wp-config.php it will do the same and solve the same problem.

Attaching Extra or Pseudo Fields to any Entity in Drupal

This thing is so cool and only recently I found about it. You can create pseudo fields with your entites, most often content types. So you can make some add, edit, delete buttons or any kind of forms on your entites or nodes. And it is pretty quick and straight fwd solution.

Read more about it here
https://www.computerminds.co.uk/drupal-code/add-stuff-node-and-configure...
http://www.vdmi.nl/blog/attach-extra-or-pseudo-fields-any-entity-drupal