# Summary

This module provides an auto-increment (serial) field.

# Project URL

https://www.drupal.org/project/serial

# Where is the code?

https://www.drupal.org/project/serial/git-instructions

# Estimated completion date

First dev release on September 2016

# Dependencies

Unknown

# Who's doing the port?

colorfield

# What help do they need?

Unknown

# D8 roadmap

A MVP has been ported, but there are still opened issues.

# Background and reference information

Unknown

CommentFileSizeAuthor
#13 integer-token.png11.58 KBcolorfield

Comments

colorfield created an issue. See original summary.

alarez’s picture

Hello.

If you need help with porting this module our company developers would be happy to help.

thanks.

colorfield’s picture

Issue summary: View changes

Howdy
Thanks, help is greatly appreciated. Just back from a few weeks off, I will continue the work + keep you posted about the progress.

alarez’s picture

Sounds Good. Thank you for replying.

matsbla’s picture

Any progress on this?
If not I might try find development for it myself.

matsbla’s picture

colorfield’s picture

Thanks for the feedback. Some coding standards sounds unclear to me, I tend to follow PSR-2 but PHP const are still uppercase in the Drupal CS. Anyway, I propose to use Coder once done.

I took some time documenting on this issue, without finding a better way, so I will still continue on the current naming convention.
Any thoughts on this ?

colorfield’s picture

Had some time to go on today and ended up on a first working version, still non atomic yet.
Main issues left

They should be closed before the end of September, right in time ; )

colan’s picture

@colorfield: Thanks for all of your work on this! Is #2455677: Getting Duplicate numbers and gaps in the sequence order included, or do we need to forward port it?

matsbla’s picture

Thank you! I made a quick test now together with pathauto.
Seems like it the paths patterns using the serial field is not working when translating the nodes!
Not sure if that is covered by any of the remaining issues?

colorfield’s picture

@colan I will take some time to update what I missed from the 7.x issue tracker + let you know.

@matsbla thanks for testing, I can reproduce this and after a quick check I see 3 possibly related issues here, I will look into this

  1. The Manage display form (e.g. admin/structure/types/manage/article/display) throws "Drupal\Component\Plugin\Exception\PluginException: The plugin (integer) did not specify an instance class. in Drupal\Component\Plugin\Factory\DefaultFactory::getPluginClass() (line 79 of /var/www/drupal82/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php)." Issue on github Fixed
  2. Pathauto and visibility : Pathauto aliases will not work if Serial field is hidden, to be verified in D8.
  3. Todo left in the SerialItem class. Currently, dependending on the content translation configuration you follow (create serial field then install Content translation module), you have to uncheck translation for the serial field in admin/config/regional/content-language (or e.g. admin/structure/types/manage/article/fields/node.article.field_serial) which is probably unfair because in most use cases, the serial id should follow the entity translation concept where node id's are the same, unlike i18n in D7 (see related issue Sync Serial Field with translated nodes). Issue on github
matsbla’s picture

Thank you!

I have 2 other comments/feedbacks:

  1. When I create a new serial field it asks me for number of allowed values. I guess it should only be possible to have 1 value for the field? And I guess the field always needs to be required?
  2. When I create a serial field it seems like there are 2 tokens that are exposed: [node:field_serial] + [node:field_serial:value], both of them give the serial value. Are there any difference or is maybe one of them is redundant?
colorfield’s picture

StatusFileSize
new11.58 KB

@matsbla

  1. 1. I have already opened a question for this on github https://github.com/r-daneelolivaw/serial/issues/9, so I think we agree. It is designed as is in D7, but if we do not conflict with other cases / issues (e.g. #2383301: Make serial IDs optional, #2742255: "Field XY is required" error when creating new node) I suggest we open a new issue for this when the 8.x branch is available on DO.
  2. 2. This is the way token exposes values for integer (see example for a plain int field), no idea if we can override this, indeed would be more site builder friendly. @all any feedback?

colorfield’s picture

@colan the module has been ported with this issue patch #2455677: Getting Duplicate numbers and gaps in the sequence order included (#9) + I just did a manual check from the latest codebase

colan’s picture

@colorfield: Okay, great. Let's start forward-porting any new commits until you're got a release. I'm not expecting much traffic here (if any) as this module has been having very low activity commit-wise.

colorfield’s picture

@matsbla the pathauto issue with content translation installed should be fixed now.

It seems that the expected behavior of serial amongst entity translations is the same serial id (see #888850: Sync Serial Field with translated nodes + comment #11 3.) which is currently the case in the module port: the site builder decides that he wants a new serial for each translation via "Users may translate this field" option, but is it clear enough?

colan’s picture

I think that's sufficient for now. Folks can open other issues later if things aren't clear.

matsbla’s picture

I tested now, looks great! (y)

I really like the flexible aproach to make the Serial Field translatable to give each translation different Serial number. However, to me it seems a little bit strange that I have to make it translatable in the configuration settings.. Normally when I will make a Field translatable I simply do this within the Field settings, right?

  1. I think we should create an issue to only allow 1 value, I can't think of any cases where several values should be allowed, to me this is a confusing Field setting alternative
  2. I also think the field should be requiered as the Field is not even exposed in the form and it is inviked automatically. At least until someone can give a convinvcing use case where the Field is not requiered,

If we can get a D8 branch at the module Project page I can create the issues and we can discuss them further there.

matsbla’s picture

Are all these issues still valid?
https://github.com/r-daneelolivaw/serial/issues

colorfield’s picture

Both options for defining field translation are available
- field level (e.g. admin/structure/types/manage/article/fields/node.article.field_serial)
- global content language and translation level (admin/config/regional/content-language)
these are the default ones for field translation, so should be ok.

+1 for creating separated issues about non blocking things, one topic at a time.

Some remaining issues are about code polishing, the blockers are still

I'm on it and will keep you posted.

colorfield’s picture

Howdy,

We are not so far from a release, the main remaining issues were fixed, leaving coding standards, Node clone support and a bit of refactoring.

A bit stuck with bundle renaming: is it still available under Drupal 8?
I cannot find traces from hook_field_attach_rename_bundle, hook_entity_bundle_rename anymore and the UI does not seem to expose bundle renaming.
If we look at the Drupal\Core\Entity\Entity class, the setOriginalId method specifies :

By default, entities do not support renames and do not have original IDs.

I cannot find traces of rename in the subclasses of Entity either and the entity.api.php mentions

These machine names are considered permanent, they may not be renamed.

Am I missing something or can we consider that we can get rid of bundle renaming?

colan’s picture

I think we can get rid of it as per #2172843: Remove ability to update entity bundle machine names. That's where that comment was added.

colorfield’s picture

Ok thanks, I removed that feature from the SerialStorageInterface.
I can work a bit later this week on the unit test but do not think that the remaining issues are blocking + the coding standards have been applied.

colorfield’s picture

Status: Active » Needs review
alvar0hurtad0’s picture

Status: Needs review » Needs work

Still have some coding standards issues, and a problem with the @inheritdoc comment on setup.

I've created a pull request on github:

https://github.com/r-daneelolivaw/serial/pull/23

colorfield’s picture

Status: Needs work » Needs review

Thanks, merged

mennonot’s picture

Any update on this? This could be a useful, but not necessarily necessary field for a current Drupal 8 project we are working on.

colan’s picture

Given the status here, please test it and/or review the code and report back. Thanks! That will help us move forward with this.

extexan’s picture

Thanks for getting this ported to D8.

Could the D8 version be added to the Serial project page, and an issue queue created? I have a patch I'd like to submit re: an alternative for the MD5 hash in the table names, but I don't think I should post it here in this thread.

extexan’s picture

I'm developing in a local environment, then committing/pushing changes to a Pantheon Dev sandbox. When I enabled this module and created a serial field on a content type (locally), it seemed to work fine when I exported the config settings and pushed them to Pantheon. But when I tried to create a node of that type, I got an error because the serial_xxxxxxxxxxxx table did not exist.

It seems that table isn't getting created during the config synchronization when the serial field itself gets created.

colan’s picture

@ExTexan: As you suggested, it would be better to file any side effects as issues against 8.x. I just created a new 8.x branch by pushing master from the GitHub repository. So please file the above as a new issue. Thanks!

If we're done with the GitHub repository, it would be great if someone could recreate those issues here (against 8.x).

colorfield’s picture

I will recreate the GitHub issues on DO.

extexan’s picture

It's nice that we now have the 8.x version in the issue queue of the project page. Thanks for that.

Are there plans to move the 8.x code from github to the project page as well? It would be nice if we could include this in our "composer update" process instead of it being a manual step.

Isti_d’s picture

@colorfield: could you please advise when can we get it on the project page?

mmjvb’s picture

Status: Needs review » Needs work

With only a development release on d.o. Status should be Needs work. For Needs review an alpha or beta is needed on d.o.
This issue is to report the current Status of the port. The porting itself should be managed in the issue queue of the module itself, either on d.o. or GitHub. The same thing goes for status requests, Ask them in the module queue and update this issue with the answer.

Cyberflyer’s picture

Is anyone actively working on this module?

It's crucial to a side design I am just about to implement.

colorfield’s picture

Issue summary: View changes

Updated the issue summary for clarity (replaced the GitHub references by the Drupal.org ones), as described by @mmjvb we should now review remaining issues and decide with the module maintainers when a first alpha release is available then identify what are beta blockers.
I have no time to work on this project before February 2018, but will definitely be happy to help on remaining issues then.

Cyberflyer’s picture

@colorfield: I'm not able to code effectively at this level, but I can drive Mac GDB and have my PHP compiled with x-debug.

If folks are willing to get this thing going, I am willing to debug and provide feedback.

colorfield’s picture

@Cyberflyer all good, imo the first issue that we should work on is #2833506: Prevent regression of closed issues, so other contributors can run automated tests while producing patches. I can start with that in February.

Cyberflyer’s picture

@colorfield Well, it's Feb, the Eagles won the superb owl and I'm undeway. I want to launch my product with Drupal 8 if possible. One bug in PHP 7.2 is slated to be fixed in March. Followed your link to the Unit Testing set up. Makes sense.

If I can make a sensible pass at that, I will,

Thanks.

L.

colorfield’s picture

Added a patch for #2868303: Type not found for custom Entity and created a first port of the unit tests to PHPUnit #2833506: Prevent regression of closed issues.

I propose to continue with #2862447: Serial field not populated when node created programmatically + if we consider this feature as a mvp #2847954: Allow having starting value for the serial field and set existing entities initialization as optional, we need to take this into account #2945658: Add an option to bypass default serial initialization for existing entities.

+ probably a few updates from the 7.x branch that should be forward ported, any feedback?

dbt102’s picture

+1

colorfield’s picture

colan’s picture

Just moved that one to the project ownership queue so hopefully we'll get this rolling soon.

colan’s picture

@colorfield: I got full access today so made you a maintainer. Thanks for helping with the Drupal 8 version!

colorfield’s picture

Thank you @colan! I will start the work on the RTBC's this week

colorfield’s picture

Merged / closed a bunch of issues these last 2 weeks, thanks a lot to all the persons that helped on these ones :)

Did some extensive testing today and we are (finally) close to a release.
Opened 2 new issues, 1 of them needs review:

Then the following issues will be updated from the latest codebase during the dev days, next week

colorfield’s picture

mmjvb’s picture

Status: Needs work » Needs review

Due to alpha.

avpaderno’s picture

Assigned: colorfield » Unassigned
avpaderno’s picture

Status: Needs review » Fixed

There is a stable release for Drupal 10.

Status: Fixed » Closed (fixed)

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