48 lines
1.8 KiB
Markdown
48 lines
1.8 KiB
Markdown
---
|
|
title: >
|
|
Open-source encourages more open-source
|
|
pubDate: 2023-12-05
|
|
permalink: >-
|
|
daily/2023/12/05/open-source-encourages-open-source
|
|
tags:
|
|
- software-development
|
|
- contribution
|
|
- open-source
|
|
- drupal
|
|
- php
|
|
---
|
|
|
|
[In yesterday's email][yesterday], I mentioned the Private Message Queue module - a contributed Drupal module we wrote for a project as part of a contribution-first workflow.
|
|
|
|
In our experience, doing that and releasing Private Message Queue as its own open-source project encouraged more open-source contributions.
|
|
|
|
We started to ask questions like, "Which user should the messages be sent from?".
|
|
|
|
## System Users
|
|
|
|
This led us to create the [System User module].
|
|
|
|
Inspired by system users in Linux, it provides a way to identify and retrieve system users that aren't tied to individuals' accounts and without relying on "magic" user IDs.
|
|
|
|
But what if a website doesn't have a system user?
|
|
|
|
## Null Users
|
|
|
|
This led to the [Null User module].
|
|
|
|
Following the Null object pattern, if there isn't a system user, instead of returning `NULL` or `FALSE`, you return a null user that you use in the same way, though they'll have default empty values and won't perform any actions.
|
|
|
|
This pattern simplifies your code as you don't need to check for `NULL` or `FALSE` values.
|
|
|
|
## Here's the thing
|
|
|
|
If I remember correctly, as part of the project, we created and released around ten new contributed modules to Drupal.org.
|
|
|
|
We were able to move straight onto the next phase of the project.
|
|
|
|
We didn't need to clean them up or refactor them beforehand. We didn't need to dedicate any additional time as they were already released.
|
|
|
|
[null user module]: https://www.drupal.org/project/null_user
|
|
[system user module]: https://www.drupal.org/project/system_user
|
|
[yesterday]: {{site.url}}/daily/2023/12/04/writing-contrib-modules-as-glue-between-your-custom-code
|