If I want to get a list of non-deleted platforms, I can use _hosting_get_platforms().
If I want to get a list of non-disabled platforms, I can use _hosting_get_enabled_platforms().

What if I want to get a list of non-deleted non-disabled platforms?

Then I have to use:
array_intersect(_hosting_get_enabled_platforms(), _hosting_get_platforms())
which is somewhat weird.

Why don't we just add an enabled_only flag to _hosting_get_platforms(), and deprecate _hosting_get_enabled_platforms()?

_hosting_get_enabled_platforms() currently crashes PDO anyway as its "h.blah" parameter names aren't valid.

I'll have a patch for this in a minute.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

colan created an issue. See original summary.

colan’s picture

Status: Active » Needs review
FileSize
2.95 KB

Here it is.

gboudrias’s picture

So you're saying _hosting_get_enabled_platforms() doesn't work at all? We should probably remove it altogether then, if one could have been using it.

I haven't tested the patch yet but it looks good.

colan’s picture

I don't know if it works for anyone else, but when I use it, I get:

PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined: SELECT n.nid, n.title FROM {node} n LEFT JOIN {hosting_platform} h ON n.nid = h.nid WHERE n.type = :n.type AND n.status = :n.status AND h.status <> :h.status ORDER BY n.title ; Array ( [:n.type] => platform [:n.status] => 1 [:h.status] => -1 ) in _hosting_get_enabled_platforms() (line 269 of /var/aegir/hostmaster-7.x-3.4/profiles/hostmaster/modules/aegir/hosting/platform/hosting_platform.module).

If I remove all of the dots from the parameters, then it works. This is already done in _hosting_get_platforms().

Besides some core use (which we could fix ourselves), there could be contribs out there using it that aren't running into this issue. So I'd feel more comfortable:

  1. Simply deprecating it in 3.x to not break the API (the patch above), and
  2. Removing it entirely (and updating core callers) in a separate 4.x issue (not created yet).

  • gboudrias committed 28f1a60 on 7.x-3.x authored by colan
    Issue #2721949 by colan: Deprecate _hosting_get_enabled_platforms()
    
gboudrias’s picture

Status: Needs review » Fixed

Okay, since we're not removing anything there's no big risk.

I tested the patch on my dev server.

colan’s picture

Thanks. 4.x issue created over at #2722641: Remove _hosting_get_enabled_platforms().

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.