Closed (fixed)
Project:
Permissions by Term
Version:
8.x-1.51
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Apr 2018 at 22:19 UTC
Updated:
5 May 2018 at 03:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jepster_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?
Comment #3
P44T commentedI'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.
Comment #4
Andrzej7 commentedHave the same error
Comment #5
mediabounds commentedI 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();
Comment #6
P44T commentedWell found. That's a problem, yes.
Comment #7
Gamewalker commentedWorking fine with colon, thanks
Comment #9
jepster_@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.
Comment #10
jepster_Comment #11
mpp commented@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.
Comment #12
jepster_Comment #13
chrotto commentedHave the same error on my site with only Swedish language and with Version: 8.x-1.49.
Comment #14
MajoMM commentedThe problem occurs if the permissions_by_term_role table is missing the record in the langcode column.
Comment #15
chrotto commentedSo 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.
Comment #16
JR Tera3yte commentedI'm also having problems with this update:
Comment #17
kb_klash commentedI am getting this error when doing the latest update.
Comment #18
jepster_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:
To re-run the database updates, execute
drush ev "\Drupal::keyValue('system.schema')->set('permissions_by_term', (int) 8144)";Afterwards run
drush updbThen 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):
Comment #20
jepster_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.
Comment #21
jepster_Comment #22
geYdes commentedHi,
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).Comment #23
bloomt commentedSame please assist
Comment #24
bloomt commentedI 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]
Comment #25
jepster_@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".
Comment #26
jepster_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".
Comment #27
jepster_Comment #28
kb_klash commentedI was still having issues after the update that looked like this:
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!
Comment #29
mediabounds commentedThis 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. Removingexecute()resolves the error and the tables are all still updated correctly.Comment #30
Andrzej7 commentedAfter updating:
Comment #31
jepster_@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.
Comment #32
Andrzej7 commented1.52 works well for me.
Thank you for your work.
:-)
Comment #33
jepster_@Andrzej7: Nareszcie. :-)
Comment #34
Andrzej7 commentedPiotrek (Peter in polish)
dzięki :-)