Skip to content

removed country_id#14713

Merged
danielkerr merged 1 commit intoopencart:masterfrom
farshadfmr:master
Mar 22, 2025
Merged

removed country_id#14713
danielkerr merged 1 commit intoopencart:masterfrom
farshadfmr:master

Conversation

@farshadfmr
Copy link
Copy Markdown
Contributor

removed country_id from the function as it was unnecessary.

@TheCartpenter
Copy link
Copy Markdown
Contributor

By doing that, you'll be crashing the delete countries and delete zones from both controllers, since the $country_id and $zone_id are both required during the foreach loop.

@farshadfmr
Copy link
Copy Markdown
Contributor Author

farshadfmr commented Mar 22, 2025

These two function are only used here:
opencart\upload\admin\model\localisation\language.php
$this->model_localisation_language->deleteLanguage($language_id);
It is just a bug since the deleteLanguage function only has one param.
You must have mistaken it with deleteDescriptions function.

@TheCartpenter
Copy link
Copy Markdown
Contributor

@TheCartpenter
Copy link
Copy Markdown
Contributor

As for the zones, not sure if this has been modified because it was unnecessary, since the deleteDescriptionsByLanguageId method is still in-use...

@mhcwebdesign
Copy link
Copy Markdown
Contributor

mhcwebdesign commented Mar 22, 2025

See also this issue: #14715
I think your pull request should work.

@TheCartpenter
Copy link
Copy Markdown
Contributor

Won't work without removing the $country_id from the controller.

@TheCartpenter
Copy link
Copy Markdown
Contributor

TheCartpenter commented Mar 22, 2025

It will also affect all the countries from the controller when the language ID will only be parametered to delete and, surely, it's not what we want to happen.

@farshadfmr
Copy link
Copy Markdown
Contributor Author

farshadfmr commented Mar 22, 2025

Issue: #14715 will be fixed with this edit, however this function (https://github.com/opencart/opencart/blob/master/upload/admin/controller/localisation/country.php#L499) will crash.

I think it needs more work for (https://github.com/opencart/opencart/blob/master/upload/admin/controller/localisation/country.php#L499) because I cannot understand why we should skip the hard-coded "en-gb" for removing a country, while its other translations would be deleted without a warning.
I can apply another fix for it by changing the params as (int language_id, int country_id = 0) but I believe it needs more work.

What I mean is that we are deleting a country and we are already checking whether its set to anything or not. So, if it passes the checks we can remove it including all languages related to that country. So why keep the 'en-gb'?

@TheCartpenter
Copy link
Copy Markdown
Contributor

Because en-gb is the default language of the platform and deleting that language would require manual re-insert for people who may want to reuse that language if not ending up doing a fresh install all over again. As for setting up a headsup for other languages, that could be ideal though.

@danielkerr danielkerr merged commit b9fa59d into opencart:master Mar 22, 2025
@farshadfmr
Copy link
Copy Markdown
Contributor Author

farshadfmr commented Mar 22, 2025

Ok I just checked https://github.com/opencart/opencart/blob/master/upload/admin/controller/localisation/country.php#L499. It has more issues at the moment than we anticipated. some functions needs to get renamed eg:
$zone_to_geo_zone_total = $this->model_localisation_geo_zone->getTotalZoneToGeoZoneByCountryId($country_id)
to
$zone_to_geo_zone_total = $this->model_localisation_geo_zone->getTotalZonesByCountryId($country_id);

Furthermore, I believe that when deleting a country, all its related languages must be also removed. If people plan to re-use the deleted country they must manually re-insert its information. Opencart is not responsible for keeping track of deleted information by user. Also another reason for this, is that when the language of admin section is other than 'en-gb', then the country will not be deleted completely and when the user tries to edit it, no information would be set in the form fields because the getCountry function relies on the language of admin (which is as of this example other than (en-gb).

@farshadfmr
Copy link
Copy Markdown
Contributor Author

farshadfmr commented Mar 22, 2025

I just fixes some of these bugs with the new edits:
#14718

The skipping of 'en-gb' unchanged.

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

Successfully merging this pull request may close these issues.

4 participants