Currently the built-in database backend has db table name repeated many times in its code (Drupal\advancedqueue\Plugin\AdvancedQueue\BackendDatabase). This to be avoided and to use a member property to keep the db table name and use that property replacing hardcoded table name across the code.

I faced this as an issue when extending the built-in database backend to use a different table to store jobs. Having the table name hardcoded, it forces me to duplicate most of the member methods just to replace the table name. Having table name on member property variable, the new extending backend class can have much less code as most of logic are same.

(As a background info: I want to use a new table just to make "job_id" column in the table "varchar" instead of "serial". So, we can set non numeric custom strings as job IDs. Having custom strings as job ids will help to identify whether a certain job is already queued/processed before creating it. We can construct Job ID of certain patterns values depending on the job)

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

junaidpv created an issue. See original summary.

junaidpv’s picture

Status: Active » Needs review

Please review the MR just updated.

johnwebdev’s picture

Status: Needs review » Reviewed & tested by the community

I think this is a reasonable change.

jsacksick’s picture

Status: Reviewed & tested by the community » Needs work

Perhaps we should make this a public const (or a protected const) that can be overridden by a child backend plugin if needed.

sayan_k_dutta’s picture

Assigned: Unassigned » sayan_k_dutta

Working on it.

sayan_k_dutta’s picture

Assigned: sayan_k_dutta » Unassigned
Status: Needs work » Needs review

Made the changes. Please review.

koustav_mondal’s picture

Status: Needs review » Reviewed & tested by the community

Changes looks good to me. Protected const is also declared. Moving to RTBC.

alexpott’s picture

  • alexpott committed 1d3af41f on 8.x-1.x authored by junaidpv
    Issue #3462741 by sayan_k_dutta, junaidpv, jsacksick: Avoid so much...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This looks great - I checked for any other direct usages of the table in the module and there were none.

  • alexpott committed 11c6e900 on 8.x-1.x
    Issue follow-up #3462741 by jsacksick: Avoid so much hardcoding of db...
alexpott’s picture

@jsacksick pointed out that self:: was not right when paired with a protected const. Fixed this post commit. Great catch @jsacksick!

Status: Fixed » Closed (fixed)

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