-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix: Banner clients accept duplicates #46239
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
base: 5.4-dev
Are you sure you want to change the base?
Fix: Banner clients accept duplicates #46239
Conversation
… duplicate record in Component -> Banners -> Clients
This is obviously not correct. With this pr you can never Save as copy so why keep the button. Please look at how Save as copy works elsewhere! |
Thanks for the feedback, @brianteeman. I see your point now — my current PR prevents Save as Copy from working as intended. I’ll update the PR so that: Save / Save & Close still prevent duplicates. Save as Copy will create a copy automatically, appending a suffix like it works if a client with the same name exists. This should fix the original issue while keeping Joomla’s copy functionality intact. I’ll push an updated version soon. |
… duplicate record in Component -> Banners -> Clients
/** | ||
* Override save to prevent duplicate client names when saving as copy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* Override save to prevent duplicate client names when saving as copy. | |
/** | |
* Override save to prevent duplicate client names when saving as copy. |
* | ||
* @return boolean True on success, false on failure. | ||
* | ||
* @since 5.3.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @since 5.3.5 | |
* @since __DEPLOY_VERSION__ |
|
||
|
||
|
||
/** | ||
* Generate a unique client name if it already exists. | ||
* | ||
* @param string $name The original client name | ||
* | ||
* @return string Unique client name | ||
*/ | ||
protected function generateUniqueName($name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* Generate a unique client name if it already exists. | |
* | |
* @param string $name The original client name | |
* | |
* @return string Unique client name | |
*/ | |
protected function generateUniqueName($name) | |
/** | |
* Generate a unique client name if it already exists. | |
* | |
* @param string $name The original client name | |
* | |
* @return string Unique client name | |
* @since __DEPLOY_VERSION__ | |
*/ | |
protected function generateUniqueName($name) |
@harshkhatri8 When you create a PR you should check how your changes look on GitHub: https://github.com/joomla/joomla-cms/pull/46239/files . Then you would see it has a bunch of code style issues. |
} | ||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the 4 empty lines 189 to 192.
COM_BANNERS_WARNING_PROVIDE_VALID_NAME="Please provide a valid, non-blank name" | ||
COM_BANNERS_XML_DESCRIPTION="This component manages banners and banner clients." | ||
COM_BANNERS_CLIENT_ERROR_DUPLICATE_NAME="A client with this name already exists." | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review, @richard67!
I’ve applied all your suggested code style changes — fixed the docblocks, removed extra blank lines, and added @SInCE DEPLOY_VERSION.
The PR has been updated and is ready for another review. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Language key should be in alpha order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @QuyTon!
I made all the suggested changes. Please check it and provide a feedback.
…extra blank lines, and added @SInCE DEPLOY_VERSION
use Joomla\CMS\MVC\Model\AdminModel; | ||
use Joomla\CMS\Table\Table; | ||
use Joomla\CMS\Versioning\VersionableModelTrait; | ||
use Joomla\CMS\Language\Text; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Joomla\CMS\MVC\Model\AdminModel; | |
use Joomla\CMS\Table\Table; | |
use Joomla\CMS\Versioning\VersionableModelTrait; | |
use Joomla\CMS\Language\Text; | |
use Joomla\CMS\Language\Text; | |
use Joomla\CMS\MVC\Model\AdminModel; | |
use Joomla\CMS\Table\Table; | |
use Joomla\CMS\Versioning\VersionableModelTrait; |
Sort alpha order.
} | ||
|
||
|
||
|
||
/** | ||
* Generate a unique client name if it already exists. | ||
* | ||
* @param string $name The original client name | ||
* | ||
* @return string Unique client name | ||
* @since __DEPLOY_VERSION__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
/** | |
* Generate a unique client name if it already exists. | |
* | |
* @param string $name The original client name | |
* | |
* @return string Unique client name | |
* @since __DEPLOY_VERSION__ | |
} | |
/** | |
* Generate a unique client name if it already exists. | |
* | |
* @param string $name The original client name | |
* | |
* @return string Unique client name | |
* @since __DEPLOY_VERSION__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @QuyTon!
I made all the suggested changes. Please check it and provide a feedback.
… suggested change
COM_BANNERS_UNLIMITED="Unlimited" | ||
COM_BANNERS_WARNING_PROVIDE_VALID_NAME="Please provide a valid, non-blank name" | ||
COM_BANNERS_XML_DESCRIPTION="This component manages banners and banner clients." | ||
COM_BANNERS_CLIENT_ERROR_DUPLICATE_NAME="A client with this name already exists." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move language key in alpha order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is also done now you can check it.
This pull request has been automatically rebased to 5.4-dev. |
Pull Request for Issue #45603
Fixes #45603
Summary of Changes
-Updated ClientModel.php to prevent duplicate client names when using Save as Copy.
-Implemented automatic unique name generation: if a client with the same name exists, the system appends (2), (3), etc.
-Preserves the original Save as Copy functionality without breaking existing save operations.
Testing Instructions
-Go to Components → Banners → Clients in Joomla Administrator.
-Select an existing client,.
-Click Save as Copy multiple times.
-Verify that each new client is created with a unique name:
-Confirm that no duplicates are created in the database and all other save functionality works as expected.
Actual result BEFORE applying this Pull Request
-Clicking Save as Copy creates a client with the same name as the original, allowing duplicates.
Expected result AFTER applying this Pull Request
-Clicking Save as Copy automatically generates a unique client name, preventing duplicates while preserving the copy functionality.
Link to documentations
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed