Bug #91365

t3editor CSS fail to load if typo3 is not installed in the document root

Added by Mathieu Bilodeau about 1 year ago. Updated 9 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
t3editor
Target version:
-
Start date:
2020-05-12
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.3
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

For our setup, we have many instances of typo3 which are installed in a subdirectory under the same domain. In the past versions that I know of (from 4.1 to 7.6) it worked well. We recently started working with 9.5LTS and 10.4LTS which both present the same issue.

If typo3 9.5 or 10.4 is installed in a subdirectory,
(ie: http://www.my-domain.com/my-typo3/) t3editor fail to work properly.

How to reproduce

1) Here is the directory structure for a traditionnal installation (without composer):

/var/www/html/typo3_src-10.4.1
/var/www/html/my-site/typo3_src -> ../typo3_src-10.4.1
/var/www/html/my-site/typo3 -> typo3_src/typo3
/var/www/html/my-site/index.php -> typo3_src/index.php

2) Installation goes through without any issue, I conclude installation with a blank database: "Take me straight to backend"

3) Then create a first page with "Site root" property enabled

4) With Template module, "create template for a new site"

5) Finally, edit "Constants" or "Setup" to notice the textarea going gray.

Using the development tool of my browser, I can notice a merged CSS is loaded, but no styles are applied to the textearea (CoreMirror classes).

-----------------------------
Suggested solution

I recommend modifying the way CodeMirror styles are included. In the file: typo3/sysext/t3editor/Classes/Form/Element/T3editorElement.php

Here is the diff of my suggested patch:

--- T3editorElement.php.orig    2020-05-12 08:47:56.991906778 -0400
+++ T3editorElement.php    2020-05-12 09:02:59.705085701 -0400
@@ -96,11 +96,10 @@
     public function render(): array
     {
         $this->extPath = PathUtility::getAbsoluteWebPath(ExtensionManagementUtility::extPath('t3editor'));
-        $codeMirrorPath = $this->extPath . 'Resources/Public/JavaScript/Contrib/cm';

         $this->resultArray = $this->initializeResultArray();
-        $this->resultArray['stylesheetFiles'][] = $codeMirrorPath . '/lib/codemirror.css';
-        $this->resultArray['stylesheetFiles'][] = $this->extPath . '/Resources/Public/Css/t3editor.css';
+        $this->resultArray['stylesheetFiles'][] = 'EXT:t3editor/Resources/Public/JavaScript/Contrib/cm/lib/codemirror.css';
+        $this->resultArray['stylesheetFiles'][] = 'EXT:t3editor/Resources/Public/Css/t3editor.css';
         $this->resultArray['requireJsModules'][] = [
             'TYPO3/CMS/T3editor/T3editor' => 'function(T3editor) {T3editor.observeEditorCandidates()}'
         ];

With this patch, the t3editor is now working as expected.

#1

Updated by Gerrit Code Review about 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64781

#2

Updated by Gerrit Code Review about 1 year ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64781

#3

Updated by Tomas Norre Mikkelsen about 1 year ago

Hi,

We have tried to reproduce this during the Review Friday, but don't succeed.
Do you have other extensions installed that could influence the js/css minify?

Have you tested if it works without your symlink setup? I'm asking to see if it's a generic issue or only an issue when having the symlink set up as you describe above.

#4

Updated by Ulfried Herrmann about 1 year ago

Hi,

I can confirm this issue for TYPO3 9.5.19. In our develop instance everything is fine, in the production instance the field bodytext of the HTML CE isn't usable. Both instances are set up with composer, and both reside in a subdirectory. (Comparing server settings - headers, compression and so on - didn't show relevant differences...)
Mathieu's suggested solution did help us (thank you for investigating!).

---
Maybe this error message can help:
Core: Error handler (BE): PHP Warning: file_get_contents(/var/www/{domain}/{subdirectory}/public/typo3//{subdirectory}/typo3/sysext/t3editor//Resources/Public/Css/t3editor.css): failed to open stream: No such file or directory in /var/www/{domain}/{subdirectory}/public/typo3/sysext/core/Classes/Resource/ResourceCompressor.php line 368

#5

Updated by Mathieu Bilodeau about 1 year ago

I retried reproducing the bug and end up with different results depending on which server I put the code on.

  1. In a docker image it did work well without my suggested patch
  2. On a development server where each linux user have their own url like this: www.my-domain.com/~myusername/my-new-typo3/ it failed.
  3. I tried on a production server with this kind of url and it worked well: www.my-domain.com/my-new-typo3/

My comprehension is that, to merge every CSS, a public URL must be passed, but in t3editor, a relative path is given. So depending on which environment, the relative path is not always valid. By using my patch, it prevent those differences.

#6

Updated by Lidia Demin about 1 year ago

Can confirm this on TYPO3 9.5.18 composer installation with following folder structure:

/var/www/{domain}/{subdomain}/ → contains the actual installation (vendor, public etc.)
/var/www/{domain}/public/ → contains following symlink: {subdomain} -> ../{subdomain}/public/

#7

Updated by Gerrit Code Review 10 months ago

Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/65559

#8

Updated by Gerrit Code Review 10 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/65560

#9

Updated by Andreas Fernandez 10 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#10

Updated by Benni Mack 9 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF