Piotras' blog

Sauna, suana, sauna or Midgard Gathering

Posted on 2008-11-12 22:24:26 EET.

I was to blog earlier but this issue made me busy. On monday, me and solt came back to Poland from Midgard Gathering. Second gathering this year. I must say I think I am getting older as it's getting hard to focus when there are so many people and sauna time ends very late night :)

Bergie's blog describes gathering very nice and with more details.

Anyway, few very interesting points:

And as Vinland requirements clarified a lot, I am looking forward to see Midgard2 as a gateway for Gnome to web servers and services world.

ap_get_module_config and RHEL5

Posted on 2008-11-12 21:18:22 EET.

This is an issue. I couldn't find why Midgard apache module refused to work on RHEL5.It just started to segfault. What's even more interesting, it started to segfault when trying to access read only data provided by apache. If you are familiar with apache modules' internals you probably know that all routines are registered as hooks. Even that ones which holds server and directory config. In normal case you register hook and get configuration later, when it's needed.

Just like this:

midgard_directory_config *dcfg = 
    (midgard_directory_config *)ap_get_module_config(r->per_dir_config, &midgard_module);

I found these two posts quite interesting. First because it affected also midgard-apache module few years ago, and the second because it clearly shows there something odd happens. Why odd? Because you never sets directory or server config explicitly. You just register function and it's up to the server implementation when it's invoked.

In my case ap_get_module_config(r->per_dir_config, &midgard_module) returned NULL all the time. So I added debug messages which showed that server and directory configuration hooks are invoked. Spent plenty of time trying to figure it out.

  1. Your hooks are working very good (the same code works with older version of Midgard)
  2. Hooks are invoked. For sure.
  3. ap_get_module_config returns NULL.

Three facts which made me think it's something wrong with Apache. Not the module itself. And after many trials and errors, I found guilty AM_CFLAG: -D_FILE_OFFSET_BITS=64. Also interesting fact, this flag is able to slow down PHP itself.

Zend hallucination

Posted on 2008-10-25 00:38:39 EEST.

No, I didn't drink any alcohol. And I didn't smoke any grass (though, I do not like it anyway). But this issue makes me...

Here's the code (PHP one):

$user = midgard_connection::get_user();
echo gettype($user);
var_dump($user);

The last line of midgard_connection::get_user() function is:

if(Z_TYPE_P(return_value) == IS_OBJECT)
    g_warning("TYPE IS OBJECT");

In Zend, return_value is reserved name for variable which is returned from function. You can not return variables or values with some explicit return smth. You always have to use this predefined return_value variable.

Now, watch it very carefully. This is the output:

Warning: (pid:2703): TYPE IS OBJECT in /usr/share/midgard/setup/php/midgard_admin_sitewizard_creator_sitegroup.php on line 227
NULLNULL

So, Object became NULL in the middle of nowhere. Maybe this is a black hole from universe? And maybe even Paris Hilton brain?

New Midgard release

Posted on 2008-10-08 13:53:29 EEST.

Finally. We released Midgard 8.09.

This release is very important and it's big milestone in the whole Midgard development cycle.

  • It provides both classic and new Midgard2 API, so developers are able to continue their work and develope new fully forward compatible functionalities.

  • Basement is GObject and GType system so the same API works well on C and PHP level. Do you know any other CMS/Framework built on top of GObject and GType system?

  • It's the only one CMS/Framework which supports D-Bus implemented for websites. Yes, I know, one may implement D-Bus with Python, but is he able to talk to Python and PHP (and even C) at the same time?

  • It's the only one CMS which provides real events support for PHP. As real as Midgard extension for PHP is nothing else but language bindings so the same functionality is ensured on C and PHP level.

  • It's the first stable generation, released with new releasing policy in mind. Just like Gnome. We want to provide new release, every six months.

  • It's the only one which provides unique replication facility, which is database independent.

As I mentioned earlier, this release include new API, so we have six months to release stable Midgard 9.03 "Vinland" (aka Midgard2). A good thing in Midgard releases is fact, that even new experimental features are included, they are independent from other stable parts of the system, so you are able to test new functionalities "almost" in production environment.

To make things more powerful, we will support more cool things in Midgard2:

  • Python bindings
  • LibGDA support (Actually, you may use those with Midgard2 alpha release, which is also working nice with maemo platform.)

  • Mono bindings

  • Httpd server independence
  • Completely new architecture so you can have both "Ragnaroek" and "Vinland" installed in parallel.

I am pretty sure, many Gnome developers love Python and C. But Gnome itself didn't reach websites environment yet. Midgard gives this great possibility to join desktop and the web. Seamlessly, using unified environment. At least, we, as Midgard Community believe in it.

Bug origin

Posted on 2008-09-18 22:43:02 EEST.

Do not read Your code twice to make it much more stable and better. Write unit tests instead.

I ran Midgard test today and started to wonder what's wrong with the code:

midgard-core:ERROR:   midgard_test_metadata.c:490):midgard_test_metadata_check_person_references: 
assertion failed (metadata_property == guid): 
("1dd85b60c20d89485b611dda4935fce5036a2e8a2e8" == "f6b665f1984503790ed91f39b11b5392")

Point is that in this test I checked if person's guid is the same as the one set for object's metadata creator and revisor properties. It's not, obviously.

So what is wrong with code then:

Today I made this commit to propagate metadata properties when object is deleted. What I did wrong? I had set revisor's guid using object's guid (the one which has been deleted), not person's guid. Is it obvious when you read code? This commit fixed this nasty bug, and I needed one hour and a half to find it and fix.

For how long such bug could be existing in Midgard without unit tests? For a month? For a year? I do not want to think about this :)

Thank you GLib testing framework!

Midgard unit and regression tests

Posted on 2008-08-25 22:43:44 EEST.

I must say, I do like GLib testing framework. I already started writing Midgard tests, but still wondering what, how and why should be changed. Even now, when few things seems to be too difficult to implement, I see many very nice features:

  • Test can be automated (ok, not a big deal)
  • Test program with routines might be run through gtester
  • Once it's done, one may create xml report
  • Once xml is created, one is able to make it much more user friendly

GTester Unit Test Report

Program / Testcase Duration (sec) View Result
midgard_test3.220978 ER OK 100.00%
    /midgard_config 0.000880 - success
    /midgard_connection 0.017047 - success
    /midgard_database/create 1.514101 - success
    /midgard_database/update 1.476490 - success
    /midgard_object/basic 0.011082 - success
    /midgard_object/basic/create 0.193323 - success
    /midgard_object/basic/update 0.000527 - success
    /midgard_object/fetch 0.001588 - success
Totals: 1 Binaries, 8 Tests, 0 Failed, 8 Succeeded3.220978 - 100.00%

As test program is invoking typical API functions, I can easily run it via valgrind and catch memory leaks before they appear on production servers. And with some nice test separation, reported duration could be quite usefull to notice some obvious performance bottlenecks.

How to run Midgard 8.9.0

Posted on 2008-08-13 23:22:13 EEST.

Midgard 8.9.0 (1.9beta1) will be released soon. I have planned to make this today, but there are still small issues and bugs which must be fixed to have very nice beta version. If you feel impatient, follow me.

How to install it? It's quite simple. You can get fresh SVN checkout or install binary packages.

Build

SVN checkout

I assume you have svn client installed.

svn co https://svn.midgard-project.org/midgard/branches/branch-1-9 midgard
cd midgard
./makedist

Now you should have all tarballs. Untar all packages and build. In most cases simple build rules should be enough:

./configure 
make 
sudo make install

In case of any problems you can always get help:

./configure --help

Installing binary packages

The easiest way. Download packages from repository. We have debian, ubuntu and opensuse ones. Unfortunately, debian or ubuntu users have to download packages and install them via dpkg. I already reported apt-get way problems and let's hope guys from Opensuse will fix it soon.

Configure and install

Once Midgard package are installed. You can install new database or upgrade existing installation.

Installing new database

Just run datagard.

datagard

In this case, you will be asked few questions and datagard will:

  • create new database
  • install MidCOM from pear channel
  • create new sitegroup ( Midgard Domain )
  • create new Midgard host
  • create new Apache virtual host

If you fell, you would like to enjoy your coffee, try this:

datagard -t q

'q' or 'quick' is quick and simple mode and 'w' or 'wizard' is the mode when you are need to answer the questions.

In this mode, datagard will try to be smart as much as possible and probably will not ask you any question.

In both cases, datagard will try to use default 'midgard' unified configuration. If you would like to use different configuration, specify it:

datagard -c myconfig

Upgrade exsiting installation

Create configuration which describes your setup best, and run datagard with 'upgrade' action.

datagard -c myconfig -a upgrade

This will remove MidCOM 2.8 ( if exists ) and install new MidCOM 2.9 from new pear channel. Also database will be updated.

Running simple action

Install pear packages.

datagard -a pear

Upgrade database only

datagard -a dbupdate

Install new sitegroup

datagard -a sitegroup

Install new Midgard host

datagard -a vhost

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS