Create SYSTEM user for all Internal / Cron operations
Details
- Reviewers
alex
Preparations
In the modules\in-news\units\articles\articles_event_handler.php file replace $resource_ids[] = $category_data['ResourceId']; line with:
$resource_ids[] = $category_data['ResourceId']; $category = $this->Application->recallObject('c', null, array('skip_autoload' => true)); $category->SetDBField('l1_Name', 'Test_' . time()); $category->SetDBField('ParentId', $category_id); $category->Create();
In the core\units\categories\categories_config.php file add CreatedById field to the Default grid:
'CreatedById' => array('filter_block' => 'grid_like_filter', 'title' => 'la_fld_CreatedById'),
In the core\units\mailing_lists\mailing_lists_config.php file add PortalUserId field to the Default grid:
'PortalUserId' => Array ('filter_block' => 'grid_like_filter', 'title' => 'la_col_FromUser'),
In the core\units\spam_reports\spam_reports_config.php file add ReportedById field to the Default grid:
'ReportedById' => Array ('filter_block' => 'grid_like_filter', 'title' => 'la_col_FromUser'),
In the themes\advanced\platform\designs\default_design.des.tpl file add after <body> tag:
Created By: <inp2:st_Field name="CreatedById"/>, Modified By: <inp2:st_Field name="ModifiedById"/>.
In the modules\in-commerce\units\products\products_config.php file add CreatedByIdId field to the Default grid:
'CreatedById' => array('filter_block' => 'grid_like_filter', 'title' => 'la_fld_CreatedById'),
In the modules\in-commerce\units\orders\orders_config.php file add CreatedByIdId field to the Default & Search grids:
'PortalUserId' => Array ('filter_block' => 'grid_like_filter', 'title' => 'la_col_FromUser'),
In the tools\run_event.php comment out line:
exit_code(1, 'This script needs to be enabled manually !');
Testing (part 1 - rss feed import as "system" user and "system" user infusion via "Test_" categories for scheduled tasks)
- Go to Website & Content → Structure & Data section
- Select News category, edit its Properties tab:
- set 1 into Update Interval field
- set https://wordpress.org/news/feed/ into Source URL field
- Enable Use Cron to run Scheduled Tasks system setting in Configuration → Website → Advanced section
- Enable n:OnUpdateRSSArticles scheduled task execution in the Configuration → Website → Scheduled Tasks section
- Run php tools/cron.php
- Confirm that new automatic articles appear with Author = system
- Confirm that new categories with names Test_{some number} created under News category, and for that Test_ categories Created By = 'system'
- Disable n:OnUpdateRSSArticles scheduled task execution in the Configuration → Website → Scheduled Tasks section
Testing (part 2 - the "run_event.php" script infusion of "system" user via "Test_" categories)
- Run the php tools/run_event.php n:OnUpdateRSSArticles b674006f3edb1d9cd4d838c150b0567d in the root folder of a project
- Confirm that new categories with names Test_{some number} created under News category, and for that Test_ categories Created By = 'system'
Testing (part 3 - system log)
- Go to Tools → System Tools
- do a full cache rebuild (triggers some system log records)
- Go to Tools → Query Database section
- Run SQL like UPDATE inp_SystemLog SET LogUserId = -3;
- Go to Logs & Reports → System Log section
- Confirm that no SQL error happens
- Confirm that system value is shown in the Username column of the System Logs grid
Testing (part 4 - mailing lists)
- Go to User Management → Mailings section
- Add some record
- Go to Tools → Query Database section
- Run SQL like UPDATE inp_MailingLists SET PortalUserId = -3;
- Confirm that system value is shown in the From User column of the Mailings grid
Testing (part 5 - spam reports)
- Go to Tools → Query Database section
- Run SQL like INSERT INTO inp_SpamReports VALUES (DEFAULT, 'p', '1', 'Test', UNIX_TIMESTAMP(), '-3');
- Go to Logs & Reports → SPAM Reports section
- Confirm that system value is shown in the From User column
Testing (part 6 - categories)
- Go to Tools → Query Database section
- Run SQL like UPDATE inp_Categories SET CreatedById = -3, ModifiedById = -3 WHERE Template` = 'index';`
- Open front-end index page.
- Confirm text appeared at the top of the page: Created By: system, Modified By: system.
Testing (part 7 - system event subscriptions)
- Go to Tools → Query Database section
- Run SQL: UPDATE inp_EmailTemplates SET BindToSystemEvent = 'u:OnCreate' WHERE TemplateId = 1
- Run SQL: INSERT INTO inp_SystemEventSubscriptions (SubscriptionId, EmailTemplateId, SubscriberEmail, UserId, CategoryId, IncludeSublevels, ItemId, ParentItemId, SubscribedOn) VALUES (NULL, 1, '', '-3', NULL, '1', NULL, NULL, NULL)
- Go to User Management → User Subscriptions section
- Confirm that system value is shown in the User ID and Username columns
Testing (part 8 - orders)
- Go to E-commerce → Orders section
- Create some order
- Go to Tools → Query Database section
- Run SQL: UPDATE inp_Orders SET PortalUserId = -3
- Go to E-commerce → Orders section
- Confirm that orders have system value in the Customer Name column and that text isn't a link for user editing
Testing (part 9 - products)
- Go to Website & Content → Products section
- Create some product
- Go to Tools → Query Database section
- Run SQL: UPDATE inp_Products SET CreatedById = -3
- Confirm that products have system value in the Created By column
Diff Detail
- Repository
- rINP In-Portal
- Branch
- /in-portal/branches/5.2.x
- Lint
Lint Errors Excuse: Doing all CS fixes is not part of this task. Severity Location Code Message Error core/units/categories/categories_config.php:343 PHPCS.E.CodingStandard.Arrays.Array.SpaceAfterKeyword CodingStandard.Arrays.Array.SpaceAfterKeyword Error core/units/categories/categories_config.php:343 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found Error core/units/categories/categories_config.php:344 PHPCS.E.CodingStandard.Arrays.Array.SpaceAfterKeyword CodingStandard.Arrays.Array.SpaceAfterKeyword Error core/units/categories/categories_config.php:344 PHPCS.E.CodingStandard.Arrays.Array.SpaceAfterKeyword CodingStandard.Arrays.Array.SpaceAfterKeyword Error core/units/categories/categories_config.php:344 PHPCS.E.CodingStandard.Arrays.Array.SpaceAfterKeyword CodingStandard.Arrays.Array.SpaceAfterKeyword Error core/units/categories/categories_config.php:344 PHPCS.E.CodingStandard.Strings.ConcatenationSpacing.NoSpaceAfter CodingStandard.Strings.ConcatenationSpacing.NoSpaceAfter Error core/units/categories/categories_config.php:344 PHPCS.E.CodingStandard.Strings.ConcatenationSpacing.NoSpaceAfter CodingStandard.Strings.ConcatenationSpacing.NoSpaceAfter Error core/units/categories/categories_config.php:344 PHPCS.E.CodingStandard.Strings.ConcatenationSpacing.NoSpaceBefore CodingStandard.Strings.ConcatenationSpacing.NoSpaceBefore Error core/units/categories/categories_config.php:344 PHPCS.E.CodingStandard.Strings.ConcatenationSpacing.NoSpaceBefore CodingStandard.Strings.ConcatenationSpacing.NoSpaceBefore Error core/units/categories/categories_config.php:344 PHPCS.E.CodingStandard.WhiteSpace.CommaSpacing.After CodingStandard.WhiteSpace.CommaSpacing.After Error core/units/categories/categories_config.php:344 PHPCS.E.Generic.PHP.LowerCaseConstant.Found Generic.PHP.LowerCaseConstant.Found Error core/units/categories/categories_config.php:344 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found Error core/units/categories/categories_config.php:344 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found Error core/units/categories/categories_config.php:344 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found Error core/units/categories/categories_config.php:345 PHPCS.E.CodingStandard.Arrays.Array.SpaceAfterKeyword CodingStandard.Arrays.Array.SpaceAfterKeyword Error core/units/categories/categories_config.php:345 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found Error core/units/categories/categories_config.php:355 PHPCS.E.CodingStandard.Arrays.Array.SpaceAfterKeyword CodingStandard.Arrays.Array.SpaceAfterKeyword Error core/units/categories/categories_config.php:355 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found Error core/units/categories/categories_config.php:356 PHPCS.E.CodingStandard.Arrays.Array.SpaceAfterKeyword CodingStandard.Arrays.Array.SpaceAfterKeyword Error core/units/categories/categories_config.php:356 PHPCS.E.CodingStandard.Arrays.Array.SpaceAfterKeyword CodingStandard.Arrays.Array.SpaceAfterKeyword Error core/units/categories/categories_config.php:356 PHPCS.E.CodingStandard.Arrays.Array.SpaceAfterKeyword CodingStandard.Arrays.Array.SpaceAfterKeyword Error core/units/categories/categories_config.php:356 PHPCS.E.CodingStandard.WhiteSpace.CommaSpacing.After CodingStandard.WhiteSpace.CommaSpacing.After Error core/units/categories/categories_config.php:356 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found Error core/units/categories/categories_config.php:356 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found Error core/units/categories/categories_config.php:356 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found - Unit
No Unit Test Coverage - Build Status
Buildable 1030 Build 1030: arc lint + arc unit
Event Timeline
core/kernel/managers/scheduled_task_manager.php | ||
---|---|---|
119–120 |
| |
core/kernel/session/session.php | ||
1126–1129 | Since you're at this line please do minimal CS fixing. | |
core/kernel/utility/temp_handler.php | ||
1064–1075 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
core/units/helpers/page_helper.php | ||
79 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
core/units/logs/change_logs/change_logs_config.php | ||
88 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
core/units/logs/session_logs/session_logs_config.php | ||
100 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
core/units/logs/system_logs/system_logs_config.php | ||
89 | For every change like this please update the test plan to include visiting the corresponding section with a non-empty grid to allow checking, that there is no SQL error. | |
core/units/mailing_lists/mailing_lists_config.php | ||
106 | For every change like this please update the test plan to include visiting the corresponding section with a non-empty grid to allow checking (faking DB field value in PMA to have -3 is perfectly fine to see if the "system" word is actually displayed), that there is no SQL error. | |
core/units/page_revisions/page_revisions_config.php | ||
97 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
core/units/reviews/reviews_config.php | ||
61–77 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
134 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
core/units/visits/visits_config.php | ||
89 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
92 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
modules/in-bulletin/units/poll_comments/poll_comments_config.php | ||
67 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
88 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
modules/in-commerce/units/affiliates/affiliates_config.php | ||
200 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
modules/in-commerce/units/coupons/coupons_config.php | ||
123 ↗ | (On Diff #991) | Please revert. The "system" user can't log in to perform such an activity. |
tools/run_event.php | ||
42 | Add tests to confirm, that this user is actually used, e.g. event that creates a record owned by a currently logged-in user should use a system user. |
core/units/reviews/reviews_config.php | ||
---|---|---|
61–77 ↗ | (On Diff #991) |
|
Made QA changes, extended test plan.
Need more test plan writing beyond core and in-commerce modules.
core/units/reviews/reviews_config.php | ||
---|---|---|
61–77 ↗ | (On Diff #991) | Translating:
|
Tested/improved current test plan. Please keep adding new test plan parts for non-tested code (in the modules) so that I can continue reviewing this task.