Issue Bug Closed

#108779Plugin's partial can be inaccessible if there are multiple partialRootPaths

Dmitry Dulepov 01/26/26, 15:57 updated 03/31/26, 08:10

Description

This seems to be similar to #81099. It was fixed for TYPO3 v11 & v12 but in v13 the fixed method is deprecated and not used.

Suppose I use EXT:news and want to extend the NewsController with new views. I create a EXT:test/Classes/Controller/MyNewsController and register my own plugin. I want to reuse some partials of EXT:news (like List/Detail but I want to override some others (like List/Item). Here is what I do in TS:

plugin.tx_test.view { 
  partialRootPaths { 
    10 = EXT:news/Resources/Private/Partials/
    15 = EXT:eventnews/Resources/Private/Partials/
    20 = EXT:test/Resources/Private/Partials/
  } 
}

According to the documentation it should search EXT:test/Resources/Private/Partials/ for partials and if it cannot find the partial there, it should search EXT:news/Resources/Private/Partials/ , right?

Wrong.

The actual order becomes:

[
  0 => 'EXT:test/Resources/Private/Partials/',
  1 => 'EXT:news/Resources/Private/Partials/',
  2 => 'EXT:eventnews/Resources/Private/Partials/', 
]

So partials from EXT:news will always be used and not mine.

Why?

Look at ActionController::resolveView() :

        $partialRootPaths = ['EXT:' . $extensionKey . '/Resources/Private/Partials/'];
        if (!empty($configuration['view']['partialRootPaths']) && is_array($configuration['view']['partialRootPaths'])) {
            $partialRootPaths = array_merge($partialRootPaths, ArrayUtility::sortArrayWithIntegerKeys($configuration['view']['partialRootPaths']));
        }

So $partialRootPaths becomes:

[
  0 => 'EXT:test/Resources/Private/Partials/',
  10 => 'EXT:news/Resources/Private/Partials/',
  15 => 'EXT:eventnews/Resources/Private/Partials/',
  20 => 'EXT:test/Resources/Private/Partials/',
]

Still good, though there is a duplicate of my path.

Next we have TemplatePaths::setLayoutRootPaths(), which calls ArrayUtility::sortArrayWithIntegerKeys() and TemplatePaths::sanitizePaths(), which calls array_unique(), and … And then we have this:

[
  1 => 'EXT:test/Resources/Private/Partials/',
  2 => 'EXT:news/Resources/Private/Partials/',
  3 => 'EXT:eventnews/Resources/Private/Partials/'
]

So my 20 entry has gone because ActionController::resolveView() prepended the array with the default view path for my extension without checking that it already exists there and in the different order. Thus it changed my order of paths. Same happens for layout and template paths.

Skipping path to my ext does not change anything.

The right solution would be to check for the existence of the path in the confuguration inside the ActionController::resolveView(). If the path is explicitely set, do not prepend it. That’s all.

Reviews 4

Files 1

History 1224

  1. Dmitry Dulepov commented and changed attached 1205-wrong-path-to-partials.patch <span data-processor="relativetime" data-value="2026-01-26T16:07:36+00:00" > 01/26/26, 16:07 </span>

    Patch version 1.

    If the patch is used as is, I would appreciate that the comitter uses --author='Dmitry Dulepov <dmitry.dulepovgmail.com>@ while comitting. Thanks! :)

  2. Dmitry Dulepov commented <span data-processor="relativetime" data-value="2026-01-26T16:45:20+00:00" > 01/26/26, 16:45 </span>

    Now thinking about it, I believe it is not specific to extending another plugin but it will happen for any plugin where partials (or layouts or templates) match the following conditions:

    1. Additonal paths are given (for example, to another extension’s partials)
    2. A partial in another path has the same name as the partial in the extensions’s directory (like both have Resources/Private/Partials/List/Item.html

    In this case there is absolitely to way to use the partial from the current extension because its partials path will be always lower in priority than any other mentioned partials path.

  3. Dmitry Dulepov changed subject Cannot override partialRootPaths of another extension when extending the controller Plugin's partial can be inaccessible if there are multiple partialRootPaths <span data-processor="relativetime" data-value="2026-01-26T16:48:09+00:00" > 01/26/26, 16:48 </span>

  4. Garvin Hicking commented <span data-processor="relativetime" data-value="2026-01-26T19:23:11+00:00" > 01/26/26, 19:23 </span>

    Would you like to propose this patch to gerrit, then we can also see if Tests might react on if.

    Otherwise I could insert your patch to the system, but without doing git author stuff. ;)

  5. Dmitry Dulepov commented <span data-processor="relativetime" data-value="2026-01-28T08:35:43+00:00" > 01/28/26, 08:35 </span>

    I will try myself until the end of the week. If there are already tests for the ActionController, I will try add more too.

    Thanks!

  6. Garvin Hicking commented <span data-processor="relativetime" data-value="2026-01-28T09:34:58+00:00" > 01/28/26, 09:34 </span>

    Great, thanks! Simon also accepted this as a problem and “mishap”, so I’m positive we’ll get this through.

  7. Dmitry Dulepov commented <span data-processor="relativetime" data-value="2026-02-02T14:55:03+00:00" > 02/02/26, 14:55 </span>

    A change to the patch.

    It will not append the default path to the end. It will check if the default path is there and will not prepend it then.

    See also a fix for fluid, which causes this bug: https://github.com/TYPO3/Fluid/pull/1298)

  8. Dmitry Dulepov commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-02-03T09:25:08+00:00" > 02/03/26, 09:25 </span>

    Applied in changeset commit:be1844c9565eeb63657a59d3eb38fa177c7d7dfc.

  9. Gerrit Code Review pushed patch set 2 for 13.4 to change 92635 status Resolved Under Review <span data-processor="relativetime" data-value="2026-02-03T09:43:54+00:00" > 02/03/26, 09:43 </span>

  10. Dmitry Dulepov commented and changed status Under Review Resolved <span data-processor="relativetime" data-value="2026-02-03T10:10:09+00:00" > 02/03/26, 10:10 </span>

    Applied in changeset commit:c0a3f83f0ec753ade1907966fa184106b03d7d52.