In-Portal Issue Tracker - In-Portal CMS
Viewing Issue Advanced Details
239 [In-Portal CMS] Optimization task always 2009-08-24 03:20 2010-01-11 22:05
alex  
alex  
normal  
closed 5.0.0  
fixed  
 
none 5.0.2-B1  
0
0000239: Replace "kApplication::IsAdmin" method with "kApplication::isAdmin" class attribute
Currently "kApplication::IsAdmin" method only checks for ADMIN constant and it's value. This method is called almost at every script run. I propose to add "isAdmin" class variable and calculate it's value on application initialization and get rid of this method. This should boost performance in cases, where this method is called in loops.
patch is admin refactoring.patch (101,683) 2009-10-06 10:47
http://tracker.in-portal.org/file_download.php?file_id=77&type=bug
Issue History
2010-01-11 22:05 Dmitry Note Added: 0001367
2010-01-11 22:05 Dmitry Status resolved => closed
2009-10-23 09:03 alex Changeset attached r12775
2009-10-23 01:48 alex Changeset attached 5.0.x r12774
2009-10-23 01:48 alex Note Added: 0000947
2009-10-23 01:48 alex Fixed in Version 5.0.2 => 5.0.2-B1
2009-10-20 10:31 alex Note Added: 0000938
2009-10-20 10:31 alex Status reviewed and tested => resolved
2009-10-20 10:31 alex Fixed in Version => 5.0.2
2009-10-20 10:31 alex Resolution open => fixed
2009-10-20 10:31 alex Changeset attached 5.0.x r12726
2009-10-20 10:27 alex Changeset attached 1.0.x r12725
2009-10-20 10:26 alex Changeset attached 5.0.x r12724
2009-10-20 10:14 alex Changeset attached 5.0.x r12723
2009-10-20 10:12 alex Changeset attached 5.0.x r12722
2009-10-20 09:49 alex Changeset attached 5.0.x r12721
2009-10-20 09:46 alex Changeset attached 5.0.x r12720
2009-10-18 00:52 Dmitry Assigned To !COMMUNITY => alex
2009-10-18 00:52 Dmitry Status needs testing => reviewed and tested
2009-10-18 00:52 Dmitry Note Added: 0000906
2009-10-06 14:24 alex Type bug report => task
2009-10-06 10:50 alex Time Estimate Removed 3 =>
2009-10-06 10:50 alex Note Added: 0000824
2009-10-06 10:50 alex Assigned To alex => !COMMUNITY
2009-10-06 10:50 alex Status active => needs testing
2009-10-06 10:47 alex File Added: is admin refactoring.patch
2009-10-03 07:52 administrator Status reviewed and tested => active
2009-09-30 06:59 alex Assigned To andrew => alex
2009-09-30 06:58 alex Status active => reviewed and tested
2009-09-30 06:58 alex Assigned To => andrew
2009-09-23 13:16 alex Time Estimate Added 3
2009-09-23 13:16 alex Note Added: 0000531
2009-09-20 15:11 alex Target Version 5.1.0 => 5.0.2
2009-08-24 11:15 Dmitry Target Version => 5.1.0
2009-08-24 03:20 alex New Issue

Notes
(0000531)
alex   
2009-09-23 13:16   
Plan:
1. 74 files with IsAdmin usage, check them all and be sure, that new kApplication::isAdmin class variable is defined before it will be used, otherwise it will result to incorrect admin detection.
(0000824)
alex   
2009-10-06 10:50   
Added two properties:
kApplication::isAdmin - checks, that "admin/index.php" is used (as before)
kApplication::isAdminUser - checks that that "admin/index.php" is used and user is logged in.

How to use/upgrade your code:

All front-end limitation filters in SetCustomQuery method should also be added while admin is not logged in!

* $this->Application->IsAdmin() becomes $this->Application->isAdminUser;
* !$this->Application->IsAdmin() becomes $this->Application->isAdmin;
(0000906)
Dmitry   
2009-10-18 00:52   
Tested ok, but you'll need to adjust your patch due to changes in 5.0.x occurred after the patched was produced, in core/kernel/processors/main_processor.php file (line 603):

I have replaced " elseif ($this->Application->IsAdmin()) { " with corresponding ->IsAdmin


Part from the patch:

Index: core/kernel/processors/main_processor.php
===================================================================
--- core/kernel/processors/main_processor.php (revision 12650)
+++ core/kernel/processors/main_processor.php (working copy)


@@ -599,7 +599,7 @@
                 $module_prefix = $module_data['TemplatePath'];
             }
             else {
- $module_prefix = $this->Application->IsAdmin() ? $module_key.'/' : rtrim($module_data['TemplatePath'], '/').'/';
+ $module_prefix = $this->Application->isAdmin ? $module_key.'/' : rtrim($module_data['TemplatePath'], '/').'/';
             }
 
             $block_params['t'] = $module_prefix.$this->SelectParam($params, $module_key.'_template,'.$module_key.'_t,template,t');
(0000938)
alex   
2009-10-20 10:31   
Fix committed to 5.0.x branch. Commit Message:

Fixes 0000239: Replace "kApplication::IsAdmin" method with "kApplication::isAdmin" class attribute
(0000947)
alex   
2009-10-23 01:48   
Fix committed to 5.0.x branch. Commit Message:

1. Fixes 0000239: Replace "kApplication::IsAdmin" method with "kApplication::isAdmin" class attribute
2. Forgot to commit modules_helper.php
(0001367)
Dmitry   
2010-01-11 22:05   
Closing completed tasks.