I was working on #165380 trying to use project_build_query() rather than adding a new query builder function. I think it'd be much more usable if there was a function to build you an empty query array.

This also adds some PHPDocs.

Comments

aclight’s picture

You've got a minor typo in one of the comments (each is there twice):

+ *   Each each value is an array with the following keys:
nedjo’s picture

+1, looks good.

drewish’s picture

StatusFileSize
new4.54 KB

this fixes the comment issue aclight noticed.

my only question is, is project_empty_query() the best name? perhaps project_build_empty_query() or project_get_empty_query()?

hunmonk’s picture

the abstraction seems like a decent idea -- however, given that we're going to move to using views, and this code is most likely going to be ripped out anyways, what is this really buying us in the near term? if it's just a few saved lines of code, i'm not sure i'm convinced.

drewish’s picture

the views migration is going to be a huge amount of work and probably end up being a separate branch. i don't want to call it vapor ware, but until someone's actually working on it i don't think it should be a reason not to make improvements in the current code. the reason for this change is so that i can re-use the code in project_usage. if we don't add this then i end up copying that block of code and pasting it into project_usage.

hunmonk’s picture

true, but your pasted block will get ripped out with all of other other project* query building crap when views lands, so i don't see it as that big of a deal -- i'd prefer that instead of creating more code divergence amongst the project* branches.

dww will have to weigh in for us to reach a final decision here.

drewish’s picture

so now that dww's back maybe we can get him to weigh in on this...

dww’s picture

Status: Needs review » Fixed

Views support isn't exactly vaporware (I do have a project_issue_views.inc started somewhere), but I agree in reality, it's at least weeks, if not months away from being done and installed on d.o. So, while I don't want to invest a bunch of effort into this query building code in general, I'm happy to see small, incremental improvements like this, especially if it reduces code duplication. Therefore, I committed patch from #3 to HEAD after a review and moderate testing on a local site. Sorry for the delay.

drewish’s picture

thanks dww, it's good to have you back.

Anonymous’s picture

Status: Fixed » Closed (fixed)