Skip to content

Conversation

@sreichel
Copy link
Contributor

@sreichel sreichel commented Feb 7, 2025

Description (*)

Added new helper Mage_Core_Helper_Validate that contains some wrapper methods for symfony validation.
Moved some parts of Zend_Validate_Abstract to Mage_Core_Helper_Validation_Abstract for some backwacrd compa. (may be removed later).

Related Pull Requests

Additinal notes

Password validation for customer accounts has been improved. It is not possibly anymore to use weak passwords (e.g. 12345678). See 7891569

@github-actions github-actions bot added Component: Core Relates to Mage_Core Component: Catalog Relates to Mage_Catalog Component: Checkout Relates to Mage_Checkout Component: Customer Relates to Mage_Customer Component: Eav Relates to Mage_Eav Component: Adminhtml Relates to Mage_Adminhtml Component: Api PageRelates to Mage_Api Component: Contacts Relates to Mage_Contacts Component: Admin Relates to Mage_Admin Component: Wishlist Relates to Mage_Wishlist Component: Review Relates to Mage_Review Component: Newsletter Relates to Mage_Newsletter Component: ImportExport Relates to Mage_ImportExport composer Relates to composer.json phpunit labels Feb 7, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 7, 2025

@sreichel sreichel marked this pull request as draft February 7, 2025 01:26
@Hanmac
Copy link
Contributor

Hanmac commented Feb 7, 2025

sad no symfony noises xD

Also, you might need to look at this:

@deprecated Calling `validate()` directly from rules is deprecated. Please use {@see \Respect\Validation\Validator::isValid()} instead.

@sreichel
Copy link
Contributor Author

sreichel commented Feb 7, 2025

sad no symfony noises xD

I tried, but writing rules is more intuitive with that ... imho.

Also, you might need to look at this:

@deprecated Calling `validate()` directly from rules is deprecated. Please use {@see \Respect\Validation\Validator::isValid()} instead.

I am aware of it, but latest version requies php 8.1.

@Hanmac
Copy link
Contributor

Hanmac commented Feb 7, 2025

for the current changes in this MR, Symfony Validator might be easy too.

the bigger use would be that we could validate entire objects like Customer Address at once

Also the Intl/Translation support is nice, so we could have the errors already translated by the System

@mattdavenport
Copy link
Contributor

I would be in favor of switching this to Symfony validation. Looking at this from a bigger picture, it would be best if we picked a library of components (e.g. Symfony/Laminas/etc.) and stuck to those throughout the project when replacing outdated libraries. IMO not doing this will increase the maintenance burden long term with differing packages/conventions to keep track of.

# Conflicts:
#	composer.json
#	composer.lock
@sreichel sreichel requested a review from addison74 October 26, 2025 20:58
sreichel and others added 7 commits October 26, 2025 22:08
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
# Conflicts:
#	app/code/core/Mage/Review/Model/Review.php
#	app/code/core/Mage/Wishlist/controllers/IndexController.php
#	tests/unit/Mage/Newsletter/Model/TemplateTest.php
@sreichel sreichel marked this pull request as draft October 31, 2025 20:35
if (Mage::helper('core/string')->strlen($password) < $minAdminPasswordLength) {
$errors->append(Mage::helper('adminhtml')
->__('Password must be at least of %d characters.', $minAdminPasswordLength));
$violations = new ArrayObject();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would like it if the part with the validatePassword would be put into an extra Function, easier to rewrite
(like adding extra validation rules via Modules)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

message: Mage::helper('customer')->__('Invalid email address "%s".', $email),
));

$password = $this->getPassword();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same there, I would like it to have the Password Validation in an extra Function

Maybe to not duplicate code with validateResetPassword?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice catch!

validatePassword was not finished yet to make it re-usable.

Updated validatePassword and added extra methods as suggested.

# Conflicts:
#	app/code/core/Mage/Admin/Model/Block.php
#	app/code/core/Mage/Admin/Model/Resource/User.php
#	app/code/core/Mage/Admin/Model/User.php
#	app/code/core/Mage/Admin/Model/Variable.php
#	app/code/core/Mage/Api/Model/User.php
#	app/code/core/Mage/Api2/Model/Resource/Validator/Fields.php
#	app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php
#	app/code/core/Mage/Core/Model/App.php
#	app/code/core/Mage/Core/Model/Variable.php
#	app/code/core/Mage/Customer/Model/Customer.php
#	app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php
#	app/code/core/Mage/Eav/Model/Entity/Attribute.php
#	app/code/core/Mage/Eav/Model/Entity/Setup.php
#	app/code/core/Mage/Newsletter/Model/Template.php
#	app/code/core/Mage/Oauth/Model/Consumer/Validator/KeyLength.php
#	app/code/core/Mage/Review/Model/Review.php
#	app/code/core/Mage/Widget/Model/Widget/Instance.php
#	composer.lock
@github-actions github-actions bot added the translations Relates to app/locale label Nov 3, 2025
@github-actions github-actions bot added the rector label Nov 3, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 3, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
5.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@sreichel
Copy link
Contributor Author

sreichel commented Nov 4, 2025

Working on some test, but thats hopefully ready for review.

@sreichel sreichel marked this pull request as ready for review November 4, 2025 04:18
@sreichel sreichel requested review from Hanmac and kiatng November 4, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Admin Relates to Mage_Admin Component: Adminhtml Relates to Mage_Adminhtml Component: Api PageRelates to Mage_Api Component: Api2 Relates to Mage_Api2 Component: Catalog Relates to Mage_Catalog Component: Checkout Relates to Mage_Checkout Component: Contacts Relates to Mage_Contacts Component: Core Relates to Mage_Core Component: Customer Relates to Mage_Customer Component: Dataflow Relates to Mage_Dataflow Component: Eav Relates to Mage_Eav Component: ImportExport Relates to Mage_ImportExport Component: lib/Varien Relates to lib/Varien Component: lib/* Relates to lib/* Component: Newsletter Relates to Mage_Newsletter Component: Oauth Relates to Mage_Oauth Component: Review Relates to Mage_Review Component: Widget Relates to Mage_Widget Component: Wishlist Relates to Mage_Wishlist composer Relates to composer.json cypress environment new feature phpstan PHPStorm phpunit rector translations Relates to app/locale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants