-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Admin app - Use the autoloader #10881
Conversation
@@ -1,6 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<form> | |||
<fields name="filter"> | |||
<fields name="filter" addfieldpath="/administrator/components/com_banners/models/fields"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbabker isn't this supposed to autoload by https://github.com/joomla/joomla-cms/blob/staging/libraries/legacy/model/form.php#L203-L206 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you only use these forms going through JModelForm objects then sure. If
they load any other way the dependency wouldn't be loaded. I equate it to
relying on something else to load jQuery when you depend on it.
On Monday, June 20, 2016, Dimitri Grammatikogianni notifications@github.com
wrote:
In administrator/components/com_banners/models/forms/filter_banners.xml
#10881 (comment):@@ -1,6 +1,6 @@
- -@mbabker https://github.com/mbabker isn't this supposed to autoload by
https://github.com/joomla/joomla-cms/blob/staging/libraries/legacy/model/form.php#L203-L206
?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/joomla/joomla-cms/pull/10881/files/5f19de3d1f3851054f65ed03611262be65340315#r67783423,
or mute the thread
https://github.com/notifications/unsubscribe/AAWfoeL9oXQo7eQDLYLivxj4CStNBLhUks5qNx3ngaJpZM4I6I8J
.
I have tested this item ✅ successfully on b7afe6c (Regarding testing instructions first I was confused by word "admin app" in testing info. But later I understand that it's mean to Joomla! Administrator tests) Thanks. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10881. |
@@ -66,8 +66,6 @@ public function display($tpl = null) | |||
|
|||
$this->addToolbar(); | |||
|
|||
require_once JPATH_COMPONENT . '/models/fields/bannerclient.php'; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mbabker
Why JLoader::register() is not used after removing this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find a direct use of the class that this was loading in the code. Meaning either it's being loaded as part of a form (where the lookup path should be included in the XML or added with a JFormHelper::addFieldPath()
call) or it was being loaded needlessly.
I have tested this item ✅ successfully on b7afe6c This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10881. |
rtc This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10881. |
@@ -12,7 +12,7 @@ | |||
use Joomla\Registry\Registry; | |||
|
|||
jimport('joomla.filesystem.path'); | |||
require_once JPATH_COMPONENT . '/helpers/menus.php'; | |||
JLoader::register('MenusHelper', JPATH_COMPONENT . '/helpers/menus.php'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general that's why the JPATH_COMPONENT
path constants should only serve one purpose in Joomla until 4.0 is released; raise deprecation notices. Those are in part why it is so freakin' difficult to work between different components, because that path is not constant by any means.
This PR has received new commits. CC: @alikon, @pritalpatel |
@mbabker |
Fixed. Copy/Paste errors suck. |
@@ -57,7 +57,7 @@ public function display($cachable = false, $urlparams = false) | |||
return $view->display(); | |||
} | |||
|
|||
JLoader::register('ModulesHelper', JPATH_COMPONENT . '/helpers/modules.php'); | |||
JLoader::register('ModulesHelper', JPATH_ADMINISTRATOR . '/components/com_messages/helpers/modules.php'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
com_modules, not com_messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FML
@@ -11,7 +11,7 @@ | |||
|
|||
JFormHelper::loadFieldClass('list'); | |||
|
|||
require_once __DIR__ . '/../../helpers/installer.php'; | |||
JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is right, but it is now using JPATH_ADMINISTRATOR+component_folder, it could have kept the usage of __ DIR __
JLoader::register('InstallerHelper', dirname(__DIR__, 2) . '/helpers/installer.php');
I say this because in other cases you keep the usage of __ DIR __, but in some you do not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I personally prefer absolute paths over relative when practical. I
dislike trying to read paths in include statements with directory traversal
like that because I think it makes it harder to follow. -
The second param on dirname() is only present as of PHP 7.0.
On Monday, July 18, 2016, Georgios Papadakis notifications@github.com
wrote:
In
administrator/components/com_installer/models/fields/extensionstatus.php
#10881 (comment):@@ -11,7 +11,7 @@
JFormHelper::loadFieldClass('list');
-require_once DIR . '/../../helpers/installer.php';
+JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php');This is right, but it is now absolute path, it could have remain a
"relative" using the DIR:JLoader::register('InstallerHelper', dirname(DIR, 2) . '/helpers/installer.php');
I say this because in other cases you keep the usage of DIR, but in
some you do not—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/joomla/joomla-cms/pull/10881/files/ec8218c23101f868671104e3c8505f357337677d#r71102143,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWfoRDLWy8U5Vzyv4f6C78Q2lDDpyBoks5qWxSvgaJpZM4I6I8J
.
@mbabker |
The DIR constant is an absolute path, specifically to the directory the On Monday, July 18, 2016, infograf768 notifications@github.com wrote:
|
yes about "absolute path" , it is but the benefit of it is that you don't need to care much about what is exactly this absolute path is,
the argument , if same folder or parent folder, then we use it __ DIR __, but if parent - parent folder we don't use , sounds strange to me |
It's a personal preference and AFAIK there is no style rule regarding how paths should be referenced. I'd suggest either absolute paths using If we're going to nitpick over this stuff, I'll just close my autoloader PRs. I'm also not a fan of PRs getting held up because people want to try and apply arbitrary standards to them. |
I have tested this item ✅ successfully on ec8218c This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10881. |
Also, before I end ranting, a benefit to using absolute paths versus relative is you don't have to change the include reference if you move the file. If I move the file calling |
anyhow, this works fine here and solves the issue we had with the gsoc project. |
I have tested this item ✅ successfully on ec8218c This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10881. |
@mbabker
and i hope that you don't imply that i am preventing a good PR, i was just asking, i had said the paths are good. |
Not trying to imply anything at all, sorry if it comes across that way. Just seen a lot more than I'd like lately folks requesting changes to PRs simply because they're already editing the lines they'd like to see changed. |
Summary of Changes
Load files in the admin app by including the required classes to the autoloader.
Testing Instructions
The admin app should still function correctly.