Symlink support for _rules_discover_module()

Created on 6 May 2015, about 9 years ago
Updated 2 January 2024, 6 months ago

Problem/Motivation

I just figured out that on our Drupal setup, that uses symlinks, _rules_discover_module() triggers lot's of db queries in drupal_get_filename().
This is because _rules_discover_module() doesn't handle symlinks atm. and RulesAbstractPlugin::getIncludeFiles() doesn't check if a sane value is given as module parameter.
This can lead to calling module_invoke() with FALSE as module parameter. Which then again triggers drupal_get_filename() with non-sense.
I found the whole thing because of this: #2380361: Latest tweaks to bootstrap.inc can make Drupal sluggish when there is code that tries to load a file that doesn't exist β†’

Proposed resolution

Add symlink support to _rules_discover_module().
Just call module_invoke() in RulesAbstractPlugin::getIncludeFiles() if there's a sane value for module.

Remaining tasks

Reviews needed.

User interface changes

None.

API changes

None.

✨ Feature request
Status

Needs review

Version

2.0

Component

Rules Core

Created by

πŸ‡¨πŸ‡­Switzerland das-peter

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States hargobind Austin, Texas

    The patch in #2 no longer applies against 7.x-2.x-dev. Attaching an updated patch.

    I'm still testing this myself to see if it fixes the problem. I'll report back if I can.

  • πŸ‡ΊπŸ‡ΈUnited States jvogt

    Patch #4 applies cleanly to rules 7.x-2.13 with php 8.1 and core 7.95. It resolves the issue of the error message ("Deprecated function: dirname(): Passing null to parameter #1 ($path) of type string is deprecated in drupal_get_path() (line 2974 of /[...]/includes/common.inc).") I haven't tested it beyond that.

  • πŸ‡ΊπŸ‡ΈUnited States RobertInOP

    Patch #4 also applies cleanly to rules 7.x-2.14, with PHP 8.1 and core 7.98. The message (similar to #5) is no longer logged:

    "Deprecated function: dirname(): Passing null to parameter #1 ($path) of type string is deprecated in drupal_get_path() (line 2970 of /[...]/includes/common.inc)."

  • πŸ‡ΊπŸ‡ΈUnited States TR Cascadia

    There are still no reviews that say anything about testing this new feature and whether it works or not.

    The "Deprecated function" warning is something from PHP 8, and is a separate issue from symlinks, and has no bearing on whether this patch achieves its intended goals.

    The best way to prove this works, absent community participation in testing, is to write a test case using a symlink. The test case should fail in the current version of Rules because of the problem mentioned in the original post. Then after we apply the patch the test case should now work, which proves that the patch fixes the problem.

    A test case is required for new features in Drupal, and Rules is using those same criteria when adding new features. I don't plan to commit this patch without feedback from the community about whether it works, but I could skip that part if there was a good and effective test case included with the patch.

Production build 0.69.0 2024