定制 discoverygarden/islandora_drush_utils 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

discoverygarden/islandora_drush_utils

Composer 安装命令:

composer require discoverygarden/islandora_drush_utils

包简介

Utility Drush commands for Islandora.

README 文档

README

License: GPL v3

Introduction

Contains a set of utility Drush commands for Islandora.

Table of Contents

Features

  • Deleter command to recursively delete all related nodes, media, and files.
  • Generate thumbnails command to re-derive thumbnails for nodes.
  • Null child weight command to identify and update nodes with a mix of null and integer values in field_weight.
  • Re-derive command to re-derive all derivatives for a set of nodes.
  • A user wrapper to replace the legacy --user drush wrapper to support user in drush commands.

Requirements

This module requires the following modules/libraries:

Installation

Install as usual, see this for further information.

Usage

Deleter

drush islandora_drush_utils:delete-recursively -vvv --dry-run --empty 7,11 --user=islandora

Given a comma-separated list of nodes to target, this command performs a breadth-first search to find all descendent nodes and deletes them, including their related media, and marks files related to media as "temporary" such that they become eligible for garbage collection by Drupal.

Generate thumbnails

drush islandora_drush_utils:rederive_thumbnails --model=Image -vvv --nids=7,11 --user=islandora

Given a comma-separated list of nodes to target, this command will re-generate thumbnails for the target model. A file containing comma-separated nids can also be provided as input.

Re-derive

drush islandora_drush_utils:rederive -vvv --user=islandora

This command re-generates all derivatives on the website. It is possible to define which "media use" term should be used as the source for derivative generation. This defaults to Original file

Null child weight

drush islandora_drush_utils:null-child-weight-updater --verbose
--dry-run 10 --user=islandora

This command identifies and updates nodes that have a mix of null and integer values in field_weight.

Queue runner

We have taken to use queue:run more; however, it does not natively have protections like running batches do, to occasionally re-fork to reduce memory usage due to Drupal's use of static caching.

This command allows the specification of some options with which to run a queue to completion:

  • --time-per-iteration: The amount of time we will request queue:run to run, in seconds. Defaults to 300.
  • --items-per-iteration: The number of items to request queue:run to process. Defaults to 100.

Otherwise, this is intended to be just be a slightly safer (in terms of memory usage) alternative to queue:run.

This command is just islandora_drush_utils:queue:run, and might be invoked with something like:

drush islandora_drush_utils:queue:run {queue_id}

where {queue_id} is the ID/name of one of the queues as might be returned from queue:list (or otherwise defined as the ID of a @QueueWorker plugin).

SEC-873 Remedy

SEC-873 is an internal issue dealing with repercussions of https://www.drupal.org/project/views_bulk_edit/issues/3084329 .

With this issue, replacing or adding paragraphs values to paragraph fields using Views Bulk Operations "modify fields" operation could lead to the same paragraph entity/ID being unexpectedly used across multiple parent entities. This can then lead to issues attempting to individually edit any of these entities, such as values from different paragraph revisions leaking to other entities referencing the same paragraph ID.

At the moment, this d.o issue is still open; however, there are patches on it which appear to work (though there may be other issues if combining with allowing the creation of new taxonomy terms inside of the paragraph; however, such should be able to be worked-around by creating such terms first, separately).

The process here creates new paragraph entities where it is detected that a paragraph is being shared across multiple parent entities, such that future edits the particular items should work as expected.

There are a few related commands:

  • islandora_drush_utils:sec-873:get-current: Dumps CSV to stdout which can be consumed by the :repair and/or :repair:enqueue commands, identifying what paragraphs are referenced across which entities in current/default revisions.
  • islandora_drush_utils:sec-873:get-revisions: Similar to :get-current, dumps similar CSV to stdout across ALL revisions, including the revision ID alongside entity IDs. Intended more for informative purposes.
  • islandora_drush_utils:sec-873:repair: Wraps the [...]:enqueue and [...]:batch commands together, for convenience.
  • islandora_drush_utils:sec-873:repair:enqueue: Consume CSV to populate queue to be processed.
  • islandora_drush_utils:sec-873:repair:batch: Process the populated queue.

User wrapper

--user=1

Before Drush 9, there was a "--user" option that could be used to run commands as other users. Here, a new "@islandora_drush_utils-user-wrap" annotation is provided, which can be used to allow the --user option in commands.

Display hint updater

When rolling out additional viewers, depending on how the front end is configured, it may be necessary to update the display hints for nodes.

The provided Drush commands will:

  1. islandora_drush_utils:display-hint-feeder - Returns all nodes with any specified taxonomy term URI(s) representing model(s) to update within field_model. Defaults to https://schema.org/Book.
  2. islandora_drush_utils:update-display-hints - Update all nodes passed with a specified taxonomy term URI in a replacement scenario. Defaults to https://projectmirador.org.

To invoke the updater command:

drush islandora_drush_utils:display-hint-feeder --user=1 --term-uris='https://schema.org/Book' > nodes.csv
drush islandora_drush_utils:update-display-hints --user=1 --term-uri='https://projectmirador.org' < nodes.csv

An alternative, more optimal approach would be to use GNU Parallel with two processes each processing 100 items at a time:

drush islandora_drush_utils:display-hint-feeder --user=1 --term-uris='https://schema.org/Book' | parallel --pipe --max-args 100 -j2 drush islandora_drush_utils:update-display-hints --user=1 --term-uri='https://projectmirador.org'

Public hOCR updater

In some instances, hOCR was set to the public:// stream wrapper instead of going into the correct configured derivative scheme. There are two commands provided to remediate this.

  1. islandora_drush_utils:identify-public-hocr - Finds all file entities that exist within the public:// stream wrapper that have the MIME type of text/vnd.hocr+html.
  2. islandora_drush_utils:fix-public-hocr - Updates all file entities passed to the configured scheme within the generate_hocr_from_an_image derivative action.

To invoke the updater command:

drush islandora_drush_utils:identify-public-hocr > public_ocr.csv
drush islandora_drush_utils:fix-public-hocr < public_ocr.csv

An alternative, more optimal approach would be to use GNU Parallel with two processes each processing 100 items at a time:

drush islandora_drush_utils:identify-public-hocr | parallel --pipe --max-args 100 -j2 drush islandora_drush_utils:fix-public-hocr

Troubleshooting/Issues

Having problems or solved a problem? Contact discoverygarden.

Maintainers and Sponsors

Current maintainers:

Sponsors:

Development/Contribution

If you would like to contribute to this module, please check out github's helpful Contributing to projects documentation and Islandora community's Documention for developers to create an issue or pull request and/or contact discoverygarden.

License

GPLv3

discoverygarden/islandora_drush_utils 适用场景与选型建议

discoverygarden/islandora_drush_utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 398 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 04 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 discoverygarden/islandora_drush_utils 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 discoverygarden/islandora_drush_utils 我们能提供哪些服务?
定制开发 / 二次开发

基于 discoverygarden/islandora_drush_utils 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 398
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 15
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 5
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2023-04-05