I have officially commited the change a few minutes ago and marked the
classes JSimpleXML and JSimpleXMLElement as deprecated. However, it is
still used in the core since currently none of the people with the
"official" developers hat on have the time to properly clean this up and
rewrite the code. A quick search came up with 15 matches where it is
used in a function in our framework. I would be very happy if someone
would take up this task and look into replacing the calls to
JFactory::getXMLParser('Simple') and subsequent function calls with the
correct classes and functions from SimpleXML. Unfortunately, they are
not 100% equal. As always: If you come up with a (working) patch, we
commit it to the trunk. :-) If you are willing to work on this, write a
quick response and open a tracker item in the 1.6 feature patch tracker:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemBrowse&tracker_id=8549
Thank you!
Hannes
Why don't you just do a:
class JSimpleXMLElement extends SimpleXML { }
It actually would allow you to fix some PHP SimpleXML bugs which are
in PHP < 5.2.4... unless Joomla 1.6 is PHP >= 5.2.4...
class JSimpleXMLElement extends SimpleXMLElement {
/**
* Get the name of the element.
* Warning: don't use getName() as it's broken up to php 5.2.3
included.
*
* @return string
*/
function name( ) {
if ( version_compare( phpversion(), '5.2.3', '>' ) ) {
return $this->getName();
} else {
return $this->aaa->getName(); // workaround php bug number 41867,
fixed in 5.2.4
}
}
}
It would allow to add some useful functions missing from the PHP
SimpleXML class as well.
Best Regards,
Beat
http://www.joomlapolis.com/
> quick response and open a tracker item in the 1.6 feature patch tracker:http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemBr...
>
> Thank you!
>
> Hannes
The quick search turned out the following 15 results:
installation/includes
aplication.php
libraries/joomla
application
helper.php (2X)
form
form.php
html
parameter.php
installer
helper.php
installer.php
librarymanifest.php
packagemanifest.php
adapters
file.php
library.php
package.php
plugin.php
language
help.php
language.php
As far as I can see, JForm (and it's fields and rules classes) needs
most attention (along with JParameter).
I would suggest a new factory method like loadXMLFile() which could be
like this:
/**
* Reads a XML file.
*
* @param string $path Full path and file name.
*
* @return mixed JSimpleXMLElement on success | false on error.
*/
public static function loadXMLFile($path)
{
if( ! file_exists($path)) {
return false;
}
jimport('joomla.utilities.simplexmlelement');
return simplexml_load_file($path, 'JSimpleXMLElement');
}//function
along with beats suggestion.
The first try can be seen here:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=19272
Regards,
Nikolai
On Jan 3, 3:29 pm, Beat <beat...@gmail.com> wrote:
> Hi Hannes,
>
> Why don't you just do a:
>
> class JSimpleXMLElement extends SimpleXML { }
>
> It actually would allow you to fix some PHP SimpleXML bugs which are
> in PHP < 5.2.4... unless Joomla 1.6 is PHP >= 5.2.4...
>
> class JSimpleXMLElement extends SimpleXMLElement {
> /**
> * Get the name of the element.
> * Warning: don't use getName() as it's broken up to php 5.2.3
> included.
> *
> * @return string
> */
> function name( ) {
> if ( version_compare( phpversion(), '5.2.3', '>' ) ) {
> return $this->getName();
> } else {
> return $this->aaa->getName(); // workaround php bug number 41867,
> fixed in 5.2.4
> }
> }
>
> }
>
> It would allow to add some useful functions missing from the PHP
> SimpleXML class as well.
>
> Best Regards,
> Beathttp://www.joomlapolis.com/
Regards,
Andrew Eddie
http://www.theartofjoomla.com - the art of becoming a Joomla developer
2010/1/4 Beat <bea...@gmail.com>:
> --
>
> You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
> To post to this group, send an email to joomla-dev...@googlegroups.com.
> To unsubscribe from this group, send email to joomla-dev-frame...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joomla-dev-framework?hl=en-GB.
>
>
>
Sam Moffatt
http://pasamio.id.au
Hi Andrew,
To reply to your question: If you don't want to need to implement a
Joomla-specific class for SimpleXML for fixing a bug, 5.2.4+ would
make sense.
btw: I didn't see significant performance in extending
SimpleXMLElement, and it nicely extends the whole tree fine.
Setting minimum higher than 5.2.0 would also make sense for many other
bugs of PHP 5.2.0, 5.2.1 and up to 5.2.5 in particular. I've lately
also ran into a very wierd php memory-corruption bug which was
corrupting heavily referenced function parameters, and got fixed only
in 5.2.6.
One example of a heavy debug in CB on this PHP < 5.2.5 memory/
parameter-corruption bug here:
https://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/id,118876/catid,88/limit,6/limitstart,30/
we have in CB a db function (method):
function & loadTrueObjects( $class = null, $key = "",
$additionalVars = array() ) { .... }
that was called with only 2 params, but the third didn't default to
array() in a heavily loaded config !!!!
So, if you want to avoid such very very weird bugs taking days to
debug, I strongly recommend setting PHP 5.2.6 as a sound minimum for
Joomla 1.6.
When using SimpleXMLElement a great amount of type casting is
required. Some people find this tedious so - extending the
SimpleXMLElement could make sense.
Example:
==Accessing attributes==
JSimpleXML
$xml->attributes('foo');
SimpleXMLElement
(string)$xml->attributes()->foo;
? JSimpleXMLElement
$xml->getAttribute('foo');
public function getAttribute($name)
{
return (string)$this->attributes()->$name;
}//function
==Accessing data==
JSimpleXML
$xml->foo->data();
SimpleXMLElement
(string)$xml->foo;
? JSimpleXMLElement
$xml->foo->data();
public function data()
{
return (string)$this;
}//function
In my patches I haven't implemented the first but the latter, just
because it required no changes to the existing code.
I have finished the form package (i think) and this afternoon (night)
I will look into the installer.
JParameter - what about this class ?
An argument to have a Joomla! (factory) function to load XML files
would also be that you could have JError to display parse and loading
errors.
see: http://www.php.net/manual/en/simplexml.examples-errors.php
Best regards,
Nikolai
On 5 Jan, 09:34, Beat <beat...@gmail.com> wrote:
> On Jan 5, 6:25 am, Andrew Eddie <mambob...@gmail.com> wrote:
>
> > Should we consider, then, raising the minimum spec to PHP 5.2.4?
>
> Hi Andrew,
>
> To reply to your question: If you don't want to need to implement a
> Joomla-specific class for SimpleXML for fixing a bug, 5.2.4+ would
> make sense.
> btw: I didn't see significant performance in extending
> SimpleXMLElement, and it nicely extends the whole tree fine.
>
> Setting minimum higher than 5.2.0 would also make sense for many other
> bugs of PHP 5.2.0, 5.2.1 and up to 5.2.5 in particular. I've lately
> also ran into a very wierd php memory-corruption bug which was
> corrupting heavily referenced function parameters, and got fixed only
> in 5.2.6.
>
> One example of a heavy debug in CB on this PHP < 5.2.5 memory/
> parameter-corruption bug here:https://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,3...
Best regards,
Nikolai
> quick response and open a tracker item in the 1.6 feature patch tracker:http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemBr...
>
> Thank you!
>
> Hannes
In the end, this patch is a great improvement. In a short test, it meant
a performance improvement of about 15-20% when using JForm. 30% with the
translation changes, 20% with this patch... If we keep it up, J! will
render before you even start the request. ;-)
Hannes
20% of speed improvement sounds amazing. I had no idea it could be so
significant.
Nikolai
On Jan 7, 4:11 am, Hannes Papenberg <hackwa...@googlemail.com> wrote:
> Hello Nikolai,
> great patch, I like it, but could you do me three favours?
> 1. Please don't remove simplexml.php in your patch. We deprecated it,
> but we wont remove it before 1.7 or 1.8.
> 2. Due to the same reason, the JFactory function to get a JSimpleXML
> object should not be removed.
> 3. Can you recreate this patch against the current trunk? There have
> been some modifications that create issues.
>
> In the end, this patch is a great improvement. In a short test, it meant
> a performance improvement of about 15-20% when using JForm. 30% with the
> translation changes, 20% with this patch... If we keep it up, J! will
> render before you even start the request. ;-)
>
> Hannes
>
> Am 07.01.2010 06:33, schrieb El KuKu:
>
> > Hello,
> > a complete patch is ready waiting for a review
> >http://joomlacode.org/gf/download/trackeritem/19272/47128/AA_complete...
Hannes
1) JSimpleXMLElem vs JSimpleXMLElement will create confusion.
2) why not do the real stuff: replace the existing JSimpleXMLElement
by the new one: JSimpleXMLElement has been written exactly with that
in mind... ;-) :
class JSimpleXMLElement extends SimpleXMLElement {
}
and not depreciate JSimpleXMLElement as the goal was to remake the old
functions ? :-)
Best Regards,
Beat
http://www.joomlapolis.com/
It's only that his point 2) interferes with your former point 1)
You would have two classes with the same name and the ability to load
them both.
Please correct me if I'm wrong...
Nikolai
Hannes
Just to clarify:
At the moment there a two classes:
JSimpleXML
AND
JSimpleXMLElement
So if you keep JSimpleXML you cannot remove or modify
JSimpleXMLElement.
The initial idea was to remove JSimpleXML and keep a modified version
of JSimpleXMLElement extending and so adopting the syntax of PHPs
SimpleXMLElement.
As for the syntax - well I thought that it was the point we were
talking about - changing the syntax to generic SimpleXML..
What to do ?
Nikolai
The installer adapters may not work as expected... I did some testing
installing J! 1.5 style components and it seems OK so far..
Regards,
Nikolai
I made some changes to the installer adapters and tested them with the
'alpha' packages I found in SVN in testing/branches/installer_samples,
some slight formatting as Hannes told me, and updated to rev. #14146.
http://joomlacode.org/gf/download/trackeritem/19272/47290/AA_complete_V3.patch
Regards,
Nikolai
On Jan 10, 8:55 pm, El KuKu <joo...@nik-it.de> wrote:
> Here comes the second version:http://joomlacode.org/gf/download/trackeritem/19272/47256/AA_complete...
since new SimpleXML, there is a problem for installing plugin (http://
joomlacode.org/gf/download/trackeritem/19018/47297/plg_mycategory.zip)
There are also some errors due to the addAttribute which can not
support add operation when the attribute already exist (see the
chdemko branch)
Ch.D
On 13 jan, 16:35, Hannes Papenberg <hackwa...@googlemail.com> wrote:
> Commited.
>
> Am 13.01.2010 05:41, schrieb El KuKu:
>
> > Hello again ;)
>
> > I made some changes to the installer adapters and tested them with the
> > 'alpha' packages I found in SVN in testing/branches/installer_samples,
> > some slight formatting as Hannes told me, and updated to rev. #14146.
> >http://joomlacode.org/gf/download/trackeritem/19272/47290/AA_complete...
The addAttribute() method in SimpleXMLElement will throw a warning if
the attribute already exists. As this behavior is different to
JSimpleXML it might require some more changes.
You can test if the attribute exists - Try:
if($xml->foo->attributes()->bar)
{
$xml->foo->attributes()->bar = 'baz';
// Or you can add
$xml->foo->attributes()->bar = $xml->foo->attributes()->bar.'baz';
// But you can not
$xml->foo->attributes()->bar .= 'baz';
}
else
{
$xml->foo->addAttribute('bar', 'baz2');
}
If you could point me to the errors I would prepare another patch to
save you some work ;)
Regards,
Nikolai