Symlink support for _rules_discover_module()

Created on 6 May 2015, over 9 years ago
Updated 22 July 2024, 5 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

Fixed

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

Merge Requests

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 Seattle, WA

    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.

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

    This symlink issue is potentially causing all tests to fail under PHP 8 on GitLabCI (the test environment uses symlinks ...), so I've created an MR out of the patch in #4 to see if it solves those errors.

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

    Restored MR to be identical to the patch + removal of the PHP 7.4 requirement from .gitlab-ci.yml.

    Crediting @fjgarlin because he was the one who figured out that the testing problem might be because GitLab CI was using symlinks.

  • Pipeline finished with Skipped
    5 months ago
    #219109
    • TR β†’ committed 50147af7 on 7.x-2.x
      Issue #2483729 by TR, das-peter, hargobind, fjgarlin: Symlink support...
  • Status changed to Fixed 5 months ago
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    I'm still not thrilled about committing this without tests, because it will affect about 100,000 legacy sites still running on D7.

    On the other hand, I can't support anything about this module without the tests running properly on GitLabCI, so I don't really have a choice. I guess GitLabCI will have to be the practical test that symlink support is working.

    Merged. Thanks to all who helped.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024