Support from Acquia helps fund testing for Drupal Acquia logo

Comments

demonde created an issue. See original summary.

init90’s picture

Status: Active » Needs review
FileSize
6.24 KB

Here is an initial patch that adds 'status' field support. Note that patch doesn't provide UI, most likely it should be added in a separate issue.

init90’s picture

This patch adds UI and extends tests for the 'status' field.

maestro888’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +ContributionWeekend2020
FileSize
79.09 KB

I've tested this solution in the Entity context. All is well.
I've tested this solution in context Bundle. All is well.
Also, I`m deleted bundle and deleted Entity. All is well.

bgilhome’s picture

I get errors like "Call to a member function getFieldStorageDefinition() on null in Drupal\Core\Entity\ContentEntityBase->getEntityKey()" when the entity builder tries to get the key for 'published' (e.g. rendering entities in a view).

Updated patch adds the entity key for 'published', attached with interdiff from #3.

pifagor’s picture

Status: Reviewed & tested by the community » Needs review
bgilhome’s picture

It seems the isPublished() method is not returning the correrct result - I had to override it and manually get the status field value for it to work.

I've also added a permission 'view unpublished eck entities' and added it to the access check (it overrides view own/any type-specific permissions, not sure what the usual approach is here).

Finally, I added hasStatusField() method to EckEntityType - not sure where this and the other hasXXField methods are used but thought it best to add it for consistency.

Patch and interdiff attached.

bgilhome’s picture

Need to check hasField() first to for the status field - updated patch & interdiff attached.

Michelle’s picture

I'm trying this out and it's not saving a change to the published status. If I uncheck it and save and then edit again, it's still checked. I'm going to dig into the code to try to figure it out.

Edit: I tried and failed to find the issue. I'm going to have to switch to doing a work around for what I need. Hopefully someone else can figure out the problem because I think this is a good addition to the module.

eugene.brit’s picture

If you need revisions and status field on your site:

  1. install 8.x-1.0-beta2 version of the module
  2. apply this patch at first https://www.drupal.org/project/eck/issues/2788507#comment-13699325
  3. apply updated patch from this comment

Otherwise, you can ignore this patch.

Murz’s picture

Thanks, patch become works well when I run updates via drush updb() after applying patch!

Murz’s picture

Also note, that on Drupal 8.9.3 with PHP 7.1 update process fails with error:

In ProcessBase.php line 188:
Unable to decode output into JSON: Syntax error
Error: Call to a member function claimItem() on null in _drush_batch_worker() (line 237 of vendor/drush/drush/includes/batch.inc).

Upgrade PHP to 7.4 resolve this problem.

@Michelle, maybe you miss with step to apply updates, or have old php version?

  • Matroskeen committed 6831279 on 8.x-1.x authored by bgilhome
    Issue #2924320 by bgilhome, init90, eugene.brit, maestro888: Add...

  • Matroskeen committed b014cf9 on 8.x-1.x
    Issue #2924320 by bgilhome, init90, eugene.brit, maestro888, Matroskeen...
Matroskeen’s picture

Status: Needs review » Fixed

Let's get this in!

I've committed a patch from #8 and additional test coverage for "view unpublished eck entities" permission. I also applied one change to the access controller to make the access control more granular - users will have access to unpublish entities only if they already have "view own ..." or "view any ..." permission for this particular entity type.

Just for the record, I wasn't able to reproduce the issues described in #9.

Thanks, everyone!

Status: Fixed » Closed (fixed)

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

DieterHolvoet’s picture

I created a separate module since this feature hasn't been included in a tagged release yet: https://www.drupal.org/project/eck_status_field

liberatr’s picture

Thanks for that module @DieterHolvoet -- we will look into using your module. This code is in the dev branch of eck, but not a release. Currently we are using 1.0.0-beta2 with these two patches applied:

https://git.drupalcode.org/project/eck/-/commit/6831279456ea438ea0b1d4db...
https://git.drupalcode.org/project/eck/-/commit/b014cf923258be5b2692c02c...

The project I am on wants to avoid -dev releases if at all possible.