Modify

Ticket #350 (closed defect: wontfix)

Opened 2 years ago

Last modified 2 years ago

Phing 2.2.0 + HTMLPurifier 3.3.0 fail (__autoload()?)

Reported by: yannick.warnier@… Owned by: mrook
Priority: minor Milestone: 2.4.0RC3
Component: phing-tasks-ext Version: 2.2.0
Keywords: Cc: yannick.warnier@…

Description

Hi guys,

First of all, thanks for phing. We've only started using it but it really helps structuring our packaging process.

Now, we're trying to package Dokeos (a GPL e-learning solution) but we're having a problem with the auto-loading of HTMLPurifier, which uses an autoload function which, frankly, works fine outside of phing, but doesn't inside.

We're using Phing with the SimpleTest framework (and its undocumented Phing extension). When starting our test suite directly from SimpleTest, everything works fine.

When launching the test suite through phing, the HTMLPurifier library (which I think is the only one in Dokeos that uses an autoload mechanism so far) isn't loaded anymore, and we get messages that say "Trying to use undeclared HTMLPurifier class".

I've read a few posts about problems with Phing, PHPUnit and autoload, but honestly I'm not much into the autoload stuff, so I would appreciate if someone who understands the problem can give me a hand.

As far as I understand, there is a way to launch the autoload function before we launch the tests, using an adhoc task (ticket #117) but I don't see how to do this in my case.

Apparently, the autoload mechanism is launched from one of the HTMLPurifier files (quoted below):

if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) {

We need unregister for our pre-registering functionality HTMLPurifier_Bootstrap::registerAutoload(); if (function_exists('autoload')) {

Be polite and ensure that userland autoload gets retained spl_autoload_register('autoload');

}

} elseif (!function_exists('autoload')) {

function autoload($class) {

return HTMLPurifier_Bootstrap::autoload($class);

}

}

Is there anyone around here who can help me get out of this easily? Does any more recent version of Phing fix that?

Also, I don't know if I will be mailed automatically if somebody answers this, but I'd like to.

Thanks,

Yannick

Attachments

build.xml Download (2.4 KB) - added by yannick.warnier@… 2 years ago.
Build file (sorry for the delay)

Change History

comment:1 Changed 2 years ago by mrook

  • Status changed from new to assigned

Hi Yannick,

How are you loading HTMLPurifier in your tests (or test suite)? With the following snippet I do not see any errors:

<?php

require_once 'HTMLPurifier.auto.php';

class PurifierTest extends SimpleTestCase
{
	function testPurifier()
	{
	    $purifier = new HTMLPurifier();
	}
};

?>

comment:2 Changed 2 years ago by mrook

To clarify, this is using Phing trunk, HTML purifier 4.0, SimpleTest trunk and a few small changes to Phing as SimpleTest changed its API (again).

comment:3 Changed 2 years ago by yannick.warnier@…

Hi mrook,

I'm not using trunk versions. I'm not loading HTMLPurifier in my tests, but rather in the code to be tested. I guess this might be the problem. If this doesn't fix the problem, I'll be back with more info. Otherwise, I guess you can consider this fixed if I'm not posting back here within 7 days.

Thank you.

comment:4 Changed 2 years ago by mrook

  • Type changed from defect to feedback

Yannick,

Can you give me some example source + build files that will help me to reproduce the problem?

Michiel

comment:5 Changed 2 years ago by mrook

  • Status changed from assigned to infoneeded
  • Type changed from feedback to defect
  • Milestone changed from 2.4.0RC1 to 2.4.0RC2

comment:6 Changed 2 years ago by yannick.warnier@…

Sorry for the delay but it seems the snippet fixed the problem. Providing you with example sources is very difficult for me right now as I have to get these files on another user's machine and I'm not with much free time at the moment. Sorry about that.

I will ask him to provide his build file. The project (sources) is Dokeos and you should be able to get it in Mercurial from  https://sources.dokeos.com/public/dokeos

comment:7 Changed 2 years ago by yannick.warnier@…

Seems like we can't attach the build file here (considered as SPAM with a 79% Bayesian probability)

Changed 2 years ago by yannick.warnier@…

Build file (sorry for the delay)

comment:8 Changed 2 years ago by mrook

  • Status changed from infoneeded to assigned

comment:9 Changed 2 years ago by ywarnier@…

Hi there,

Just to let you know that, so far, the fix with autoload seemed to have worked. We are currently running a bunch of tests (around 500) automatically for Dokeos.

We also connected it (for what it's worth) to Xinc and I'm currently running it almost completely automatically (there seems to be a few problems with the Xinc Hg update) as a Mercurial -> SimpleTest -> Phing -> Xinc process. It is providing us with a clear view of what regressions we might have in the code (although none has been detected so far :-)).

I know this isn't a xinc site, but for more info on the SimpleTest + Hg integration, I have put the code here:  http://code.google.com/p/xinc/issues/detail?id=206

Thanks for the great work with phing!

comment:10 Changed 2 years ago by mrook

  • Status changed from assigned to closed
  • Resolution set to wontfix

Yannick,

that's great news - good luck with the entire integration process :)

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.