ianhomer / bugzillareports

This repository is deprecated - please use https://github.com/jnwatts/BugzillaReports
Apache License 2.0
0 stars 0 forks source link

closed=-1w not working in standalone mode #55

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
... taken from blog comments

Barak ->

Is “closed” supported? when trying
$out=$bugzillaReport->render(array(“columns=id,to,component,priority,severity,
status,summary”,”closed=-1w”));

I got empty page and this:

Fatal error: Call to undefined function wfLoadExtensionMessages() in
/var/www/html/BugzillaReport.php on line 184

(same qeury with “created” works well)

Ian -> 

ahh … it looks like the error message handling is not working in standalone
mode …

the following function in BugzillaReport.php :

public function getErrorMessage($key) {
$args = func_get_args();
array_shift( $args );
wfLoadExtensionMessages( ‘BugzillaReports’ );
return ‘BugzillaReports : ‘.
wfMsgForContent($key,$args).’‘;
}

wfLoadExtensionMessages is a MediaWiki function and this method really
needs a safety check in case this is run out side of MediaWiki. If you
could file a bug for this over at http://code.google.com/p/bugzillareports
that’d be helpful.

However essentially, we see the underlying error that is being masked by
this error handling issue, if you could change the getErrorMessage function
to …

public function getErrorMessage($key) {
$args = func_get_args();
array_shift( $args );
return $key.join($args);
}

and then rerun the query then this should give us a clue as to the
underlying issue

Barak ->

Running the query raised that:

SELECT DISTINCT bugs.bug_id as id, alias, closedactivity.bug_when as
closed, components.name as component, quickflag.flagdate as flagdate,
priority, bug_severity as severity, bug_status as status, short_desc as
summary, profiles.realname as assignedto FROM `bugs`.bugs LEFT JOIN
`bugs`.components on bugs.component_id=components.id LEFT JOIN (SELECT
bug_id, MAX(bug_when) as bug_when from `bugs`.bugs_activity where fieldid=
and added=’CLOSED’ GROUP BY bug_id) as closedactivity on
bugs.bug_id=closedactivity.bug_id LEFT JOIN (SELECT bug_id as
quickflagbugid, MAX(creation_date) as flagdate from `bugs`.flags where
status=’?’ group by quickflagbugid) as quickflag on
quickflag.quickflagbugid=bugs.bug_id LEFT JOIN `bugs`.profiles on
bugs.assigned_to=profiles.userid where 1=1 and closedactivity.bug_when
>=’2010-05-20′ and bug_status’CLOSED’ order by priority,bug_status ASC; 
You
have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near ‘and added=’CLOSED’
GROUP BY bug_id) as closedactivity on bugs.bug_id=closedactiv’ at line 1

Seems like no closedactivity in my bugzilla db.. :-( 

Ian -> 

Actually when reviewing the sql, seems like the problem is this:

…where fieldid= and added=’CLOSED’…

Shouldn’t it be set to 9 (bug_status)?

Barak ->

Getting this to screen:

Registering field ids : 57

And seems ok as SELECT * FROM bugs.fielddefs f; also returns 57 rows…

Thanks for helping so far, I’m not a PHP guy :-) 

Original issue reported on code.google.com by ian.homer@gmail.com on 31 May 2010 at 8:46

GoogleCodeExporter commented 8 years ago
(correction on above cut n paste)

Ian ->

Yes – that looks like the issue. These ids should have been initialised in the
function initFieldIds($db) in BugzillaQuery.php. Could you put debug logging on
(http://www.mediawiki.org/wiki/Extension:Bugzilla_Reports#Troubleshooting) and 
see if
this method is running through. You should see a log line saying “Registering 
field
ids” if it is.

Barak->

Getting this to screen:

Registering field ids : 57

And seems ok as SELECT * FROM bugs.fielddefs f; also returns 57 rows…

Thanks for helping so far, I’m not a PHP guy :-) 

Original comment by ian.homer@gmail.com on 31 May 2010 at 8:49

GoogleCodeExporter commented 8 years ago
Do you see in the log after this a list of all the fields registered, e.g. 

  Registering field id bug_status = 9

if not then perhaps it's not loading the field ids.  To help you further I 
probably
need to simulate your set up ... although I suspect this is roughly where the 
issue
may lie.

Original comment by ian.homer@gmail.com on 31 May 2010 at 9:02

GoogleCodeExporter commented 8 years ago
Barak -> Another question – why the generated SQL contains this in the where 
clause:
and bug_status’CLOSED’ ? A reminder, I’m looking for bugs closed in the 
last week.

Original comment by ian.homer@gmail.com on 31 May 2010 at 9:11

GoogleCodeExporter commented 8 years ago
That does look odd - I'd expect an "="s to be there

Original comment by ian.homer@gmail.com on 31 May 2010 at 9:12

GoogleCodeExporter commented 8 years ago
replying to comment #2 - yes, this is field is registered:

Registering field idbug_status -> 9

Original comment by barak.ya...@gmail.com on 1 Jun 2010 at 6:49

GoogleCodeExporter commented 8 years ago
OK - I think I'll need to spin up a similar set up to you and test this out.

Original comment by ian.homer@gmail.com on 1 Jun 2010 at 7:19

GoogleCodeExporter commented 8 years ago
10x - waiting... :-)

Original comment by barak.ya...@gmail.com on 1 Jun 2010 at 1:10

GoogleCodeExporter commented 8 years ago
I'm trying to debug the code - I found that in BugzillaQuery.php when coming to 
execute this code:

if ($this->isRequired("closed")) {
      $sql.=" LEFT JOIN ".
        " (SELECT bug_id, MAX(bug_when) as bug_when from ".
        $this->connector->getTable("bugs_activity").
        " where fieldid=".$this->fieldIds["bug_status"].
        " and added='CLOSED' GROUP BY bug_id) as closedactivity on 
bugs.bug_id=closedactivity.bug_id";
    }

$this->fieldIds is NULL. Can it be null if the debug mode reports that the 
fields 
got registered?

Original comment by barak.ya...@gmail.com on 3 Jun 2010 at 9:59

GoogleCodeExporter commented 8 years ago
I think issue resolved.

1. In BugzillaQuery::initFieldIds() I've substitued BugzillaQuery::$fieldIds 
with 
$this->fieldIds

2. in the query, I explicity added "status=CLOSED" (since default is !CLOSED - 
maybe 
default should considred if the user queries for closed bugs :-))

Original comment by barak.ya...@gmail.com on 3 Jun 2010 at 10:32

GoogleCodeExporter commented 8 years ago
Barak - thanks for working through this (and apologies for not being able to 
help out
more on it - been a bit hectic over the last few days).

If that does the job then, great.   I was hoping for the 
BugzillaQuery::$fieldIds to
be a static access the variables - I guess $this->fieldIds accesses the static
variable as well, but puzzled as to why the static access didn't work, 
especially
since we set the variables with  
BugzillaQuery::$fieldIds[$line["name"]]=$line["id"];

On point 2 - absolutely the default !CLOSED shouldn't be set if the user 
queries for
closed bugs.

Original comment by ian.homer@gmail.com on 4 Jun 2010 at 7:25