SOF3 / pharynx

A tool to recompile PHP sources into a phar in PSR-0
Apache License 2.0
16 stars 3 forks source link

Plugins defined in "PLUGIN PATHS" being overwritten #17

Closed Nexus9w9 closed 10 months ago

Nexus9w9 commented 10 months ago

I've been trying to use the compilation option for my plugins using the ./start.sh option but I realize that when I indicate 2 directories or more, the plugin is overwritten by the other one because of their identical names.

How to reproduce the error:

Open ./start.sh and enter two paths, start ./start.sh and see that one plugin is replaced by the other because their names are the same.

Nexus9w9 commented 10 months ago

Apparently this is a typo, here is the corrected compile_plugin function.

compile_plugin() {
    for index in ${!PLUGIN_PATHS[@]}; do
        export PHP_BINARY PHARYNX_PATH
        export PLUGIN_PATH="${PLUGIN_PATHS[$index]}"
        local COMPOSER=""
        if [[ -f "${PLUGIN_PATH}/composer.json" ]]; then
            COMPOSER="-c"
        fi
        "$PHP_BINARY" -dphar.readonly=0 "$PHARYNX_PATH" $COMPOSER -i "$PLUGIN_PATH" -p=plugins/pharynx-output-${index}.phar

        if [[ ! -f "${PLUGIN_PATH}/composer.json" ]]; then
            "$PHP_BINARY" -dphar.readonly=0 "$DIR"/bootstrap-plugin-dev.php plugins/pharynx-output-${index}.phar
        fi
    done
}
SOF3 commented 10 months ago

Please open a pull request if you find the correct option but I don't understand, why would you have two plugins with the same name?

Nexus9w9 commented 10 months ago

I expressed myself wrongly. In fact, the problem lies in the way the for loop's index variable is being used, which results in all plugins having the same name. The variable used does not exist.

Nexus9w9 commented 10 months ago

How to open a pull request for a file that is in a release?

SOF3 commented 10 months ago

@Nexus9w9 the file is in the repo under the plugin-dev directory

SOF3 commented 10 months ago

https://github.com/SOF3/pharynx/blob/master/plugin-dev/start.sh