• Uncategorized

    Actionable Task Naming – Reduce Confusion, Increase Speed

    I’ve worked on many teams across many task management systems. One practice that has consistently brought clarity to our projects is actionable task naming. That is, naming tasks in a way that makes them assignable and actionable. This will reduce the number of false assumptions made, and the amount of time it takes people to interpret a task, every time they encounter the task!

    Doing this is easy, too.

    Instructions:

    When you’re writing a task, say these words first (in your head): “I need you to…” or “I need them to…” or “John needs to” — you get the gist. It’s that simple (most of the time).

    Example 1:

    Instead of Hero image on the homepage is too large you could say Make homepage hero image smaller or Homepage: make hero image smaller or similar.

    Note that I often remove the word “the” (Make the homepage hero image smaller).

    Example 2:

    This time I’ll illustrate why this practice is useful:

    Address field is optional  — does that mean it is currently optional but needs to be required? Or does it mean that it’s presently required but needs to be optional? I don’t want to have to ask myself that question each time I pass by this task. It’d be much easier to understand the intent/issue if it was written Make address field optional or Make address field required or similar.


    On a Related Note (for Developers)

    You can use a similar practice when writing version control commit messages.

    Instead of I need you to... we use the prefix This will....

    The result is consistent messages that say what will happen with a commit is applied/reverted.

    Example:

    Update jQuery UI version to 3.5.1
  • Photography

    Walter’s First Birthday

  • Development

    Increasing Memory for Specific Paths in Drupal 8

    Most of the examples I see for Drupal 8 are for single-path memory limit increases.

    The examples for Drupal 7 often follow the pattern below.

    Here’s a D8 version that supports multiple paths.

    Place this in your settings.php (or site/environment-specific settings.php), then update the paths accordingly.

  • Development

    Conditionally Triggering Salesforce Push Operations in Drupal 8

    The user interface for the Salesforce Suite in Drupal 8 is fantastic. The suite itself is incredibly powerful. Among the many options, for each mapping you create you can specify what operations should trigger a synchronization. Here’s an example:

    We recently faced an issue with the “Drupal entity update” trigger being called too often. The salesforce_push module implements hook_entity_update() , which gets called a lot. After looking at how the functions are called in salesforce_push.module I realized there were two choices:

  • Development

    Patch for Drupal 8.7.14 SA-CORE-2020-004, SA-CORE-2020-005, and SA-CORE-2020-006

    I have a site that’s temporarily stuck on 8.7.14; it’s not worth the risk to update to 8.8.8 right now.

    I was able to diff 8.8.7 and 8.8.8 to figure out what changes were made for these security announcements:

    I could then compare the changes with 8.7.14 to create the patch below, which applies against 8.7.14 without any issues.

    DISCLAIMER: The formal recommendation is to update to 8.8.8 if at all possible. Use the patch below at your own risk.

     

  • Development

    Storing First and Last Name with Social API for Drupal 8

    I recently worked on a project that relied on Social API for Google, Facebook, and Yahoo authentication. Out of the box everything worked great. Our site stores the user’s first name and last name in two fields on the user entity: field_first_name  and field_last_name. There are a few ways to tap into the Social API authentication process (which comes from the Social Auth component).

    Originally we leveraged the SocialAuthEvents::USER_CREATED event in an event subscriber. We set the first name and last name, then re-saved the user. This, however, executes after the user is created. The issue we had was that we also have Salesforce integration and both name fields are required in Salesforce. When the user is first saved it was pushing to Salesforce without the name fields, which triggered an error.

    The solution was to implement a different event handler: SocialAuthEvents::USER_FIELDS

    This lets you manipulate the user fields before the user is saved. I poked through the Social Auth code and figured out how to get the first and last name values. Here’s the working solution:

    web/modules/custom/mymodule/mymodule.services.yml

    web/modules/custom/mymodule/src/EventSubscriber/MymoduleSocialAuthSubscriber.php

    After creating/updating the files above, just clear the caches and test.

  • Development

    Overriding “Required Message” on Composite Fields in Webform (Drupal 8)

    The more commonly used fields in Webform (text, radios, etc.) offer the ability to set a custom Required message string. This is the text that shows in the error message when a required field is not filled.

    Here’s what that screen looks like when you’re configuring a field on the Build screen:

    Required message

    There are several element types that do not provide a UI field to set this Required message value. The composite Name and Advanced Address field are two examples I encountered. For these fields you have to dig a little deeper, but it’s easy once you get the hang of it. Visit the Advanced tab for the field, then scroll to the bottom where you’ll see a Custom Settings fieldset.

  • Development

    Snippet: MySQL table sizes ordered by largest to smallest (in MB and Row Count)

    Show All Tables By Size in MB

     

    Show All Tables By Size in MB (if > 1 MB)

     

    Show All Tables By Number of Rows

     

  • Development

    Using Drupal 8 Persistent Login Module on Platform.sh

    The Persistent Login module relies an extra cookie to maintain a Drupal user’s session. The configuration screen for this module lets you specify a prefix for the cookie. The default is “PL”. If you are using the site on HTTPS, the module prepends an “S” to the cookie it creates. Here’s an example cookie name: SPLfa0650d6d985433d455a3b15cc70fd9b .
    Platform.sh lets you configure cookie cache settings via routes.yaml .
    If you’re using Persistent Login you must tell the system not to ignore this cookie.
    Here’s a standard (and simple) routes.yaml  file on a Drupal 8 site:
    Here’s a modified version which allows Persistent Login to work correctly:

     

    There is a bit more discussion around how these cookies are handled here: https://www.drupal.org/node/2898065/discuss