Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different modules with same file name #11775

Open
punitkumar opened this issue Oct 4, 2022 · 10 comments
Open

Different modules with same file name #11775

punitkumar opened this issue Oct 4, 2022 · 10 comments

Comments

@punitkumar
Copy link

What version of OpenCart are you reporting this for?

Opencart4x

Describe the bug
When two different modules use same file name then there are conflicts like, installing 1st module will also show 2nd module get installed whereas in actual it does not.
Uninstalling any one of two show both modules uninstalled.

To Reproduce
Steps to reproduce the behavior:
Download attached module files and install it on Opencart 4.0.1.1

  1. See error in video https://www.loom.com/share/cbb6282697a1417aad0394a5c1ff2853

Expected behavior
Both modules get installed indecently and functional normally.

two_modules_same_file_name.zip

@danielkerr
Copy link
Member

well the idea is the ext devs would create some unique naming.

so example dreamvention doing their own paypal extension could do dv_paypal

@mhcwebdesign
Copy link
Collaborator

Well, that's why I suggested ages ago to have the extension name included in the install.json file, and not rely on the base file name for the extension folder name.

@danielkerr
Copy link
Member

its not the same thing

@andresjavierpf
Copy link

Well, I think that behavior is a problem because it shouldn't happen. Each extension lives in a different namespace and that allows you to have the same file name (even class) even if they are different extensions.

I see the problem in the way the extensions are being loaded. Example: in the case of the modules, all the paths of the module controllers are being loaded from the DB but only the file name of the controller is being taken into account to identify the module. As there are 2 extensions that have 2 controllers with the same name there is a conflict because currently there is no way to differentiate which module belongs to each extension and it is also losing one of the advantages of namespaces. Here the solution I propose is that instead of just taking the filename of the controller ($available[] = basename($result['path'], '.php');) also take into account the extension code as a prefix:
oc_file_module1_file.php
oc_file_module2_file.php

oc_file_module1 and oc_file_module2 are the name or code of each extension.

@danielkerr
Copy link
Member

@mhcwebdesign does not make a fucking bit of difference, and u sound like a fucking broken clock keep repeating the same mantra.

@danielkerr
Copy link
Member

i think put a block on extension using the same code

@stalker780
Copy link
Contributor

@danielkerr No need to put any blocks.
An only issue is that module settings do not contain extension code in setting table.
Furthermore different developers can eventually call their modules the same name.

opencart\payment\cheque has the same setting names as myext\payment\cheque
for example $this->config->get('payment_cheque_status').
And this is hardcoded in admin and catalog controllers.

You just need to add extension code everywhere before module code.
$this->config->get('payment_opencart_cheque_status')
$this->config->get('payment_myext_cheque_status')

@danielkerr
Copy link
Member

maybe setup the installer to remove any other extension witht he same code.

@stalker780
Copy link
Contributor

@danielkerr We are talking not about extension code, but about module codes inside extensions.

Extensions codes must be unique.

But developers are asking here to allow using same modules names inside extension.

Any developer can call their module for example 'blog'.

So there will be a conflict if OC have myext.blog and anotherext.blog

@danielkerr
Copy link
Member

same with the modules inside

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants