User tests: Successful: Unsuccessful:
Explanation per files:
components/com_users/models/profile.php
Do not call more than once $this->loadFormData() which call getItem()
and preprecessData()
each time. getItem()
should not trigger onContentPrepareData
. The events should be triggered in preprocessData()
only.
administrator/components/com_users/models/user.php
getItem()
is call twice in legacy view:
view::get('Item');
view::get('form');
so cache it and do not run twice the same code (2 sql queries twice = 4 queries)
Replace ->where($db->qn('id') . ' = ' . $db->q($user_id));
to ->where($db->qn('id') . ' = ' . (int) $user_id);
which will be the same as in Juser class.
This is for mysql which can cache the query if it has the same text.
onContentPrepareData
more than once.At the top of method onContentPrepareData
line ~ 61:
echo "<p><b>onContentPrepareData<b> was run with context $context from<br><code>";
array_walk(debug_backtrace(false),create_function('$a,$b','echo "{$a[\'function\']}()(".$a[\'file\'].":{$a[\'line\']}); ";'));
echo "</code></p>";
and at the top if method onContentPrepareForm
line ~ 233:
echo "<p><b>onContentPrepareForm<b> was run from<br><code>";
array_walk(debug_backtrace(false),create_function('$a,$b','echo "{$a[\'function\']}()(".$a[\'file\'].":{$a[\'line\']}); ";'));
echo "</code></p>";
This way we can see how many times that methods is run.
This PR reduce calls method onContentPrepareData.
Login and go to profile view /index.php?option=com_users&view=profile
You should see:
Edit file /libraries/legacy/controller/legacy.php
and comment line 947 as:
//$app->redirect($this->redirect);
Uncomment line from point 7)
Back to backend to /administrator/index.php?option=com_patchtester
Search for 9325 or "User Profile - remove redundant event trigger onContentPrepareData"
Then apply that patch.
Go to profile view /index.php?option=com_users&view=profile
You should see now:
Comment line from point 7)
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Code style |
Category | Code style | ⇒ | Code style Components Libraries |
Category | Code style Components Libraries | ⇒ | Administration Components Front End Libraries Code style |
Title |
|
Title |
|
I have tested this item
test didn't changed @icampus
@csthomas I wonder if these failed tests are really failed or it is unclear what to test. Reading the test instructions I am not sure what to test. Your summary of changes state what is supposed to changed. Perhaps we can clarify the test instructions with how often the echo should be shown and where to check in the debug information to see the query gone?
I have updated test instruction. Please test again.
@schmidtpaddy @wmchris Can you please again using the new test instructions? Thank you.
Labels |
Added:
?
|
Category | Code style Components Libraries Administration Front End | ⇒ | Administration Components Front End Code style |
Labels |
Removed:
?
|
I have tested this item
Ran updated test as described and got the same results at each stage - made edits to /plugins/user/profile/profile.php - completed each of the other steps described, applied the patch, same results.
I have tested this item
Got same Result as written in Test Instructions.
@jeckodevelopment I have no clue what this does here. As long as the models behave the same and trigger the plugin events, I'd say it should be fine, but I only glanced over it.
I have added a few more explanation to code to be more easy to understand the changes.
Category | Code style Components Administration Front End | ⇒ | Administration com_users Front End Code style Components |
What the status of that PR, RTC?
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-02-11 11:38:13 |
Closed_By | ⇒ | rdeutz | |
Labels |
Added:
?
|
I have tested this item? unsuccessfully on
Applied the changes, dont get a difference before and after patch in the messages
'''
on open:
I was run in 63
I was run in 230
on changing two or more fields:
I was run in 230
User successfully saved.
I was run in 63
'''
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9325.