List Info

Thread: RE: ProjectInfoAPI Documenation




RE: ProjectInfoAPI Documenation
country flaguser name
Canada
2007-09-13 09:36:38
Phoenix Devs,

This morning I adapted ProjectInfoList to use the
ProjectInfoData class that
Bjorn provided last night.  I find this to be a much more
elegant solution
and it relieves some of the questions / difficulties that I
had when
implementing the original ProjectInfo class for my category
pages.

I did however encounter a bug when trying to retrieve data
from Multi Record
data such as "mailinglist", "newsgroup",
and I would imagine "release" would
be the same. 

	$projectInfoData->newsgroup[0]->name;
	$projectInfoData->newsgroup[1]->name;

Would both return the same values.  The newsgroup[] array
had the right
number of records but all records were identical.  I dove
into the class and
found the culprit in the __get() function.

Original 

	foreach( $this->rows as $rr ) {
		if( $rr['MainKey'] == $mainkey) {
			$subrows = array();
			foreach( $this->rows as $rr ) {
				if( $row['ProjectInfoID'] ==
$rr['ProjectInfoID']) {
					$subrows[] = $rr;
				}
			}
			$result[] = new ProjectInfoValues( $this, $subrows
);
		}
	}


Fixed 

	foreach( $this->rows as $rr ) {
		if( $rr['MainKey'] == $mainkey) {
			$subrows = array();
			foreach( $this->rows as $rrr ) {
	
				if( $rr['ProjectInfoID'] ==
$rrr['ProjectInfoID']) {
					$subrows[] = $rrr;
				}
			}
			$result[] = new ProjectInfoValues( $this, $subrows
);
		}
	}


$rr was being overwritten and then checked against the wrong
value.
I've tested this new code and it returns the correct records
as expected.

Thanks for the new class Bjorn!

/eclipse.org-common/classes/projects/projectInfoData.class
/eclipse.org-common/classes/projects/projectInfoList.class

The new class files above have been committed to CVS on
Phoenix.eclipse.org.

Can we get some more +1's to move this forward?

Nathan Gervais - nathaneclipse.org
Web Developer 
The Eclipse Foundation
 
 
-----Original Message-----
From: phoenix-dev-bounceseclipse.org
[mailto:phoenix-dev-bounceseclipse.org] On Behalf Of
Denis Roy
Sent: Wednesday, September 12, 2007 10:53 PM
To: For developers on the new Eclipse.org website project.
Subject: Re: [phoenix-dev] ProjectInfoAPI Documenation

You guys are brilliant.

+1 for Bjorn's code and Nathan's adaptation.


Nathan Gervais wrote:
>> I'm not suggesting we rewrite any of the code that
Denis, Karl, Matt,
>> and Nathan have already written with the other
class, but I think we
should
>> hide that other class and only expose this one to
our user population
(the
>> committers).
> 
> I don't see the point in creating two different API's
for accessing this
> data.  
> 
> I would suggest replacing the class ProjectInfo with
this new
> ProjectInfoData class, and then adapting
ProjectInfoList to use this new
> class.  This will provide the flexibility of the
SimpleXML style, while
> still allowing filtered lists of ProjectInfoData that
are required to
> produce pages such as the categories, mailinglist /
newsgroups (by topic),
> project page etc.
> 
> 
> Nathan Gervais - nathaneclipse.org
> Web Developer 
> The Eclipse Foundation
>  
>  
> 
> -----Original Message-----
> From: phoenix-dev-bounceseclipse.org
> [mailto:phoenix-dev-bounceseclipse.org] On Behalf Of
Bjorn Freeman-Benson
> Sent: Wednesday, September 12, 2007 9:16 PM
> To: karl.matthiaseclipse.org; For developers on the new
Eclipse.org
website
> project.
> Subject: Re: [phoenix-dev] ProjectInfoAPI Documenation
> 
> Karl, Nathan, Denis, Matt,
>> I didn't think you could do this in a dynamic way
(meaning you don't
>> have to track the DB schema by hand in the class'
member variables)
>> without manipulating the PHP language structs like
SimpleXML does.  
>>   
> I took up the challenge and wrote the two classes
necessary. Here's the 
> file and a demo. In the end you just write code like
this:
> 
> $info = new ProjectInfoData( 'technology.dash');
> $a = $info->pargraphurl ;
> $b = $info->descriptionurl ;
> $c = $info->bugzilla->productname ;
> $d = $info->mailinglist[0]->name ;
> $e = $info->mailinglist[0]->description ;
> 
> I'll let Denis or Karl code review my work and then
check it in the 
> appropriate place (where ever that is) and then update
that wiki page. 
> Or I can update the wiki page once you tell me where
the file is going 
> to reside.
>> I suggest that we implement the classes as they are
now--and as Nathan
>> has done a nice job of documenting--because we are
running out of time
>> to complete the page conversion before the end of
the quarter.  But I
>> think we could make a significant improvement to
usability if we built a
>> dynamic ProjectInfo class next quarter.
>>
>>   
> It's a significantly better user experience for our
committers, so I 
> suggest we roll this code out this quarter. I'm not
suggesting we 
> rewrite any of the code that Denis, Karl, Matt, and
Nathan have already 
> written with the other class, but I think we should
hide that other 
> class and only expose this one to our user population
(the committers).
> 
> - Bjorn
> 
> _______________________________________________
> phoenix-dev mailing list
> phoenix-deveclipse.org
> 
https://dev.eclipse.org/mailman/listinfo/phoenix-dev
> 

_______________________________________________
phoenix-dev mailing list
phoenix-deveclipse.org

https://dev.eclipse.org/mailman/listinfo/phoenix-dev

_______________________________________________
phoenix-dev mailing list
phoenix-deveclipse.org

https://dev.eclipse.org/mailman/listinfo/phoenix-dev

Re: ProjectInfoAPI Documenation
country flaguser name
United States
2007-09-13 16:21:20
I discovered a bit of a limitation in the class in that
things which are 
usually arrays like newsgroups or mailinglists return
non-array data 
when only one entry is present.  That requires that your
code check 
every time it gets something back to see if it's an array or
not.  So 
Bjorn came up with the idea of allowing you to request the
key as a 
plural word and always get back an array even if there is
only 1 
element.  I implemented this in the attached file.  So for
example, say 
the ECF project has only 1 mailing list.  If I said:

$x = $projectinfo->mailinglist
if(count($x) > 1) {
    ...
}

I get a fatal error on count() unless I check is_array()
every time 
first.  Then I have to have two paths everywhere in my code
where I use 
the data.  Instead with the attached version (incorporating
Nathan's 
fix) I can say:

$x = $projectinfo->mailinglists   <--------- note the
's'
if(count($x) > 1) {
   ...
}

And get no error.  And I don't have to check is_array()
every time I use 
the data nor maintain multiple paths through my code.

Also, I implemented Countable on each of the two classes
allowing you to 
say count($projectinfo) to see how many keys you got back. 
Or 
count($projectinfovalues) to see how many fields you have
for a mainkey.

Cheers,

Karl



Karl Matthias wrote:
> +1 Looks great to me.
>
> Karl
>
> Bjorn Freeman-Benson wrote:
>   
>> Nathan,
>> Thanks for the code review and fix.
>> +1
>>
>> - Bjorn
>>
>> Nathan Gervais wrote:
>>     
>>> Can we get some more +1's to move this
forward?
>>>
>>>   
>>>       
>>
------------------------------------------------------------
------------
>>
>> _______________________________________________
>> phoenix-dev mailing list
>> phoenix-deveclipse.org
>> 
https://dev.eclipse.org/mailman/listinfo/phoenix-dev
>>     
> _______________________________________________
> phoenix-dev mailing list
> phoenix-deveclipse.org
> 
https://dev.eclipse.org/mailman/listinfo/phoenix-dev
>   


_______________________________________________
phoenix-dev mailing list
phoenix-deveclipse.org

https://dev.eclipse.org/mailman/listinfo/phoenix-dev

  
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )