Forums / Developer / [core] extend kernel code

[core] extend kernel code

Author Message

Frederic GUEHO

Thursday 15 February 2007 4:59:30 am

I'd like to change tiny lines of code in some classes of the core of eZ Publish.

But, in order to avoid problems later when upgrading my eZ Publish version, I'd like to do all my changes in an unique extension. So that, when upgrading or re-installing my site, I only have to activate my extension.

Firstly, it seems pretty cool to me and I thought I can do that easily with eZ Publish. But now, I have to do it, I have no idea how to do that.

Any help ?

Thanks.

Fred

Kristof Coomans

Thursday 15 February 2007 6:37:02 am

I think the only solution for this is using the include_path PHP setting. If you make it look first in a dir with your patched files, and afterwards in the current directory, then you can use your own patched kernel files.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

kracker (the)

Thursday 15 February 2007 8:17:32 pm

This is a subject of keen interest for those more suited to php code modifications of the eZ publish kernel, lib aka stock eZ publish.

<i>http://ezpedia.org/wiki/en/ez/creating_and_maintaining_an_ez_publish_patch</i>

While brief and over simplified here is a starting point for others to share their experiences with this subject with everyone.

//kracker

<i>eminem - the way i am .. (instrumentals)</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Frederic GUEHO

Friday 16 February 2007 3:34:58 am

Thanks for your replies but I don't understand :
1 - the include_path recommandation
2 - the ezpedia article

Do you have a simple example for both of them (in which case to use them ? how to use them ?)

Thanks.

Claudia Kosny

Friday 16 February 2007 5:38:34 am

Hi Frederic

PHP uses the include path to find files that are included in other files with include(...) or require(...). If you change the include path, you can make sure that eZ looks first looks in whatever directory you specified, before looking in the default eZ directories.
Example:
Add this to the index.php

$path = 'my_ez_core_replacements';
set_include_path($path . PATH_SEPARATOR . get_include_path());

my_ez_core_replacements is the name of the directory where your patched files are located.

Please note that you can set the include path also in the htaccess or php.ini, which might be better, just check the PHP docu.

Now, when eZ runs a script where include_once('kernel/classes/ezcontentobjecttreenode.php') is called (which is jsut an arbitrary example), PHP will first look for the file my_ez_core_replacements/kernel/classes/ezcontentobjecttreenode.php. If it does not find the file there, it will check the other directories in the include_path.

This will not work like an extension, but you still can keep your changed files in one location and just need to change the include path of your PHP to use the new files.

Claudia

Frederic GUEHO

Wednesday 21 February 2007 4:59:22 am

Ok. Thanks.

Does my new directory need to be in the root of my install ?
Or can I put this new directory elsewhere ?

Claudia Kosny

Wednesday 21 February 2007 10:35:40 am

Hi Frederic

Afaik putting it elsewhere should be fine as long as you provide the correct folder in the setting for the include_path and the folder is accessible by PHP.

Claudia