mustafau requested a zend_set_include_path that would alter the include path:


function _parser_zend_feed_set_include_path() {
  $include_path = get_include_path();
  $include_path .= PATH_SEPARATOR . drupal_get_path('module', 'parser_zend_feed') .'/library';
  set_include_path($include_path);
}

function _parser_zend_feed_restore_include_path() {
  restore_include_path();
}

This is for 6.x and 5.x branches.

CommentFileSizeAuthor
#7 zend_path.patch1.63 KBrobloach

Comments

robloach’s picture

Assigned: Unassigned » robloach
Status: Active » Fixed

Fixed by 92034 and 92032 for both Drupal 5 and Drupal 6.

mustafau’s picture

Status: Fixed » Active

A hook_init() implementation in Zend module for 6.x can be used to call zend_set_include_path().

zend_set_include_path() function should try to include a Framework class (example: include_once 'Zend/Version.php';) before altering the path. Then if that fails Zend Framework's library path should be located and added to the include path.

hook_init() implementations in 5.x are called on every page request including cached pages. This means 5.x version of Zend module should not rely on hook_init(). Other modules should call zend_set_include_path() before including Zend Framework classes.

robloach’s picture

Here's the todo list......

Drupal 5:
Put zend_set_include_path in hook_menu(!$may_cache).

Drupal 6:
Put zend_set_include_path in hook_init.

zend_include():
Remove the zend_set_include_path stuff,

zend_set_include_path():
Add in a check to zend_ready(FALSE) before adding the include path.

robloach’s picture

Status: Active » Fixed

http://drupal.org/cvs?commit=92063
http://drupal.org/cvs?commit=92061

In Drupal 5, you don't have to call zend_set_include_path before using it because it's called in hook_menu(!$may_cache)...

mustafau’s picture

Status: Fixed » Active

I do not like the idea of putting Zend into the module folder because if we do so module files are going to be added to the include path. Instead, should we change the default location to a "library" folder under the module folder. We can put an empty folder named "library" to the distribution package of the module.

The function:

function zend_get_path() {
  return variable_get('zend_path', drupal_get_path('module', 'zend'));
} 

Should be like following:

function zend_get_path() {
  return variable_get('zend_path', drupal_get_path('module', 'zend') .'/library');
} 
robloach’s picture

This is the default directory and can be changed in the settings. In reality, it should just be blank because most people just add it to the PHP include path manually...

robloach’s picture

Title: zend_set_include_path() » Change default Zend path
StatusFileSize
new1.63 KB

I think the default path should be blank as most "newer" servers include the Zend Framework by default (already in the include path). Any thoughts on this?

robloach’s picture

Status: Active » Needs review
mustafau’s picture

I agree.

robloach’s picture

Status: Needs review » Patch (to be ported)

Management of this is much easier now. The Zend Framework installation directory defaults to already being included. When the user wants to specify a different path, the system then takes care of including that path for you when it needs the Zend Framework. So, when you need a Zend Framework class, you just do something along the lines of:

if (zend_initialize('Zend_Gdata')) {
   $gdata = new Zend_Gdata();
   $gdata->doStuff();
}
else {
  echo 'Zend GData not available!';
}

Very easy! I've published the REST Server which uses this.

.... This has to be ported to the Drupal 6 branch.

robloach’s picture

Status: Patch (to be ported) » Fixed
mustafau’s picture

Priority: Normal » Critical
Status: Fixed » Active

This breaks my module: http://drupal.org/cvs?commit=94223

zend_require() should not call zend_restore_include_path().

robloach’s picture

Status: Active » Fixed

Whoops, thanks. It's strange because that was in the DRUPAL-6--1 branch, but seemed to miss it in the DRUPAL-5 branch. It's in now.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.