Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coding standards, database standards, and performance pass #15

Open
wants to merge 81 commits into
base: 8.x-1.x
Choose a base branch
from

Conversation

qadan
Copy link

@qadan qadan commented Aug 10, 2020

Supersedes #12, #13, and #14, which I'm closing.

This pull encompasses a great deal of things, so a summary will probably be extremely helpful here:

  • Coding standards passes:
    • phpcs passes for Generic, Drupal, and DrupalPractice
    • phpcpd passes
    • PHP lint passes
    • This included function and class variable documentation and comprises the bulk of changes
  • The usage of \Drupal:: has been almost completely removed, except where absolutely necessary
    • Dependency injection has been implemented everywhere that it possibly can be
    • This probably represents the second largest chunk of changes
  • Anything that was previously calling Markup::create() or render() has been replaced with full renderable arrays
    • In the cases where markup is complex, these renderable arrays now reference twig templates
    • Translatability has been ensured for all renderable strings in the module.
  • Cache tags and contexts are implemented in renderable arrays, access controllers, and in the embargo entity type itself, so that caches no longer have to be globally flushed or have their max-age set to 0
  • embargoes-file-embargoes.js and its corresponding library file has been removed so that jQuery isn't overriding properties set by the theme
  • An EmbargoedAccessInterface has been implemented to allow entities of various kinds to determine how they wish to restrict access to entity types or provide redirection
    • Base implementations have been created for node, media, and file, that move out a lot of the logic from embargoes.module
    • This was done partially to remove duplicate code, and partially to ensure cacheability of results
  • An access control handler for files, EmbargoesFileAccessHandler, has been implemented, and asserts itself by altering the file entity type
    • This overrides the default site behaviour (which allows files to be viewed/downloaded with no access control when stored on the public filesystem) by instead asking first if an embargo should prevent access.
  • EmbargoesEmbargoesService::getParentNidsOfFileEntity() now checks references for files in image fields
    • This change allows embargoes to have an effect on files stored on media using an 'image' field.
  • IP embargo redirection is now managed by an EventSubscriber hooking into the request event itself, as the previous method of manually generating a RedirectResponse and calling send() was causing problems with cached headers being present.
  • Some database optimization has been done:
    • Columns are postgresql-friendly
    • Indices have been implemented
    • Text repetition has been reduced, specifically by representing an embargo's notification status as an 8-bit integer instead of a string
  • A schema has been implemented for embargoes.settings
  • The log controller has been removed and replaced with complete views integration for the embargoes_log table in a submodule, embargoes_log_views.
    • A default log view is included
    • Plugins for the special log data model pieces are included
    • A wizard plugin is included to create new views
    • The view wires up node and user relationships so that they're accessible when creating or modifying embargoes log views

The one thing that's not implemented here that I very much would have liked is to move the access control stuff to a plugin system. I'm not a huge fan of the fact that I've implemented access control as services, or hard-coded those services into specific hooks/the IP redirect subscriber. This was kind of a quick n' dirty solution; it would make far more sense to implement a plugin so that individual entity types could determine whether or not they should be accessible based on an embargo, then have the access hook and event subscriber vaccum them all up when Drupal builds its cache. That's an improvement for a later day, though.

One current unresolved issue of note is the fact that the EmbargoesNotificationsForm isn't wired up to anything - there's no embargoes.notifications schema, and it doesn't appear that embargoes.notifications is referenced anywhere else. This wasn't really considered an issue for this pass but is probably worth looking into a solution in the future.

MorganDawe and others added 14 commits August 11, 2020 11:22
This can happen when switching something from scheduled to indefinite without manually clearing the expiration date before toggling the indefinite radio button in the form.
Wasn't breaking anything, but it made the embargoes page look misleading.
…exempt users

before this change, if viewing an embargoed object that didn't have any exempt users, then the foreach loop wouldn't be run for the empty array and the message wouldn't be added.
…rray

empty nids array is returned if no relationships
@@ -22,15 +24,14 @@ function embargoes_schema() {
'not null' => TRUE,
],
'action' => [
'type' => 'varchar',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qadan , I believe the reason why a string was used here was so that a username would persist even after the user is deleted from the Drupal instance.

jordandukart and others added 8 commits February 19, 2021 14:01
Adding a default message for embargo notification block
```
Drupal\Core\Config\Schema\SchemaIncompleteException: Entity type 'Drupal\embargoes\Entity\EmbargoesEmbargoEntity' is missing 'config_export' definition in its annotation
```
Fix for missing entity configuration in Drupal 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants