PHP 5.3 BBQ Release Party Munich

We like to invite you to the PHP 5.3 release party which is an event to
celebrate the 5.3 release, happening Friday, the 17th of July in Munich.
The release party offers a chance to come together with other php
enthusiasts and enjoy that php is alive and kicking. And of course people
in favour of a decent barbecue, together with some beer and other drinks
are invited.

The happening will take place at Waldwirtschaft (http://www.waldwirtschaft.de)
beer garden, at any weather. We will meet at 19:00 o’clock – open end.

Catering will be provided and as a special delicacy you may enjoy a suckling pig!…hopefully vegetarian food. If you like to join the event please register at PHPUG-Munich Wiki (http://phpugmunich.org/dokuwiki/php_release_party) and follow it for updates. Alternatively you may register at Facebook
(http://www.facebook.com/event.php?eid=115203467104) as well and follow
this for updates.

For any questions please visit IRC channel: #phprp on irc.uni-erlangen.de.

The PHP 5.3. BBQ release party is sponsored by:
– Microsoft
– Mayflower GmbH
– Swoodoo AG
– Zend Technologies GmbH

Supporters for the PHP 5.3 BBQ release party are:
– Sun Microsystems
- PHPUG.de

Calling Conventions – when you need to know C to understand PHP

I think most of the people using PHP wonder from time to time about particular behavior of the language. That’s pretty much the same case with every language. Pythoneers have their wtf moments, Ruby programmers have their wtf moments and C programmers tend to live in a whole wtf universe. But lately I stumbled over a nice one. It looked like a bug in PHP, but turns out to be an interesting, curious, part of the C-language. Imagine the following PHP code sample and note that $a and $b are not defined (yeah I know, it’s bad coding style..blabla..):

<?php
var_dump($a + $b);
?>

What is the expected result with error_reporting set to E_ALL?

PHP Notice: Undefined variable: b in /var/foo/bla on line 1
PHP Notice: Undefined variable: a in /var/foo/bla on line 1
.
Are you sure? I’m not. On x86 hardware b is fetched before a is fetched and therefore the executor detects that b is not set first. But wait. Let’s test this on a SPARC machine:

PHP Notice: Undefined variable: a in /var/foo/bla on line 1
PHP Notice: Undefined variable: b in /var/foo/bla on line 1
.
What? It evaluates it in the reversed oder? What is happening? So I spend a few minutes with my lovely debugger and it turns out that this is what happens in the engine (I use pseudo code here):

result ZEND_ADD_OPCODE()
{
   return add_function(get_op1(), get_op2());
}

Voila, that’s the problem. On SPARC get_op1() is executed before get_op2(), while it’s the other way round on x86. As get_opX() detects if a variable exists, the error messages appear in reversed oder. I did a little bit research (thank you SunCC Team for your answer!) and it turned out, that C99 doesn’t define the way function calls in parameter lists are executed. Therefore, every system and compiler is free to use it’s own ordering mechanism. My current plan: Write a compiler that does this by random(). The fix is trivial:

result ZEND_ADD_OPCODE()
{
  op2 = get_op2();
  return add_function(get_op1(), op2);
}

. It’s a lovely curiosity.

git2svn, a little bit of git voodoo.

Interacting between git and subversion is quite common. The git command git-svn can be used to import existing subversion repositories into git and commit synchronize commits between two repositories. While importing a subversion repository into git is common, importing an git repository into subversion is quite unusual. There are various tools to do so, but most of them require direct access to the svn repository. In fact it is possible to use git-svn to get that job done. Frankly it requires some git voodoo and knowledge of the graft-feature. We’ll do a sample import using grafts, but before we start, we’ll explain the theory behind the import.
Read the rest of this entry »

PHP BBQ Tour in Karlsruhe

The PHP BBQ Tour organized by Ulf Wendel and various PHP Usergroups in Germany will stop in Karlsruhe. For those of you living near Karlsruhe, it’s definatly worth to join us. There will be food, drinks and I’m sure it’ll be a great evening. Information can be found here

ext/scream functionality without ext/scream

There were some rumors recently about Gopals ext/scream. This extension disables the @ operators and therefore makes all errors visible. If you want to use the extension you have to build the extension and restart your PHP modules so that the extension is loaded.

But there is a more elegant to get the same behavior. Using DTrace and recent OpenSolaris 2009.06 we are able to use the php:::error probe to get all error messages. Unlike the PHP extension we do not need to restart our PHP. We are also able to just temporarily look into the errors of all running PHP processes. Here is the DTrace script:

#!/usr/sbin/dtrace -s

php*:::error {
printf("Error \"%s\" in file %s line %d\n", copyinstr(arg0), copyinstr(arg1), arg2);
}

This will display all errors that occur. There is also a php:::exception-thrown probe which can provide nearly the same data for exceptions instead of errors.

PHP Testfest in Munich

We will have another great PHP Testfest this year in Munich on Thursday and Friday 16th/17th April. This time we will also have a nice evening event with some talks around testing PHP and PHP’s internals. So it’s not just a great place to get in contact with other people from the community but also to learn something.

No knowledge about C or PHP’s internals is needed. We will provide you with everything you need.
Check the wiki page for more information about the event. It’s definatly worth joining us.

Merge vs. Rebase – A deep dive into the mysteries of revision control

I remember the days when I started learning Git about two years ago. I crawled through all the available commands and read the man pages what they are for and I remember when I stumbled over rebase and stuck. After figuring out what it actually does, I start loving it, but didn’t understand it’s dangerousness until someday I somehow got duplicated commits after pulling from another repository. So let me explain what goes wrong and why merge and rebase are often misunderstood. I’ll also present a list of golden-rules about their usage. Before we start with explaining both commands, I would like to give you one of the most important rules, in case you don’t want to read the complete article.

Never rebase branches or trees that you pulled. Only rebase local branches.

Read the rest of this entry »

A really unfriendly and not so fair approach to GIT vs. Mercurial

Okay, this is one of the posts I wanted to since about 1 year, but now, nearly 2 years after the first git vs. Mercurial blog post I finally made it to actually write a second time about this topic. A first notice: I won’t cover bazaar. I personally hate it with passion and think it is the worst approach to DVCS ever. Nevertheless git and Mercurial fight in the same game with the same weapons (unlike bzr which is just far behind).

WARNING: This is the most subjective, most pointless approach to this topic ever. I didn’t read it myself a second time, I just published it.

I will start the same way as last time:

git
Git is a decentralized version control system written by Linus Torvalds to replace bitkeeper as the version control system of choice for the kernel because of licensing issues (okay I know this is the short story and it was much more complex and you can write a thousand lines about that, but it’s enough for most people). Git is designed to be fast. Everthing is optimized in that way. It contains a huge C written core with a lot of bash and perl scripts around it. A few years ago the C written part formed the so called plumbing. Nowadays the git community tries to replace high-level commands written in bash and perl that call the plumbing commands with c-written code to get a more consistent code base.
Let’s make a long story short:
Git is powerful. Awesome powerful. This is true since git’s beginning, but back then it lacks a good interface and the git community did a great job in improving the horrible interface git had once. Git is still awesomely fast. Commits, bisecting, everything works like a charm particularly on big projects like the kernel. They can rewrite history, they are doing a great job in helping intergrators to apply patches, reviewing them, and pushing to multiple sources. Everything about git is really unique, their focus on a powerful command set, their branching support and their targeted audience. I want to talk a little bit about that fancy branching support. Frankly, every version control system, even the 3rd generation decentralized ones have a pretty conservative way of doing branching by giving every changeset a name that the changeset belongs to (at least this is true for mercurial, and called named branches there). Git just gives a sh** about that and takes a version control branch the same way as a tree branch. It’s just an unnamed branch of the DAC. This gives you the awesome possibility to great huge set of local branches, to merge, rebase them without any bigger problem or even just discard them (actually that is one of the biggest problems in mercurials bookmarks implementation). Another just great feature in git is the staging area. You can stage hunks, as a virtual repository that is used to actually commit the ‘selected’ changesets. That’s awesome and I’m really missing that in most of the version control systems that I use. The idea of a staging area is just a huge win for git. It’s so incredible powerful. Okay to put it in a nutshell: git is just awesome, but….

There is Mercurial.
Okay some kind of a warning in advance: I contributed two well known extensions to Mercurial, I hang around in their chatroom and I think that I’m a well known part of the community. Nevertheless if you talk about Mercurial and compare it with git you have to take care. Mercurial is by far not as powerful as git, and…that is just the best think about Mercurial. Matt really keeps it simple and clear for everybody. it’s so incredible easy to understand in the first place. There are no weird commands with a thousand of flags. Okay I try to be fair. Mercurial is much less powerful than git in the first place. Because it tries to keep everything simple. There is no rebase, no cheap branching, no staging area. But there are extensions. You can learn Mercurial and know all it’s commands within 24h. They are really easy to learn, and not powerful, but they can be extended, by a large range of extensions. You can have cheap branching (bookmarks), you can have kind of a staging area (record extension), you can have patch management on top (mq) and much more. With all those extensions, Mercurial is as hard to learn as learning all git commands (which frankly is not necessary at all), but it’s more of a evolutionary approach. I know a thousand people who say that learning git is as easy. Okay, no problem. I don’t think so but it doesn’t matter, but frankly, git is missing 2 big points. Windows and an application integration: If you live in your nice Linux/BSD/foo world you are right. Git is awesome, but come on, I don’t have a freaky Windows machine, but I know that 80% of all people and more than 50% of all programmers use Windows. No they are not these bad, not geeky enough people. They are the real programmers. Those who are not freaks and take programming as a job. They don’t care (and thats good) about their environment, they just want to get things done and want to earn money. That good. And even that is not quite true for most of them, they do their stuff just faster on Windows than on Linux, therefore it’s better for them to use Windows. Okay, you might argue, but there is mysysgit and it’s even part of official git. Oh nice arguement, but frankly, junio doesn’t provide Windows binary, there is no official site to get them from, and ….. git daemon still doesn’t work perfectly nor does git-svn. It just sucks. Big -1 from me for that one.
The second pint is the worse git internal design. It’s soooo unix style. It’s cool for people that love Unix (like I do), who pipe around at least 3 commands, and know that I it starts to get funny if you pipe around 5 commands. But most of the developer want to use a nice integrated version control system. They don’t like to use fancy command line stuff with a thousand of flags, they want to do click&click (the german expression would be ‘klicky-bunti’). They want to have it integrated in their Eclipse, their NetBeans, Visual Studio, their Windows explorer and so on, and frankly, git does a poor job in that area. I know there is an eclipse plugin (but the mercurial one is stilll a thousand times better), and all this fancy stuff, but what do they do, damn, they have to parse the shell output. This means either git will never ever change their shell output (which would be sad, e.g. I hate the # in git status), or they will break older stuff. Mercurail on the other side is really easy to interface with. Okay you need python but that’s all. Everything else is just smooth. It’s easy to handle, it’s easy to integrate, it just works fine. Git really does a bad job on that. And the git community knows it. That’s why they start their libgit, and libgit2 project, because they know something like a git library is needed.

Okay it’s late and I want to finish that without reading it a second time, no frankly, this time I want to be completely unfair, without any objective argument: So here comes my final words, make them:

If you like to play with software, if you really like to have the power, go for git, if you use Linux, even better, go for it, there is nothing equal to the power and the fun you can have with Git. You can be a thousand times more productive. But if you, or people in your team are not tech-geeks. If you use Guis and want to use Windows, believe me, you better use Mercurial. I really love both systems (as long as you don’t use bzr even SVN is fine), but in this use case Mercurial is just better. Think about it.

shame on myself: song for this post: This is the life by Amy MacDonald

This is….

Sind mir €0.99 min. 2h gute Laune wert? Mir schon.

IPv6: AAAA records with Plesk the hackish way

Adding IPv6 addresses to a domain is usually quite simple. Instead of an A record, you hast have to add an AAAA record to your database that points to an IPv6 address. If you use a configuration tool like Plesk, adding those records might be a little bit more difficult, as Plesk – at least in the version my hoster uses – doesn’t allow me to add AAAA records. So here is a short tutorial how to add an AAAA record.

Plesk manages the DNS records in a database. We first need a way to insert AAAA records in the database. Luckily if this is done, we are almost finished as the script that generates the zone files, doesn’t do a doublecheck at all.

First of all login as root on your box. Then login to your mysql server using the ‘admin’ user:

# mysql -u admin -p psa

Now alter the table to allow AAAA records:

mysql> alter table dns_recs modify column type enum(‘NS’,'A’,'AAAA’,'CNAME’,'MX’,'PTR’,'TXT’,'SRV’,'master’,'none’) NOT NULL default ‘A’;

Downoad the dnsupdate.sh script from parallels website. You now just need to add an entry to your database using a INSERT statement and then run the dnsupdate. I wrote a extremly hackish and dangerous to use script for that:

#!/bin/sh
echo “INSERT INTO dns_recs (displayHost, host, displayVal, val, type, dns_zone_id) VALUES (‘$1′, ‘$1′, ‘$2′, ‘$2′, ‘AAAA’, 2)” | mysql -u admin -p psa

sh /root/dnsupdate.sh

Notice that I set the dns_zone_id explicitly. You have to check what id your zone has. If you write a more sophisticated script and like to share it, I would be interested.

Don’t forget the trailing dot!

# sh /root/insert-dns.sh ‘ipv6.experimentalworks.net.’ ’2a01:3332:2324:52aa::2′

Done. Your domain now points to the right IPv6 address.