Page MenuHomeIn-Portal Phabricator

INP-1757 - Replace "each" function usage with equivalent code

Authored by erik on Jun 21 2021, 11:49 AM.


Test Plan
  1. Login as administrative user to the adm.console
  2. Go to Website & ContentStructure & Data section
  1. Edit some category, edit category Description field using CKEditor, confirm that image upload in CKEditor works fine. (That is test for changes in core/ckeditor/ckfinder/core/connector/php/php5/Core/Config.php)
  2. No normal tests for changes in core/ckeditor/ckfinder/core/connector/php/php5/Utils/Security.php, because get_magic_quotes_gpc() always return false and changed code is never called. Comment "if" condition (line 35 and line 52). Set debugger breakpoints in the line 73 of core/ckeditor/ckfinder/core/connector/php/connector.php (getRidOfMagicQuotes call). Debug after pressing "Browse Server" button in CKEditor. Confirm, that $_GET variable is recursively iterated and "stripslashes" function is applied to each it's data element.

CKEditor's "Browse Server" button leads to changed places in
core/ckeditor/ckfinder/core/connector/php/php5/Utils/Security.php (need remove if condition with "get_magic_quotes_gpc()" to execute changed code in Security.php)

Changes in core/install.php - may be invoked when upgrading from some old version, after pressing "Continue" button on
"Select Modules to Upgrade" step.

Changes in core/kernel/db/cat_event_handler.php

  1. event OnSaveSettings may be invoked from Tools > Import Data, when pressing folder icin-button in the "Import Section:: row.
  2. method _getPermissionCheckInfo in changed part may be invoked when creating new product with non-root admin user, after pressing "Save" button.

Changes in core/kernel/db/db_event_handler.php

  1. event OnValidateField is invoked when on front-end, in advanced theme, registered user edits form fields in the My Profile form (platform/my_account/my_profile.html)
  2. to debug change in AddFilters, add filter on any column in any adm.comsole grid (for example, Order = 1 in the Structure & Data -> Sections), and then reload page, containing grid
  3. OnCreate - Edit any Category, open form to add Category image on Images tab, debug on Save button click
  4. OnSelectUser - comment out function processUserSelector in the form_blocks.tpl, edit any Category, open user selector for Created By Field, debug on Save button click in user selector popup

Change in core/units/categories/categories_event_handler.php - login as non-root in adm.console, check some category in Structure & Data -> Sections grid, debug on Approve button click

Changes in core/units/content/content_eh.php

  • both changed places are debuggable from one place - open any content block to edit in Browse Website -> Content Mode. Debug on Save button click.

Change in core/units/email_templates/email_template_eh.php - do not see and can't imagine where this may be used. Change is in OnSelectUser method. There are no fields, containing user Id in this unit configuration. This is working only with "module" special. I do not see where this email-template unit is used with "module" special.

Change in core/units/helpers/brackets_helper.php - Go to E-Commerce -> Affiliates -> Affiliate Plans. Open form to Add affiliate plan. Press "More Brackets" button. Debug on "Save" button click.

Change in core/units/helpers/captcha_helper.php. To debug make changes:

  1. Configuration -> Users -> General -> Use Captcha code on Registration - make checkbox on.
  2. users_event_handler.php - change second parameter in this line "$captcha_helper->validateCode($event, false);" to be true.

Debug on submit front-end user registration form - platform/login/register.html

Changes in core/units/helpers/cat_dbitem_export_helper.php - both changes are debuggable on run export (Save button click) in adm.console Website & Content -> Structure & Data -> Products -> Tools (toolbar button) -> Export

Change in core/units/helpers/controls/minput_helper.php - Website & Content - Email Temolates -> edit some template -> Settings tab, debug on "Add" button click under "Recipient's Name" field.

Change in core/units/helpers/file_helper.php - User Management -> Users, debug click on toolbar Edit button with any user checked.

Changes in core/units/helpers/search_helper.php - all 3 changed places are debuggable by setting any filter in the Management -> Users grid and click Search toolbar button. First two changes - in the request, directly produced by Search button click. Third change - after redirect.

Changes in core/units/languages/languages_event_handler.php -

  1. Configuration ->Website -> Regional - click Import button, debug for submit of import form - place in OnImportLanguage method.
  2. Configuration ->Website -> Regional - choose language, click Export button, debug for submit of export form -

place in OnExportProgress method.

Change in core/units/reviews/reviews_event_handler.php - in adm.console edit product, go on comments tab, edit some comment, debug on comment save button click.

core/units/selectors/selectors_event_handler.php - can't test now, because missing section and tables for related unit (unfinished development).

Change in core/units/theme_files/theme_file_eh.php - go to Browse Website -> Design Mode. Find some block with design, open template_edit form by pressing "Edit Design" button, appearing on block mouseover. Debug "Save" button click of template_edit form.

Change in core/units/user_profile/user_profile_eh.php - on front-end, with logged in-user, go to page platform/my_account/my_preferences.html. Debug click on "Update" button under "My Preferences" form.

Changes in core/units/users/users_event_handler.php -

  1. in OnUpdateAddress - not used in base system. Log in on front-end and use link like index.php?env=u-4---OnUpdateAddress-&u[4][FirstName]=Erik, where 4 is logged user id to debug
  2. in OnRefreshForm - go to Configuration -> E-commerce -> General. Make "Allow registration as affiliate" option checked. On front end open registration form platform/login/register.html and debug click on "Become an Affiliate" checkbox.
  3. in OnUpdatePassword - login to adm.console as non-root user. Open password change form (click on username link in header). Debug on "Save" button click.

Change in modules/in-commerce/units/coupons/coupons_event_handler.php - go to E-commerce -> Discounts & Certificates -> Coupons. Create coupon. Check it in the grid and click "Clone" button. Debug on "Save" button click in the opened "Cloning a Coupon" form.

Changes in modules/in-link/units/listings/listings_event_handler.php - login on front-end. Go to directory/in-link/links/suggest_link.html, debug on "Create" button click in the "Suggest Link" form.
First change (in the OnRequestEnhancement method) is debuggable when In-Commerce module is active.
Second change (in the OnListingCreate method) is debuggable when In-Commerce module is not active.

Changes in modules/in-commerce/units/orders/orders_event_handler.php

  1. in the setBillingAddress method debug with NOT logged in user click on "Same As Shipping Address" checkbox on checkout billing step (tangible item must be in shopping cart)
  2. in the OnProceedToBilling method and 3) in the SetStepRequiredFields method - both debuggable on front-end checkout, when clicking on "Proceed to Billing" button

Change in modules/in-commerce/units/pricing/pricing_event_handler.php - go to Website & Content -> Products. Edit product -> Pricing tab. Debug on "Arrange" toolbar button click.

Change in modules/in-commerce/units/product_option_combinations/product_option_combinations_event_handler.php - go to Website & Content -> Products. Edit product -> Options tab -> Link "Open" for "Manage Options Combinations". Debug click "Add" button on "Managing Option Combinations" form.

Change in modules/in-commerce/units/products/products_event_handler.php - go to Website & Content1 -> Products. Edit product -> Options tab -> Link "Open" for "Manage Options Combinations". Create some options combinations and make them available. Go to Inventory tab. Select "By Product Options" option. Choose some combination in the bottom grid, input some quantity and debug for "Add" button click.

Changes in modules/in-commerce/units/taxes/taxes_tag_processor.php (2 places)

  1. add state RIO to Brazil country in the Countries & States section. Go to E-Commerce -> Taxes, add tax, select "By State" Type, Select "Canada" state. While Add Tax popup is open, go to Countries & States section and delete RIO state. In the Add tax popup debug on change Dropdown with countries value from Canada to Brazil.
  2. open Add Tax popup, debug on "By State" radio button click

Change in modules/in-commerce/units/shipping_quote_engines/usps.php - enable usps shipping type, go to some order shipping tab. Clear system cache (to delete possible cached shipping quotes). Debug on order shipping tab refresh.

Changes in modules/in-commerce/units/zones/zones_tag_processor.php

  1. add state RIO to Brazil country in the Countries & States section. Go to E-Commerce -> Shipping -> Custom Shipping Types, Edit some shipping type. Go to Shipping Zones tab, add shipping zone, select "By State" Type, Select "Canada" state. While Adding Shipping Zone popup is open, go to Countries & States section and delete RIO state. In the Adding Shipping Zone popup debug on change Dropdown with countries value from Canada to Brazil.
  2. open Add Shipping Zone popup, debug on "By State" radio button click

Diff Detail

rINP In-Portal
Lint ErrorsExcuse: Full code style fixing is not part of this task.
No Unit Test Coverage
Build Status
Buildable 1047
Build 1047: arc lint + arc unit

Event Timeline

erik created this revision.Jun 21 2021, 11:49 AM
erik requested review of this revision.Jun 21 2021, 11:49 AM
erik edited the test plan for this revision. (Show Details)Jun 21 2021, 1:18 PM
erik edited the test plan for this revision. (Show Details)Jun 23 2021, 1:57 PM
erik edited the test plan for this revision. (Show Details)Jun 29 2021, 5:59 AM
erik edited the test plan for this revision. (Show Details)Jun 30 2021, 5:56 AM
erik edited the test plan for this revision. (Show Details)Jul 2 2021, 3:05 AM
erik edited the test plan for this revision. (Show Details)Jul 12 2021, 5:57 AM
erik edited the test plan for this revision. (Show Details)Jul 13 2021, 5:57 AM
erik edited the test plan for this revision. (Show Details)Jul 14 2021, 5:56 AM
erik edited the test plan for this revision. (Show Details)Jul 15 2021, 6:10 AM
erik edited the test plan for this revision. (Show Details)Jul 16 2021, 2:18 AM
alex requested changes to this revision.EditedJul 26 2021, 7:42 AM

I've counted only ~30 places instead of 44 requested places. Please locate other places (likely coming from other modules), that require fixing using the Find Usages feature of the PhpStorm applied to any each function usage occurrence (see.

Also, update the test plan to include instructions about locating added code reflection in UI.

This revision now requires changes to proceed.Jul 26 2021, 7:42 AM
erik edited the test plan for this revision. (Show Details)Jul 28 2021, 1:51 PM
erik edited the test plan for this revision. (Show Details)Jul 29 2021, 6:22 AM
erik edited the test plan for this revision. (Show Details)Jul 29 2021, 1:46 PM
erik edited the test plan for this revision. (Show Details)Aug 4 2021, 5:59 AM
erik edited the test plan for this revision. (Show Details)Aug 5 2021, 1:51 PM
erik updated this revision to Diff 1025.Aug 5 2021, 1:59 PM
erik edited the test plan for this revision. (Show Details)

Done requested changes in all other modules

alex requested changes to this revision.Aug 26 2021, 11:20 AM
alex added inline comments.

Remove $_key => part (note space at the end).

Variable wasn't used before and isn't used now.



Looking through the changes the \PricingEventHandler::OnArrangeBrackets method, doing a similar thing, caught my attention. After that, it became obvious, that both variables are just a copy/paste artifact and are no longer needed.


Replace $id with $item_id.

Code below relying on the $item_id variable value became broken.



This revision now requires changes to proceed.Aug 26 2021, 11:20 AM
erik updated this revision to Diff 1027.Aug 27 2021, 9:31 AM
erik marked 4 inline comments as done.

Made all requested fixes

alex accepted this revision.Aug 31 2021, 2:40 AM
This revision is now accepted and ready to land.Aug 31 2021, 2:40 AM
This revision was landed with ongoing or failed builds.Aug 31 2021, 4:24 AM
This revision was automatically updated to reflect the committed changes.