Hello,

if I try to update drupal to newest version and run update.php, I get the following error:

PDOException: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in permissions_by_term_update_8147() (Zeile 141 in httpdocs/web/modules/contrib/permissions_by_term/permissions_by_term.install).

CommentFileSizeAuthor
#29 Update-failure-2964781-29.patch1.47 KBmediabounds

Comments

Gamewalker created an issue. See original summary.

jepster_’s picture

Status: Active » Postponed (maintainer needs more info)

Hello :)

Which languages have you configured on your site? Are you using the content translation module? Do you have taxonomy terms entered on your site?

P44T’s picture

Status: Postponed (maintainer needs more info) » Active

I'm seeing this too. Database update 8147 keeps failing. In my case, I've configured Dutch as the single language, so I'm not translating nodes/entities. I do have a taxonomy vocabulary with some (< 10) terms to restrict access with.

Andrzej7’s picture

Have the same error

mediabounds’s picture

I am seeing the same issue--these are the languages I have enabled on my site:
English
French
Spanish
Russian
Thai
Bahasa Malaysia
German
Turkish
Arabic
Polish
Chinese, Simplified
Vietnamese

I _think_ the issue is that the placeholders in the query should be prefixed with a colon.

e.g. $database->query("UPDATE {permissions_by_term_role} SET langcode = :langcode WHERE tid = :tid", [':langcode' => $termLangcode, ':tid' => $roleTerm->tid])->execute();

P44T’s picture

I _think_ the issue is that the placeholders in the query should be prefixed with a colon.

Well found. That's a problem, yes.

Gamewalker’s picture

Working fine with colon, thanks

  • Peter Majmesku committed fd52559 on 8.x-1.x
    Issue #2964781: Invalid parameter number after update. Added colon to...
jepster_’s picture

Status: Active » Fixed

@mediabounds: Thanks for the hint! I have changed the update hook and added the missing colon.

Has been released in version 8.x-1.49. See https://www.drupal.org/project/permissions_by_term/releases/8.x-1.49.

jepster_’s picture

Status: Fixed » Closed (fixed)
mpp’s picture

@Peter Majmesku, thanks for the update but this issue needs work. I still encountered the error "Invalid parameter number: no parameters were bound in " with 8.x-1.49.

The problem occurs when you have a taxonomy that is not set to be translatable. In my case I could fix this error by making the taxonomy translatable but it's a valid case for some vocabularies not to have translations.

jepster_’s picture

Status: Closed (fixed) » Needs work
chrotto’s picture

Have the same error on my site with only Swedish language and with Version: 8.x-1.49.

MajoMM’s picture

The problem occurs if the permissions_by_term_role table is missing the record in the langcode column.

chrotto’s picture

So I can just ignore this error when not using multilingual sites?
I do not get any error messages when using the module an chang term permissions.

JR Tera3yte’s picture

I'm also having problems with this update:

 [error]  Error: Call to a member function get() on null in permissions_by_term_update_8147() (line 140 of /home/user/Projekte/php/project/web/modules/contrib/permissions_by_term/permissions_by_term.install) #0 /home/user/Projekte/php/project/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(185): permissions_by_term_update_8147(Array)
kb_klash’s picture

I am getting this error when doing the latest update.

jepster_’s picture

Status: Needs work » Postponed (maintainer needs more info)

MajoMM wrote:
The problem occurs if the permissions_by_term_role table is missing the record in the langcode column.

Please make sure, that you have applied the update from version 8.x-1.45. It's update hook is adding the langcode fields to PbT's database tables:

/**
 * Add field for langcode in user and role permission tables.
 */
function permissions_by_term_update_8145() {
  $database = \Drupal::database();
  $schema = $database->schema();

  $spec = [
    'type'     => 'varchar_ascii',
    'length'   => 12,
    'not null' => TRUE,
    'default'  => '',
  ];
  $schema->addField('permissions_by_term_role', 'langcode', $spec);
  $schema->addField('permissions_by_term_user', 'langcode', $spec);
}

To re-run the database updates, execute

drush ev "\Drupal::keyValue('system.schema')->set('permissions_by_term', (int) 8144)";

Afterwards run

drush updb

Then the database update from 8.x-1.47 should be good. I was testing this approach a few times (with and without multiple languages configured and with/without the language+content translation modules) and it worked.

Let me know, if this helps. If this does not help: please (!!!) set me a screenshot or a select result from the following database tables (before the update):

permissions_by_term_role
permissions_by_term_user

  • Peter Majmesku committed 3aeb208 on 8.x-1.x
    Issue #2964781 by Peter Majmesku: Cleanup dangling datasets, with no...
  • Peter Majmesku committed 4705acb on 8.x-1.x
    Issue #2964781 by Peter Majmesku: Update language code in PbT tables...
jepster_’s picture

Status: Postponed (maintainer needs more info) » Fixed

I think I have found the fix. There has been issue #2947315 Delete access storage when a term is deleted. Before this fix, PbT's datasets have been not deleted on taxonomy term deletion. Unfortunately there has been no cleanup update-hook, which would delete dangling datasets.

In release 8.x-1.50 PbT will only update language codes for existing taxonomy terms. Also datasets with no taxonomy term relation will be cleaned up.

Please run the database updates via "drush updb" or Drupal's update.php file to run the new update hook.

Feel free to re-open this issue, if you have any objections.

jepster_’s picture

Status: Fixed » Closed (fixed)
geYdes’s picture

Hi,

In my case the error still happens after updating to release 8.x-1.50.

Error: PDOException: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound en permissions_by_term_update_8150() (line 149 de /var/www/vhosts/webexample.es/httpdocs/webexample/web/modules/contrib/permissions_by_term/permissions_by_term.install).

bloomt’s picture

Same please assist

bloomt’s picture

I get this from update.php
permissions_by_term module
Update #8145
Failed: Drupal\Core\Database\SchemaObjectExistsException: Cannot add field permissions_by_term_role.langcode: field already exists. in Drupal\Core\Database\Driver\mysql\Schema->addField() (line 407 of /var/www/vhosts/cdlandtrust.org/httpdocs/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php).

and this from drush updb
Cannot add field permissions_by_term_role.langcode: field already exists. [error]
Performing permissions_by_term_update_8145 [ok]
Cache rebuild complete. [ok]
Failed: Cannot add field permissions_by_term_role.langcode: field already exists. [error]

jepster_’s picture

@bloomt: You must set the PbT version to the previous one. Because you already have the langcode fields:

drush ev "\Drupal::keyValue('system.schema')->set('permissions_by_term', (int) 8149)";

@geYdes:
It looks like your taxonomy terms do not have any language code. I am wondering, because they do have - even the language module is disabled.

There are two possible ways now.

1.,

You could bypass the update hook via executing

drush ev "\Drupal::keyValue('system.schema')->set('permissions_by_term', (int) 8150)";

and set the langcode column value in the 2 PbT database tables to "en", if your default langcode is "en" (database table names: permissions_by_term_role and permissions_by_term_user).

This way you are setting the default langcode by yourself. However, that way the update hook is not removing dangling datasets, which are not in relation with taxonomy terms. So I am suggesting the way below.

2.,

The alternative is: you open the update hook for version 8.x-1.50 in the permissions_by_term.info file in a text editor or ide. Check function permissions_by_term_update_8150(). Set the value for "langcode" to your fixed default one in both update database queries. Let's say "en" for "english", if english is the language of your Drupal site.

That would be the better way, because PbT would remove the dangling datasets for you via the both delete queries in this update hook.

Do not forget to jump back to the previous version, before you want to run the update hook again:

drush ev "\Drupal::keyValue('system.schema')->set('permissions_by_term', (int) 8149)";

This command will finally allow you, to execute "drush updb".

jepster_’s picture

Please update to 8.x-1.51. I have added an if-case for existing term langcode to the update hook. See https://www.drupal.org/project/permissions_by_term/releases/8.x-1.51. The modified update hook will save you the manual steps from above. Just run e.g. "drush updb".

jepster_’s picture

kb_klash’s picture

I was still having issues after the update that looked like this:

SQLSTATE[HY093]: Invalid parameter number: no parameters were bound                        [error]
Performing permissions_by_term_update_8151                                                 [ok]
Failed: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound                [error]
Cache rebuild complete.                                                                    [ok]
Finished performing updates.                                                               [ok]

However I ended up running the following query directly:

UPDATE permissions_by_term_role SET langcode = 'en';

That probably won't solve everyone's problems, but if you're only dealing with English it works. Afterwards I was able to run "drush updatedb" and it was able to perform the update.

Thanks for the work on this, man!

mediabounds’s picture

StatusFileSize
new1.47 KB

This issue still exists in 8.x-1.51 -- the issue now is that the update is attempting to call execute() on a static query, but that's not necessary. Removing execute() resolves the error and the tables are all still updated correctly.

Andrzej7’s picture

Version: 8.x-1.48 » 8.x-1.51

After updating:

permissions_by_term module
Update #8151
Failed: PDOException: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in permissions_by_term_update_8151() (line 146 of /.../modules/permissions_by_term/permissions_by_term.install).
jepster_’s picture

@mediabounds: Thanks again for your useful objection! I have patched the update hook for patch release 8.x-1.52 once again. The execute() method has not been necessary. I have tested it. Even if I could not reproduce any error with MySQL and SQLite on PHP 7.1. See https://www.drupal.org/project/permissions_by_term/releases/8.x-1.52.

Andrzej7’s picture

1.52 works well for me.
Thank you for your work.
:-)

jepster_’s picture

@Andrzej7: Nareszcie. :-)

Andrzej7’s picture

Piotrek (Peter in polish)
dzięki :-)