Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
https://api.drupal.org/api/drupal/core%21modules%21node%21node.install/f...
The column description says it is used for boolean values. That means we should add 'size' => 'tiny' for this column as it is already done for other boolean columns in the table.
\Drupal\node\NodeGrantDatabaseStorage::write() shows that the value can only be 0 or 1:
// The record with the original langcode is used as the fallback.
if ($grant['langcode'] == $node->language()->getId()) {
$grant['fallback'] = 1;
}
else {
$grant['fallback'] = 0;
}
Comment | File | Size | Author |
---|---|---|---|
#15 | Selection_003.png | 13.61 KB | quietone |
#15 | Selection_004.png | 5.97 KB | quietone |
#14 | 2613190-14-specify_node_access_fallback_column_size.patch | 1.3 KB | fenstrat |
Comments
Comment #2
LOBsTerr CreditAttribution: LOBsTerr as a volunteer commentedComment #3
LOBsTerr CreditAttribution: LOBsTerr as a volunteer commentedComment #4
LOBsTerr CreditAttribution: LOBsTerr as a volunteer commentedComment #5
nicrodgersThe patch looks ok to me - it makes it consistent with the other boolean fields, so nice spot! However, because it's a change to the schema, it needs a corresponding hook_update_N function to update the size for existing installations.
Comment #6
LOBsTerr CreditAttribution: LOBsTerr as a volunteer commentedComment #7
LOBsTerr CreditAttribution: LOBsTerr as a volunteer commentedI have added the update hook. I'm not good in commenting and documenting. Let me know if it is should be updated.
Comment #8
LOBsTerr CreditAttribution: LOBsTerr as a volunteer commentedComment #9
LOBsTerr CreditAttribution: LOBsTerr as a volunteer commentedComment #12
fenstratHere's a minor modification to #7, inspired by history_update_8101() which uses Database::getConnection()->schema->changeField() rather than db_query().
Comment #14
fenstrat#12 was missing a
use
statement.Comment #15
quietone CreditAttribution: quietone as a volunteer commented@LOBsTerr, thanks for finding this and making a patch. At DrupalSouth 2016, fenstrat did a great job at demonstrating how to review this issue. That resulted in a new patch which I've just tested.
Tested the patch on a freshly installed Drupal 8 and it works.
Here is node_acces before the patch, note that fallback is an int(10).
After applying the patch the status report correctly showed that 'Database updates' was out of date. And then running update.php the update was found and ran successfully.
Here is node_access after the patch and fallback is not a tinyint.
And some relevant screen shots:
Comment #16
alexpottUpdating IS to show that this is a safe change.
Committed 64c4d8e and pushed to 8.3.x. Thanks!
Fixed the update number of commit.