Field API defines that a functionality that is not needed on every page load, so we'd like to use the code registry to auto-load it. This means we have to require every module that wants to use Field API functions to wrap their calls in drupal_function_exists(), which is ugly, use module_invoke(), which makes pass-by-reference impossible, or by providing autoloaders. I've written a script that generates auto-loaders and works great, except that the code registry isn't available during installation.

I'm not sure what the right solution is.

Comments

damien tournoud’s picture

bjaspan’s picture

As I also mentioned in #332733: Implement a way to require that some functions are available, I changed the auto-loaders generated by my script not to require the code registry, so they now work during installation. I believe this is the best solution given the options available. There are still some minor improvements to make but the approach will remain the same.

The only question now is which Field API functions should be autoloaded and which should always be loaded. My opinion is that Field Attach API is the most often used (e.g. for every node/user/object page view). If we are auto-loading those functions, I think we should auto-load Field CRUD API too, which is the only other Field API function set currently being always-loaded.

bjaspan’s picture

Status: Active » Closed (duplicate)