Skip to content

Bug: strMasterAlias false positive causes 500 error when module is embedded in a calendar event reader page #411

Description

@luger95

Bug report: strMasterAlias false positive when module is embedded in a calendar event reader page

Version: 1.32.52
Contao version: 4.13

Description

When a catalog-manager module (ModuleUniversalView) is inserted into a Contao calendar event reader page, a 500 error occurs.

The root cause is in the compile() method, at the condition:

$this->strMasterAlias && !$this->catalogPreventMasterView

On a calendar event reader page, the current URL contains the event alias. The module picks it up and assigns it to $this->strMasterAlias, then enters master view mode assuming the alias belongs to a catalog record. Since no catalog record matches the event alias, the module fails with a 500 error.

Steps to reproduce

  1. Create a calendar event reader page in Contao 4.13.
  2. Insert a catalog-manager universal view module on that page.
  3. Open any calendar event URL (e.g. /events/my-event-alias.html).
  4. A 500 error is thrown inside ModuleUniversalView::compile().

Expected behavior

The module should not enter master view mode unless the current alias actually matches a record in the catalog table. A non-catalog alias (such as a calendar event alias) should be ignored.

Suggested fix

Before entering master view mode, verify that the alias resolves to an existing catalog record:

if ($this->strMasterAlias && !$this->catalogPreventMasterView) {
    $objResult = \Database::getInstance()
        ->prepare("SELECT id FROM " . $this->catalogTablename . " WHERE alias = ? LIMIT 1")
        ->execute($this->strMasterAlias);

    if ($objResult->numRows < 1) {
        $this->strMasterAlias = null;
    }
}

This ensures the master view logic is only triggered when the alias genuinely belongs to the configured catalog table.

Happy to submit a pull request if this approach is confirmed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions