helhum / typo3-secure-web

Secure your TYPO3 installation by only exposing public files
60 stars 12 forks source link

Folders in public/typo3conf/ext are not deleted after removing extension #11

Closed peterkraume closed 3 years ago

peterkraume commented 6 years ago

When you remove an extension with composer remove there remain some traces in public/typo3conf/ext:

ext_key/
ext_key/Resources
ext_key/Resources/Public
helhum commented 6 years ago

Hm, I can't confirm this. Can you give me more details on your setup and the exact command you are executing?

helhum commented 6 years ago

Could it be that you are on Windows?

peterkraume commented 6 years ago

My host system is Mac but I run the composer remove within a DDEV environment. It's a legacy TYPO3 8.7 project where I added helhum/typo3-secure-web recently and reconfigured everything from using a web folder to now public and private.

The problem occurred when I removed old extensions prior to the upgrade to TYPO3 9.5. I'm able to reproduce the issue.

This is my composer.json:

{
    "repositories": [
        { "type": "path", "url": "packages/*/" },
        { "type": "composer", "url": "https://composer.typo3.org/" }
    ],
    "name": "typo3/cms-base-distribution",
    "description" : "TYPO3 CMS Base Distribution",
    "license": "GPL-2.0+",
    "config": {
        "platform": {
            "php": "7.2"
        }
    },
    "require": {
        "helhum/typo3-console": "^5.0",
        "typo3/cms-belog": "^8.7",
        "typo3/cms-beuser": "^8.7",
        "typo3/cms-func": "^8.7",
        "typo3/cms-fluid-styled-content": "^8.7",
        "typo3/cms-info": "^8.7",
        "typo3/cms-info-pagetsconfig": "^8.7",
        "typo3/cms-lowlevel": "^8.7",
        "typo3/cms-opendocs": "^8.7",
        "typo3/cms-reports": "^8.7",
        "typo3/cms-rte-ckeditor": "^8.7",
        "typo3/cms-recycler": "^8.7",
        "typo3/cms-setup": "^8.7",
        "typo3/cms-sys-note": "^8.7",
        "typo3/cms-tstemplate": "^8.7",
        "typo3/cms-wizard-crpages": "^8.7",
        "kws/kws-theme-zmg": "@dev",
        "typo3-console/composer-auto-commands": "^0.2.0",
        "helhum/typo3-secure-web": "^0.2.7"
    },
    "extra": {
        "typo3/cms": {
            "cms-package-dir": "{$vendor-dir}/typo3/cms",
            "web-dir": "public",
            "root-dir": "private"
        },
        "helhum/typo3-console": {
            "install-extension-dummy": "0"
        }
    },
    "require-dev": {
    }
}

I'm able to reproduce this issue by installing and removing e.g. yoast_seo like this:

composer require yoast-seo-for-typo3/yoast_seo
composer remove yoast-seo-for-typo3/yoast_seo

Thx a lot for taking care!

DavidBruchmann commented 5 years ago

Having removed the personal packages from composer.json above I installed it and afterwards yoast_seo, this is what I get: image I got the same error already before but changed the running php-version to 7.2 and installation of composer.json itself went without that errors then. Don't know if it's still related to the php-version. Using Windows 10.

The reported misbehavior I can reproduce with some variation but I get a non-logical reason shown: image After removal only the extension's main-folder still exists and the according symlink, everything inside is deleted. So the error-message with the Resources folder is confusing.

helhum commented 5 years ago

I'm able to reproduce this issue by installing and removing e.g. yoast_seo like this:

I'm sorry. tried it and removing the seo extension did also remove the folder in public (on OSX)

helhum commented 5 years ago

@DavidBruchmann yes, there is indeed an issue on Windows systems, where the junction cannot be removed.

DavidBruchmann commented 5 years ago

@helhum , tried another time and still had the "Resources" folder too. Looks a bit randomly, somehow about the right timing for execution. In Windows is still the admin-account issue but I started the console as admin and symlinks can be created. So what's the issue then exactly? Is it a Windows- or a Symfony-issue? I'm not sure but might it be possible to use symlink/junction-handling from composer? It has the ability built-in too, right?

helhum commented 5 years ago

@DavidBruchmann The issue is, that on Windows junctions are created, not symlinks. These junctions point to a directory within a package that is installed via Composer.

This process happens right before Composer is done with everything (after dump autoload event).

Now when a package is removed, Composer removes the files, which leaves a Junction pointing to a not existing directory. Such Junctions cannot be removed as far as I know.

But all this is a Windows issue and not an issue on *nix systems, which the OP is claiming to use.

So let's see these a separate issues. Windows: yes there is a bug. Unix: I cannot reproduce any wrong behavior.

DavidBruchmann commented 5 years ago

Sure, don't want to confuse and mix up different issues ;-)

helhum commented 3 years ago

unable to reproduce on *nix with current version and not going to tackle for Windows System.