Drupal 9: Using The Caching API To Store Data

Posted by #! code - 1 hour 12 min ago

The cache system in Drupal has a number of different components with time, contexts and tags being used to determine the cache.

Whilst all of these mechanisms are really useful you can also inject data directly into the cache system. This is beneficial if you have an expensive function that takes a long time to complete. The result of the function can be stored in the Drupal cache system just like other cache data.

For example, let's say you are pulling data from a slow API. If the data doesn't change much it might be better to add a cache to the request so that instead of going to the slow API the fast cache systems are used instead.

To get an instance of the cache system you can use the \Drupal::cache() method, which will return an instance of a CacheBackendInterface type object. By default, this will assume that you want to use the 'default' cache bin, which is essentially the cache_default table (assuming you are using the database for your cache storage).

Once you have a cache object, there are a couple of important methods you can use.

Cache Methods

The first method to talk about is the set() method, which is used to write some cache to the cache system. This takes a few parameters and is called like this.

\Drupal::cache()->set($cacheId, $data, Cache::PERMANENT, $cacheTags);

Let's go through the parameters a little.

Read more.

Docksal 1.17.0 Release

Posted by Docksal - 23 Apr 2022 at 23:00 UTC

And a very special release it is!

A little pre-DrupalCon gift just dropped — Docksal v1.17.0. This release now supports Apple M1 and Linux ARM64 architectures. That is just the tip of this iceberg of a release (albeit a very big tip for those that have been waiting).

Software Version Updates

Docker Dependencies

The Docker suite now uses new versions:

  • Docker v20.10.12
  • Docker Compose v2.1.0.
  • Docker Desktop for Mac/Win users are able to update to the latest Docker Desktop v4.4.2+ version manually (tested officially with build 73305).

VirtualBox version (to v6.1.32), which adds official support for macOS Monterey 12.3.

Image Library and Stacks

Almost all services in the Docksal catalog have been updated to use fresh multi-arch (amd64/arm64) images.

docksal/cli has been updated v3.2. When v3.0 was released in July 2021, it was the first to have arm64 support. However, users had to manually set the CLI_IMAGE to use this version. v3.1 released in Feb 2022 dropped PHP 7.3 after it was EOL in Dec 2021. v3.2.0 through v3.2.2 has seen more updates to included tools. From v3.1 on, terminus 3.x is included with PHP 8 support.

Read more

The ABCs of PDPs and PLPs

Posted by Centarro - 23 Apr 2022 at 00:53 UTC
While many Drupal developers have at least some eCommerce experience, the number of people in our community who make it their primary focus is rather small. This isn't surprising, given Drupal is most often used as a CMS, not an eCommerce platform. However, it does mean that when you encounter an eCommerce opportunity, you may not be making the most effective pitch you can to win the merchant's business. One way to improve your pitch is to make sure you're using the same vocabulary to describe eCommerce features and concepts as the rest of the eCommerce industry. It's all too easy for us as Drupal developers to rely on our internal vocabulary, but merchants comparing your proposals, case studies, or Drupal Commerce articles won't have the slightest clue what Taxonomy Terms, Views, or Search API indexes are. Learning and using industry standard terms will help you build clarity and confidence with your eCommerce prospects and customers, reducing the amount of work they have to do to understand your proposals and compare them against other solutions to see exactly where Drupal Commerce comes out on top. Read more

3 things to know about Drupal in 2022

Posted by Opensource.com - 22 Apr 2022 at 07:00 UTC
3 things to know about Drupal in 2022

Several changes have made Drupal more accessible and easier to use.

Shefali Shetty Fri, 04/22/2022 - 03:00

A broad range of enterprises, including nonprofits, media and publishing, government agencies, education, and more, rely heavily on Drupal. But while Drupal is widely...

Elevating Our Impact: Oomph Joins 1% for the Planet

Posted by Oomph Insights - 22 Apr 2022 at 00:00 UTC
I’ve been following 1% for the Planet since around 2006, before Oomph was even born. As a father of a one-year-old at the time and a passionate outdoor enthusiast — especially around the ocean — sustainability was always top of mind for me, and seeing businesses take a stand on these issues was incredibly inspiring. I used to dream that one day my company would be a member, committed to giving back to the environment. Today, I’m excited to announce that Oomph has joined 1% for the Planet for 2022 and beyond! 1% for the Planet pairs businesses and individuals with environmental nonprofits…

Top Upcoming DrupalCon 2022 Picks for Higher Ed Marketers

Posted by ImageX - 21 Apr 2022 at 16:20 UTC
Oxford University, Harvard, MIT, Stanford, and a great number of other top Higher Ed institutions have one thing in common. Their websites are built with Drupal, the open source platform that keeps innovating to provide cutting-edge digital experiences.  What are the latest Drupal improvements, top-notch features, best practices, or complementary technologies that could be beneficial for university and college websites? The best way to learn is to follow the Drupal community’s largest annual event — DrupalCon. It gathers the best Drupal minds and the most passionate innovators that share their ideas, drive change and shape Drupal’s future.

DrupalCon Portland: Top Sessions for Developers

Posted by ImageX - 21 Apr 2022 at 16:19 UTC
Between April 25 to April 28, 2022, Portland will become the Drupal capital of the world. Like the strongest of magnets, the Oregon Convention Center will attract thousands of attendees to the first in-person DrupalCon since 2019. Valuable insights, new connections, and lots of communication are guaranteed for marketers, designers, editors, project managers, and all others who create or work with Drupal websites. We have recently shared top DrupalCon picks for Higher Ed marketers which is worth checking out.

Top Session Choices for Non-Profit Marketers at DrupalCon Portland

Posted by ImageX - 21 Apr 2022 at 16:18 UTC
Non-profit teams are dedicated enthusiasts working for a given cause. They definitely know the worth of a good website. Like a tireless team member, websites can work 24/7 bringing the organization’s message across to potential donors, boosting the whole team’s efficiency in routine tasks, and providing smooth user experiences for everyone. An enthusiastic team member always strives to go the extra mile. Similarly, non-profit websites can always do more for their teams... But in what way? The best answers can be found at DrupalCon Portland 2022.

Set up a local Drupal multisite with Lando on Mac OS

Posted by Aten Design Group - 21 Apr 2022 at 11:34 UTC
Set up a local Drupal multisite with Lando on Mac OS Eric Toupin Thu, 04/21/2022 - 05:34 Drupal

Setting up a local Drupal multisite with Lando isn’t complex with the right docs, but it took me a little while to find all the right bits of configuration. I’ve centralized them here for posterity.

Building and operating local development environments that reflect your production environments can be tricky — especially as the landscape of tools, libraries, and automations continues to evolve. Recently we’ve been pretty satisfied with Lando for Drupal development. It’s well supported, has an active developer community, and can be configured for a variety of tricky use cases like emulating a Pantheon environment (that will have to be a different post) or setting up a Drupal multisite.

If you’re here you probably know what a Drupal multisite is, but just in case: Multiple separate websites, each with its own database and configuration, served from the same code base. There are a host of uses for multisites, but if you think about different websites for different store branches or maybe a variety of individual blog sites driven from the same or similar setup you’d be on the right track.

Read more

Announcing the Field Formatter Pattern module

Posted by Morpht - 21 Apr 2022 at 01:24 UTC
A new contributed Drupal module allows site builders to add custom HTML pattern attribute to the text fields in the Manage Form Display settings page.

Announcing the Search API Field Token module

Posted by Morpht - 21 Apr 2022 at 01:24 UTC
The Drupal Search API Field Token module allows to send data into search index using tokens.

What’s new on Drupal.org - Q1 2022

Posted by Drupal.org blog - 20 Apr 2022 at 23:16 UTC

Read our roadmap to understand how this work falls into priorities set by the Drupal Association with direction and collaboration from the Board and community. You can also review the Drupal project roadmap.

Contributor Enablement

git.drupalcode.orgArchitecting GitLab CI for Contrib

The GitLab Acceleration initiative is one of the top priorities of the Drupal Association engineering team.

Over the past quarter, we've been focused on the transition from DrupalCI to GitLab CI, and about 20 contributed module maintainers have stepped forward to help us define the architecture. 

We fully believe that involving the community throughout the GitLab acceleration process will be essential to success.

In the case of CI testing for Drupal projects, the move from a centralized system (DrupalCI) to a decentralized one(GitLabCI) needs special care. Once control is directly in the hands of maintainers, we want to ensure we're providing default testing configurations that help them keep their testing up to date with the right versions and environments. 

Pre-work for Issue Migration

In addition to the focus on GitLab CI, we've done a lot of preparatory work for the transition to GitLab issues. Primarily, we've been updating custom version control information like commit logs from our bespoke Drupal.org implementations to link to GitLab instead.

Read more

The Present and Future of Drupal’s Administrative Interface

Posted by Lullabot - 20 Apr 2022 at 18:43 UTC

Claro is the new core administration theme based on the new Drupal design system. It is a clone of the Seven admin theme, the default admin theme in Drupal since Drupal 7. If Seven is adequate for a certain need, then Claro will be adequate for that need, too. We didn’t have to start from scratch.

The big-picture goals are as follows:

Drupal core - Moderately critical - Access bypass - SA-CORE-2022-009

Posted by Security advisories - 20 Apr 2022 at 15:07 UTC
Project: Drupal coreDate: 2022-April-20Security risk: Moderately critical 13∕25 AC:Basic/A:User/CI:Some/II:Some/E:Theoretical/TD:DefaultVulnerability: Access bypassDescription: 

Drupal 9.3 implemented a generic entity access API for entity revisions. However, this API was not completely integrated with existing permissions, resulting in some possible access bypass for users who have access to use revisions of content generally, but who do not have access to individual items of node and media content.

This vulnerability only affects sites using Drupal's revision system.

This advisory is not covered by Drupal Steward.

Solution: 

Install the latest version:

All releases prior to Drupal 9.3 (including Drupal 7) are not affected.

Read more

Drupal core - Moderately critical - Improper input validation - SA-CORE-2022-008

Posted by Security advisories - 20 Apr 2022 at 15:04 UTC
Project: Drupal coreDate: 2022-April-20Security risk: Moderately critical 12∕25 AC:Basic/A:User/CI:Some/II:Some/E:Theoretical/TD:UncommonVulnerability: Improper input validationDescription: 

Drupal core's form API has a vulnerability where certain contributed or custom modules' forms may be vulnerable to improper input validation. This could allow an attacker to inject disallowed values or overwrite data. Affected forms are uncommon, but in certain cases an attacker could alter critical or sensitive data.

We do not know of affected forms within core itself, but contributed and custom project forms could be affected. Installing this update will fix those forms.

This advisory is not covered by Drupal Steward.

Solution: 

Install the latest version:

All versions of Drupal 9 prior to 9.2.x are end-of-life and do not receive security coverage. Note that Drupal 8 has reached its end of life.

Drupal 7 is not affected.

Read more

April Drupal for Nonprofits Chat

Posted by Nonprofit Drupal posts - 20 Apr 2022 at 14:02 UTC

We are looking for an additional co-moderator for this group! Reach out to Jess or Johanna to learn more about what's involved.

Our normally scheduled call to chat about all things Drupal and nonprofits will happen TOMORROW, Thursday, April 21 at 1pm ET / 10am PT. (Convert to your local time zone.)

We don't have anything on the agenda at the moment, so we're looking to enjoy an informal chat about anything at the intersection of Drupal and nonprofits. Got something specific on your mind? Feel free to share ahead of time in our collaborative Google doc: https://nten.org/drupal/notes!

All nonprofit Drupal devs and users, regardless of experience level, are always welcome on this call.

This free call is sponsored by NTEN.org and open to everyone. 

  • Join the call: https://us02web.zoom.us/j/81817469653

    • Meeting ID: 818 1746 9653
      Passcode: 551681

    • One tap mobile:
      +16699006833,,81817469653# US (San Jose)
      +13462487799,,81817469653# US (Houston)

    • Dial by your location:
      +1 669 900 6833 US (San Jose)
      +1 346 248 7799 US (Houston)
      +1 253 215 8782 US (Tacoma)
      +1 929 205 6099 US (New York)
      +1 301 715 8592 US (Washington DC)
      +1 312 626 6799 US (Chicago)

    • Find your local number: https://us02web.zoom.us/u/kpV1o65N

Read more

Sneak Peak: Proof-of-Concept of Customisable Footer for a LocalGov Drupal Microsite

Posted by mark.ie - 20 Apr 2022 at 11:28 UTC

Here's a short video giving a proof-of-concept for how to create a customisable footer for a microsite based on LocalGov Drupal and Group Module.

The Liberian Observer in West Africa runs on Drupal and Thunder

Posted by Ramsalt Lab - 20 Apr 2022 at 10:01 UTC
The Liberian Observer in West Africa runs on Drupal and Thunder 20.04.2022

The Liberian Observer is Liberia's first independent daily newspaper that envisions expanding into new markets and becoming the leading national digital newspaper. After thoughtful investigation they chose Ramsalt as digital partner.

The Liberian Observer Corporation was founded by Mr. and Mrs. Kenneth Y. Best in Monrovia in 1981. It is an independent newspaper, its goals are government accountability and popular awareness of current events. In 2021 the newspaper celebrated its 40th anniversary.

Thunder and Ramsalt Media

- We envision having an online media platform that will enable us to power up content and experiences beyond our mainstream news service, such as a number of niche publications in multiple content formats and across numerous devices, said the Managing Director Bai Sama G. Best when he contacted Ramsalt in July 2021.

Upon learning about Thunder and its immense benefits for the online publishers, Liberian Observer began searching for a Certified Thunder Integrator that could help them move from their current publishing platform.

Read more

Why Is Drupal a Key To Success For Enterprise Web Development

Posted by Specbee - 20 Apr 2022 at 07:10 UTC
Why Is Drupal a Key To Success For Enterprise Web Development Shri Ganesh Hegde 20 Apr, 2022

Do you know how much enterprises spend on their websites annually? What makes their enterprise website great? I mean there is obviously the high traffic, better bounce rates, and over the top numbers, but is that all?

A recent study by Gartner estimated that large enterprise companies around the world spend close to $150 Billion just on their website. That is double the amount spent by some companies for all their digital marketing campaigns put together. What strikes me though - is all this money, billions of dollars, well-spent? Or is it just going down the drain?

I've always thought of working on an enterprise web development project as an entirely different experience than just building a website. When you handle enterprise web development, you are building an experience, a seamless environment that requires expertise, strategy, and a certain level of understanding. What sets the enterprise website apart from the ones termed as "normal" is the CMS used and the feature-rich experience it provides.

Over the years, combining tools and strategies, ECM (Enterprise Content Management) has handled a wide range of enterprise business requirements across all verticals. With the introduction of Drupal, the ECM System, which is different from the web CMS has seen certain developments. With Drupal as your ECMS, you can offer a superlative web experience to your users.

Read more

Pages

Subscribe with RSS Subscribe to Drupal.org aggregator - Planet Drupal