As stated in the subject, here the complete error:

PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined: INSERT INTO acl_node (nid, acl_id, grant_view, grant_update, grant_delete, priority) SELECT n.nid AS nid, 18 AS acl_id, 1 AS grant_view, 1 AS grant_update, 1 AS grant_delete, 0 AS priority FROM taxonomy_index n WHERE (n.tid = :db_condition_placeholder_1) ; Array ( ) in acl_add_nodes() (line 115 of /public_html/sites/all/modules/acl/acl.module).

Any way to quick fix this?

Comments

Soraph’s picture

Title: PDO errore on forum administration interface first access » PDO error on forum administration interface first access
salvis’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

I cannot reproduce this problem.

What is the module that requires ACL on your site? What exactly are you doing that produces this error?

Soraph’s picture

form_access call ACL, when I create a new forum and I go to the administration interface to modify something, I get the error I mentioned before.

Soraph’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.29 KB

I've made a patch to fix the error, can you please check it?

Status: Needs review » Needs work

The last submitted patch, pdoerror-1815158.patch, failed testing.

Soraph’s picture

Status: Needs work » Needs review

#4: pdoerror-1815158.patch queued for re-testing.

Soraph’s picture

miss clicked, damn me.

Anyway, there are no tests defined

Status: Needs review » Needs work

The last submitted patch, pdoerror-1815158.patch, failed testing.

salvis’s picture

What database are you using?

We have thousands of sites that are running the FA+ACL combo without any problems...

Soraph’s picture

PostgreSQL

salvis’s picture

Title: PDO error on forum administration interface first access » PostgreSQL: PDO error on forum administration interface first access

Ah, that explains it...

Is it pgsql blowing up if the $subselect returns an empty set?

No, we won't turn one query into two to accommodate pgsql's quirks. What we can do is special-case pgsql and count the records, and skip the existing query if there's none.

Soraph’s picture

PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined: INSERT INTO acl_node (nid, acl_id, grant_view, grant_update, grant_delete, priority) SELECT n.nid AS nid, 18 AS acl_id, 1 AS grant_view, 1 AS grant_update, 1 AS grant_delete, 0 AS priority FROM taxonomy_index n WHERE (n.tid = :db_condition_placeholder_1) ; Array ( ) in acl_add_nodes() (line 115 of /public_html/sites/all/modules/acl/acl.module).

From here, the query doesn't even reach the database layer, is the PDO stopping the action as the tid parameter is lost when the query is constructed.

How can this be related to postgreSQL?

salvis’s picture

As I wrote above: We have thousands of sites that are running the FA+ACL combo without any problems...

Your site is the only one that has this problem, and I attribute it to pgsql. pgsql will give you headaches wherever you go in the Drupal world...

From here, the query doesn't even reach the database layer, is the PDO stopping the action as the tid parameter is lost when the query is constructed.

My interpretation of the error message is that the database is complaining that the result of the subselect is empty ("Array( )"). I don't see any other "parameter number" that could be "invalid".

What do you mean with "the tid parameter is lost"?

BTW, there certainly are tests, the testbot must have had a bad day.

salvis’s picture

Status: Needs work » Needs review

#4: pdoerror-1815158.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, pdoerror-1815158.patch, failed testing.

salvis’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Needs work » Needs review

Always use HEAD...

salvis’s picture

#4: pdoerror-1815158.patch queued for re-testing.

salvis’s picture

salvis’s picture

Issue tags: +PostgreSQL

 

dmitriy.trt’s picture

Title: PostgreSQL: PDO error on forum administration interface first access » PostgreSQL & MS SQL Server: PDO error on forum administration interface first access

Same problem on MS SQL Server.

simon_w108’s picture

same problem here on PostgreSQL

salvis’s picture

See #11 — we need a patch that does not punish MySQL and does not risk retrieving and feeding back a huge number of nids.

ccoppen’s picture

I was able to at least successfully apply the patch in #4, as I too am using Postgresql with the access_forum module.

As for this working with other DB's, it's not an issue of taking into account other DB's idiosyncrosies, but doing proper testing and coding to make sure that your module isn't going to break because someone's not using the most popular DB. Drupal supports several DB's and therefore the modules should be properly coded and tested to work with those. If a module developer doesn't want to take that extra step, then they should state so in their description, not take someone to task for using a less popular DB.

skrrp’s picture

Issue summary: View changes
StatusFileSize
new1.44 KB

I hit this exact same issue on a new build using Postgres. As people have said, the patch in #4 works.

I've come up with a change to it that will hopefully limit the number of nids coming back from the database. I think it is easier this way than to try to sniff all the possible database types from $database.

I'd also like to echo the sentiments of #23, an open source developer should help the community have choice in the stack they run on rather than just blame the stack if it is not the majority choice.

salvis’s picture

doing proper testing and coding

It's easy to say what others should do, especially when you don't pay for their work. I'm not "taking anyone to task for using a less popular DB." PostgreSQL is a marginal database in the Drupal world. If YOU choose to use it, then YOU have to provide for testing and coding, unless someone else happens to do it for you. In the case at hand, no one has done it yet, so...

We have 5 people in this thread with this issue, compared to 20'000 known sites apparently running ACL without this problem, 13'000 under D7. The time wasted to discuss who should do what already far outweighs your fair share of the maintenance effort.

The patch in #24 changes the behavior of the function for 13'000 sites, IOW you're potentially breaking 13'000 sites in your attempt to fix a problem on 5 sites!

The first step towards a solution is to analyze the problem. So far no one has cared to find out and explain what exactly pgsql is complaining about...

pierce’s picture

make that 6 people. just ran into the same problem.

have these patches been integrated into the -dev version?

re: PostgreSQL, my drupal 7.latest-on-postgresql site has dozens and dozens of modules and they all work just fine. I just added ACL so I could use forum_access, now noone can post to the advanced forum.

again, the error appears to be in the PDO layer

PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined: INSERT INTO acl_node (nid, acl_id, grant_view, grant_update, grant_delete, priority) SELECT n.nid AS nid, 4 AS acl_id, 1 AS grant_view, 1 AS grant_update, 1 AS grant_delete, 0 AS priority FROM taxonomy_index n WHERE (n.tid = :db_condition_placeholder_1) ; Array ( ) in acl_add_nodes() (line 115 of /home/observers/drupal-7.28/sites/all/modules/acl/acl.module).

Thats being thrown from this code, but I don't understand this php/drupal abstraction stuff, there's no SQL there.

function acl_add_nodes($subselect, $acl_id, $view, $update, $delete, $priority = 0) {
  db_delete('acl_node')
    ->condition('acl_id', $acl_id)
    ->condition('nid', $subselect, 'IN')
    ->execute();
  $subselect->addExpression($acl_id, 'acl_id');
  $subselect->addExpression((int) $view, 'grant_view');
  $subselect->addExpression((int) $update, 'grant_update');
  $subselect->addExpression((int) $delete, 'grant_delete');
  $subselect->addExpression($priority, 'priority');
  db_insert('acl_node')
    ->from($subselect)
    ->execute();
}

If you can't fix this, please post in big giant letters on your ACL home page that THIS MODULE IS MYSQL ONLY.

salvis’s picture

I outlined the type of patch that I'd accept in #11, #18, and #22. The code for MySQL must not change.

I'm not saying that I can't fix this, but that I'm waiting for a viable patch plus reviewing/testing from the pgsql subcommunity...

salvis’s picture

Still no one who is willing to find out what pgsql is really complaining about and to provide a patch that keeps MySQL safe?

salvis’s picture

Status: Needs work » Needs review
StatusFileSize
new719 bytes

This might work...

  • salvis committed 262693c on 7.x-1.x
    Issue #1815158 by salvis: Fix PDO error under PostgreSQL...
salvis’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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