phalcon/cphalcon — pull request #840 by sjinks (2013-07-13 08:18:49+00:00)
Title: [NFR] Explicitly mention dependecies on modules used at coompile time

Right now Phalcon uses SPL, PCRE, JSON, Session modules if they present at compile time. Those modules can be built either statically into PHP or as DSOs.

If a module Phalcon depends on is built as a DSO and then later is disabled in php.ini, this may lead to very interesting crashes due to unresolved external symbol. Module dependencies will ensure that all required modules are present at runtime and provide meaningful diagnostics if one of the required modules is missing.

This PR implements the following:
* 0ca55d6 and 4db3834 add known module dependencies to config.m4 (strictly speaking this is necessary only when Phalcon is built statically into PHP (as an offtopic, if Phalcon is built into PHP and LTO is enabled, this could give quite noticeable performance improvement due to better opportunities for inlining and IPO)) and phalcon.c; this will ensure the correct order of initialization of extensions
* 4db3834 also removes conditional checks against old ZEND_MODULE_API_NO numbers (those numbers correspond to PHP 4.x, if I am not mistaken) and adds `GINIT` function used to initialize module globals (this is the preferred way over `ZEND_INIT_MODULE_GLOBALS(phalcon, php_phalcon_init_globals, NULL)` used for backwards compatibility with ancient PHP versions)
* f2392c9 introduces kernel/session.c and kernel/session.h which provide transparent access to the PHP Session API (either via calls to native functions or via calls to the userland); f4d1ee6 uses this API in `ext/session/adapter.c` (this looks better than a bunch of #ifdefs)
* bce8607 provides an abstraction for `preg_match` regardless whether PCRE is available at compile time and now it is sufficient to call `phalcon_preg_match` without any #ifdefs

To be done:
* 0ca55d6 works reliably only for *nix; Windows builds currently use a hack (in the bottom of php_phalcon.h) because I don't know the equivalent for `AC_CHECK_HEADER()` for `config.w32`; in other words, nothing has changed for Windows. I need help here.
* `build/*/config.m4` will need to be updated, too