Magento Forum

Corrections to Varien_Simplexml_Element
 
charitygeek
Jr. Member
 
Total Posts:  2
Joined:  2007-10-23
 

Sorry if this isn’t the right place for this, but I’m not sure where this belongs.

I was going through the Varien_SimpleXml_Element class and discovered what I think might be some possible issues. I could be wrong, but thought I’d post just in case.

Varien_Simplexml_Element class

public function descend($path)
    
{
        
#$node = $this->xpath($path);
        #return $node[0];

        
$pathArr explode('/'$path);
        
$desc $this;
        foreach (
$pathArr as $nodeName{
            
if (strpos($nodeName'@')!==false{
                $a 
explode('@'$nodeName);
                
$b explode('='$a[1]);
                
$nodeName $a[0];
                
$attributeName $b[0];
                
$attributeValue $b[1];
                
$found false;
                foreach (
$this->$nodeName as $desc{
                   
if ((string)$nodeChild[$attributeName]===$attributeValue{
                        $found 
true;
                        break;
                    
}
                }
                
if (!$found{
                    $desc 
false;
                
}
            } 
else {
                $desc 
$desc->$nodeName;
            
}
            
if (!$desc{
                
return false;
            
}
        }
        
return $desc;
    
}

shouldn’t the following line:

foreach ($this->$nodeName as $desc{
                   
if ((string)$nodeChild[$attributeName]===$attributeValue{
                        $found 
true;
                        break;
                    
}

be:

foreach ($this->$nodeName as $desc => $nodeChild{
                   
if ((string)$nodeChild[$attributeName]===$attributeValue{
                        $found 
true;
                        break;
                    
}

Otherwise, $nodeChild remains undefined.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

@charitygeek: you are correct. thank you for the find smile

The reason it’s still there is because we have never used attribute selectors in our models, it was a potential functionality.
The first time we would implement something that uses node@attribute=value, we would get a notice, because all of us develop with E_ALL | E_STRICT.

The fix would be:

if ((string)$desc[$attributeName]===$attributeValue{

Thank you again.

 
Magento Community Magento Community
Magento Community
Magento Community
 
charitygeek
Jr. Member
 
Total Posts:  2
Joined:  2007-10-23
 

Yeah, I see that there’s even a large chunk of code that’s been commented out, though I haven’t really looked at it all that closely. I’ve been playing around with the SImpleXml library code you’ve implemented into Magento and would like to use it for some additional projects that I’m working on. I assume that the license for Magento also applies to the Varien library classes. I’d also be interested in helping out with the development of Magento.

A few years ago I got diagnosed with a rare lung disease that causes my lungs to spontaneously collaspe, and has led to severe COPD. Unable to work, and on disability, I decided to turn me hobby of programming into a mission and started doing volunteer programming for non-profits. I’ve since met up with another programming geek, who is also on disability, and we’ve started a venture called Charity Geeks, which is an on-going project of our non-profit organization. I hope to expand our network to include other programmers and service providers in similar situations who want to put their skills to use and help others.

We’re currently developing a range of open source web applications and free service-based sites, and we are very interested in integrating Magento into our signature project. You’ve developed a tremendous application that really identifies the needs of businesses and shop owners. I look forward to helping non-profits integrate Magento into their organizations.

Sean

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top