Complete error message:

Fatal error: require_once() [function.require]: Failed opening required 'HTMLPurifier/DefinitionCache.php' (include_path='./:/cust-web/*/*/********/sites/www.*******.**/include:/cust-web/*/*/*******/sites/include:/usr/share/php') in /cust-web/*/*/*******/sites/www.*******.**/html/sites/all/modules/htmlpurifier/HTMLPurifier_DefinitionCache_Drupal.php on line 3

* taken out account info

I'm busy migrating our websites to a new (shared) UNIX hosting provider. After uploading I was greeted with this error-message for both sites. The sites break and the only way to fix this seems to be to remove the HTML purifier module directory. This is kinda sucky as we plan to go live Tuesday.

Any thoughts on what is causing this and how to solve it?

My hunch is that it has to do with a php.ini setting that the HTML affects the HTML purifier module as the servers folder structure is:

/
-sites
-- includes
-- www.******.**
----html (drupal install dir)
----include

Comments

RedTop’s picture

Had a brainwave for a stop-gap measure:

I copied the HTML purifier library to one of the include directories as well. That seems to do the trick. However, ideally HTML purifier shouldn't be thrown off like this when a server has include_path configured... If you Google you will find lots of websites that apparently deal with similar issues...

ezyang’s picture

Status: Active » Postponed (maintainer needs more info)

This should not ever happen, since Drupal DefinitionCache is only ever loaded after require'ing HTMLPurifier.auto.php, which should modify the include_path appropriately. However, I don't see the appropriate include_path in your error message. Is there anything strange about your setup?

RedTop’s picture

I'm on shared linux hosting business plan (with a reputable ISP in Australia) so I don't know the ins and outs of the server config, although I do have a feeling that the setup is somewhat exotic. For example, I ran into permission/owner issues on the files folder, this particular issue and some strange behaviour of the FTP server in that it doesn't show hidden files (such as .htaccess) in the FTP client by default.

The server is hardened using suhosin.

ezyang’s picture

Ok. Can you place a line var_dump(get_include_path()); in HTMLPurifier.auto.php before and after the autoload include? What does it output?

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Active

Hello,

we are recommended to put the library in sites/all/libraries, but this line is still in modules/htmlpurifier/HTMLPurifier_DefinitionCache_Drupal.php:

require_once 'HTMLPurifier/DefinitionCache.php';

and this also fails in HTMLPurifier.auto.php:

set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once 'HTMLPurifier/Bootstrap.php';
require_once 'HTMLPurifier.autoload.php';

Whatever that's trying to do, doesnt do it. It doesnt change the path on my client's hosting.

ezyang’s picture

Status: Active » Postponed (maintainer needs more info)

Hello,

Are you by any chance setting the include path via a .htaccess file?

RedTop’s picture

Sorry for not getting back to you ezyang. It's just that I need to find a proper time to do this as it only affects our production environment (dev is hosted somewhere else...). That obviously means putting the site in maintenance mode so I will have to do some planning and try and do updates at the same to minimise the time the amount of time(s) the site if offline..

I'll get back to you soon.

RedTop’s picture

Today we updated our production environment so I got a chance to test what you suggested. Adding those lines didn't make a difference (no output whatsoever) so it seems as if HTMLPurifier.auto.php is being ignored...

I have not set the include path using the .htaccess file.

I've send you a PM with additional info.

ezyang’s picture

Ah, the fact that auto.php is not being loaded all is interesting. Do you have warnings/notices enabled for your site? Can you get a trace from code executing in HTMLPurifier_DefinitionCache_Drupal.php? What happens if you add an include for HTMLPurifier.auto.php at the top of HTMLPurifier_DefinitionCache_Drupal.php?

ezyang’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
Helmut Neubauer’s picture

I've the same problem. If I change the php include path from .: to .:/usr/share/php HTML Purifier causes blank sites due to include fails.

My HTML Purifier is located in libraries (not module).
Adding var_dump(get_include_path()); in HTMLPurifier.auto.php (#4) returns the HTML purifier library path if I don't change the php include path (.:) and nothing if I change the php include path.

If I add an include for HTMLPurifier.auto.php at the top of HTMLPurifier_DefinitionCache_Drupal.php (#9), I'll get the warning:
warning: require_once(HTMLPurifier.autoload.php): failed to open stream: No such file or directory in /var/www/vhosts/mydomain/httpdocs/sites/all/modules/htmlpurifier/HTMLPurifier_DefinitionCache_Drupal.php on line 3.

Helmut Neubauer’s picture

Status: Closed (cannot reproduce) » Active
Helmut Neubauer’s picture

Version: 6.x-2.3 » 6.x-2.4

Normally there is no problem with HTML purifier if PHP include_path is empty (".:"). But If you need to extend this PHP include_path (for example ".:/usr/share/php/" to include PHP classes installed by PEAR), HTML purifier causes blank sites because require_once 'HTMLPurifier/DefinitionCache.php'; of HTMLPurifier_DefinitionCache_Drupal.php fails.

It seems setting the include path of HTML purifier library (HTMLPurifier.auto.php) isn't called anymore. I don't know why. Has anyone an idea? I'm not sure if there are problems with other modules interfering. Is there anyone having this problem, too?

As workaround you don't need to copy the whole library. Simply add the library folder of HTMLPurifier also to the PHP include_path. I did it by adapting my vhost.conf:

php_admin_value include_path ".:/var/www/vhosts/mydomain/httpdocs/sites/all/libraries/htmlpurifier/library:/usr/share/php"

heddn’s picture

Assigned: Unassigned » heddn
Status: Active » Postponed (maintainer needs more info)

@Helmut Neubauer
In HTMLPurifier.auto.php from the HTML Purifier library, is your path set to:
.:/usr/share/php:/usr/share/pear
prior to line 6? When set to that, things still work for me.

What is shown by get_include_path() on line 292 of htmlpurifier.module, right before you call? require_once "$library_path/library/HTMLPurifier.auto.php";
For me it is showing: .:/usr/share/php:/usr/share/pear
And also, what is shown by get_include_path() on line 3 of HTMLPurifier_DefinitionCache_Drupal.php, right before you call? require_once 'HTMLPurifier/DefinitionCache.php';
For me it is showing: ~/websites/drupal-6/sites/all/libraries/htmlpurifier/library:.:/usr/share/php:/usr/share/pear

francis004’s picture

Title: require_once(HTMLPurifier/DefinitionCache.php) [function.require-once]: failed to open stream » Fatal error: require_once() [function.require]: Failed opening required '/home/avavapro/public_html/includes/lock.inc' (include_
Project: HTML Purifier » upload (simple)
Version: 6.x-2.4 » master
Assigned: heddn » francis004
Priority: Normal » Critical

hi, please i'm having issues with my site after uploading it from my local machine to a host.it gives me that error message when i go to the site's url and i totally don't have an idea on how to go about it because i'm new to this. Can somebody please give me step by step instructions on how to go about it because i'm lost right now and have a deadline to meet thanks.