No serials generated for existing content nor for new, silently failing

Created on 22 January 2025, 2 months ago

Problem/Motivation

When i add a serial field, i expect it to work or provide an error indicating why it is not working.

Steps to reproduce

Added serial field to a couple existing content types, in both cases quite complexโ€” i wasted quite a bit of time checking the output to see if we were simply not displaying the serial field, before figuring out that serial values were not being created at all.

Leave the starting value as 1.

Select the 'Start on existing entities' option.

Create a few new pieces of content.

All the tables created show no results, for example: SELECT * FROM serial_d00042505c0eee5abb9539219c50bdf1; and SELECT * FROM node__field_shortcode; both return "Empty set (0.000 sec)"

No errors shown to the user, and no errors in the log.

Proposed resolution

Maybe complete the refactor proposed in ๐Ÿ› Serial not generating on entity save in certain contexts Needs work first?

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States mlncn Minneapolis, MN, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mlncn
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mlncn Minneapolis, MN, USA

    Possibly the behavior i documented only occurs when using Drupal's "Re-use field" feature.

    Trying again with the patch from ๐Ÿ“Œ Remove uniqid field from serial storage table RTBC , and only putting the field on one content type (also using the field name `serial`, and also the phase of the moon was different, i don't know) new content did receive new serial numbers, but existing content did notโ€” the "Start on existing entities" option continued to do nothing at all (is open D7 bug #2906190: No data created to existing nodes โ†’ in fact also current for D8/2.x?), but far worse when i edited content it all got the serial ID of "1". And then after creating a piece of content (entity_id 748320 in the table below) and seeing it go to two, i thought it would at least work for new content, but then the second new piece of content i created (id 748321) went to one!! (All other content IDs are existing, edited content.)

    MariaDB [db]> SELECT * FROM node__field_serial;
    +---------+---------+-----------+-------------+----------+-------+--------------------+
    | bundle  | deleted | entity_id | revision_id | langcode | delta | field_serial_value |
    +---------+---------+-----------+-------------+----------+-------+--------------------+
    | program |       0 |       533 |     1463984 | und      |     0 |                  1 |
    | program |       0 |      1790 |     1463983 | und      |     0 |                  1 |
    | program |       0 |    744127 |     1463982 | und      |     0 |                  1 |
    | program |       0 |    748320 |     1463986 | en       |     0 |                  2 |
    | program |       0 |    748321 |     1463987 | en       |     0 |                  1 |
    +---------+---------+-----------+-------------+----------+-------+--------------------+
    
    MariaDB [db]> SELECT * FROM serial_16086b691b7fb65de27d49516009e1ca;
    +-----+
    | sid |
    +-----+
    |   1 |
    +-----+
    

    This is a module with a lot of use but i wonder if those using it successfully are only when it is installed on a completely new site, possibly also starting with an older codebase that set things up better?

    There are so many major issues still open (at least i'm not hitting #3076002: Serial ID doesn't start from 1 in a new content โ†’ ) that i don't know where to start with fixing.

    I would encourage the maintainers to start a new branch with ๐Ÿ“Œ Remove uniqid field from serial storage table RTBC and maybe some other straightforward improvements/fixes/simplifications as the start and then maybe the community can iterate fixes on that, starting with ๐Ÿ› Serial not generating on entity save in certain contexts Needs work , but as of nowโ€” for myself i'm regretfully falling back to custom code.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mlncn Minneapolis, MN, USA

    All right, tried one more time with no patches (same as to start) and now all new content gets the correct serial, while edited content gets a one.

    Then tried re-using the field on another content type, and that worked the sameโ€” new content gets an independent, correct in serial number, and edited content gets a one.

    Sorry for mucking up the issue queue but i still don't know what's going on here and don't know what i can trust :-(

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mlncn Minneapolis, MN, USA

    Well, using the issue fork from ๐Ÿ“Œ Remove uniqid field from serial storage table RTBC

    And it is still a complete disaster. No serial IDs created retroactively. Only doing this on one content type for now.

    MariaDB [db]> SELECT * FROM serial_0420c62dd723430557835bf4ac5a5493;
    Empty set (0.000 sec)
    
    MariaDB [db]> SELECT * FROM node__field_serial;
    Empty set (0.000 sec)
    

    After editing one piece of content:

    MariaDB [db]> SELECT * FROM node__field_serial;
    +------------+---------+-----------+-------------+----------+-------+--------------------+
    | bundle     | deleted | entity_id | revision_id | langcode | delta | field_serial_value |
    +------------+---------+-----------+-------------+----------+-------+--------------------+
    | individual |       0 |    693010 |     1464063 | und      |     0 |                  1 |
    +------------+---------+-----------+-------------+----------+-------+--------------------+
    1 row in set (0.000 sec)
    
    MariaDB [db]> SELECT * FROM serial_0420c62dd723430557835bf4ac5a5493;
    Empty set (0.001 sec)
    

    And then after creating one piece of content:

    MariaDB [db]> SELECT * FROM node__field_serial;
    +------------+---------+-----------+-------------+----------+-------+--------------------+
    | bundle     | deleted | entity_id | revision_id | langcode | delta | field_serial_value |
    +------------+---------+-----------+-------------+----------+-------+--------------------+
    | individual |       0 |    693010 |     1464063 | und      |     0 |                  1 |
    | individual |       0 |    748330 |     1464064 | en       |     0 |                  1 |
    +------------+---------+-----------+-------------+----------+-------+--------------------+
    2 rows in set (0.000 sec)
    
    MariaDB [db]> SELECT * FROM serial_0420c62dd723430557835bf4ac5a5493;
    +-----+
    | sid |
    +-----+
    |   1 |
    +-----+
    1 row in set (0.000 sec)
    
Production build 0.71.5 2024