Running against a build from the latest SVN, I ran into an issue when creating a new task[1], it was caused in UnknownElement at line 133 when $this->project was equal to NULL. The issue arose when I add <include /> elements to a <fileset> within the new task. Adjusting the code as follows worked, but introduced another issue:
@@ -130,7 +130,8 @@
$realChild = $this->makeTask($child, $childWrapper, false);
$parent->addTask($realChild);
} else {
- $realChild = $ih->createElement($this->project, $parent, $child->getTag());
+ $project = is_null($this->project) ? $parent->project : $this->project;
+ $realChild = $ih->createElement($project, $parent, $child->getTag());
}
$childWrapper->setProxy($realChild);
The issue that it introduces is at line 142, but can be addressed via:
@@ -138,7 +139,9 @@
$realChild->setRuntimeConfigurableWrapper($childWrapper);
}
- $child->handleChildren($realChild, $childWrapper);
+ if ($realChild instanceof ProjectComponent) {
+ $child->handleChildren($realChild, $childWrapper);
+ }
if ($realChild instanceof Task) {
$realChild->maybeConfigure();
}
It appears that if you just specify that handleChildren() should only be called when the $realChild variable is a ProjectComponent, you can avoid any warnings from the logger.
It's entirely possible that my Task is not properly formatted for some reason. I was following the instructions available in the current manual along with some investigation into the tasks system with the current code. Applying the above patches and re-building the package fixes the issue I was having.
Below is the original fatal error that started my looking through the code:
[PHP Error] Argument 1 passed to IntrospectionHelper::createElement() must be an instance of Project, null given, called in /usr/share/php/phing/UnknownElement.php on line 133 and defined [line 384 of /usr/share/php/phing/IntrospectionHelper.php]
Fatal error: Call to a member function log() on a non-object in /usr/share/php/phing/IntrospectionHelper.php on line 394
Call Stack:
0.0005 68700 1. {main}() /usr/share/php/phing.php:0
0.1051 4174556 2. Phing::fire() /usr/share/php/phing.php:41
0.1051 4174804 3. Phing::start() /usr/share/php/phing/Phing.php:262
0.1071 4242392 4. Phing->runBuild() /usr/share/php/phing/Phing.php:164
0.7476 21538208 5. Project->executeTargets() /usr/share/php/phing/Phing.php:516
0.7476 21538208 6. Project->executeTarget() /usr/share/php/phing/Project.php:682
0.9150 21571944 7. Target->performTasks() /usr/share/php/phing/Project.php:709
0.9154 21571944 8. Target->main() /usr/share/php/phing/Target.php:263
0.9196 21612728 9. Task->perform() /usr/share/php/phing/Target.php:240
0.9196 21612728 10. UnknownElement->maybeConfigure() /usr/share/php/phing/Task.php:253
0.9202 21613376 11. UnknownElement->handleChildren() /usr/share/php/phing/UnknownElement.php:76
0.9213 21623428 12. UnknownElement->handleChildren() /usr/share/php/phing/UnknownElement.php:141
0.9215 21623592 13. IntrospectionHelper->createElement() /usr/share/php/phing/UnknownElement.php:133
[1]: https://svn.domain51.com/pear/trunk/src/Domain51/Phing/Task/AddNamespaceTask.php