-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Improvements to Maho's autoloaders #40
Conversation
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.
sorry @justinbeaty, isn't there a simpler way to solve the problem you had cause this is gonna be very difficult to test
Git install is used only by us and it is forbidden to store projects, we
shouldnt even consider it as a possibility ans it’s never coveres in the
doc and never will 😂
Il giorno ven 4 ott 2024 alle 20:35 Justin Beaty ***@***.***>
ha scritto:
… ***@***.**** commented on this pull request.
------------------------------
In app/code/core/Mage/Core/functions.php
<#40 (comment)>:
> +
+ $path = realpath($version['install_path']);
+ if ($path !== BP) {
+ $packages[] = $package;
+ $packageDirectories[] = $path;
+ }
With a git install, composer lists mahocommerce/maho as an installed
package, but it's installed path is just where you cloned the repo. The
check filters that out.
I'm not sure it's strictly needed, but anytime you use the results of that
function, it seems you're expecting the path to be in vendor. I will
investigate.
—
Reply to this email directly, view it on GitHub
<#40 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG6DL5SS4OIB3CCB6NOQILZZ3UWJAVCNFSM6AAAAABPMIAQGKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGNBZGAYDAOJVGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I do agree, but it's not great that things break on a git install, because it makes testing harder since things work differently between the two install types.
I could drop the Zend override stuff from this PR if it will make it easier to test. |
I think people should use a composer patch if they need to patch zf1, overrides are always risky when there is an upgrade of the base file. I think this whole zf1 override thing is overrated. |
One other thought just now, it might be possible to drop the varien autoloader all together, but still allow Zend overrides. Then we get the fast Composer autoloader if available, and fallback to the slow PSR-0 type. Although I do agree it's not great practice to allow overrides. |
@fballiano Check it out, no more Varien auto loader! There's only one caveat. Before you could do stuff like: $this->_frontController = new mage_core_controller_varien_front(); Where it was case-insensitive, not you cannot, it must be But I don't think that's a deal breaker, and it doesn't seem like that's always an issue, I think maybe only the first call to the class must be right. Still working on the PR. |
wow! very interesting!!
mmm I kinda don't think that's a problem, since everybody uses an IDE (I hope) :-D |
Also, question: Do you think it's okay to change the output of [
'mahocommerce/maho' => [
'type' => 'maho-source',
'path' => '...',
],
'my/module' => [
'type' => 'magento-module',
'path' => '...',
],
] There might be a few keys to add to each module for an optimization idea I have. |
I think I've seen some ancient modules that named something like |
only difference is the key of the array right? I don't see any problem with that at this stage of the project.
exactly, it's the kind of code that should die anyway |
Right now you return two arrays: ['mahocommerce/maho', 'my/module']
['path1', 'path2'] And yeah, I don't think anyone has relied on it yet. 😄 |
right, change it if you think it's better, no problem |
It is actually faster to check which dirs exist first in included modules instead of adding all possible options into the path. So I added a check in See this test: https://pastebin.com/z3T7cQ2j, test 1 is the old way, test 2 is new, ignore test 3 for now. While we will not be loading 3,581 classes on a page load, the numbers are still much better.
Edit, I logged how many lookups are done on a normal page load. Product pages are about 350, so with 10 modules installed, it's 18ms faster. |
HAHAHHA I like the title of your last commit |
Wait, maybe we should have left the |
let me see |
mmm method and variable are "protected" and somebody should have overridden/extended app/code/core/Mage/Core/Model/Config.php which should be quite unusual, would you want to leave them in a disabled state and deprecate them? |
Not sure. One the other hand, if someone did extend But we could also log an exception if someone calls it.... |
We could also check to see if the user has it enabled, and log an exception there too. But I'm almost in favor of just having it completely removed. |
nah, the thing is that if we log an exception not a lot of people check the exception log... if we throw an exception at that point it's the same as the code breaking so... I'd say let's go if you don't want to think about it for a bit |
let's think about it for a couple of hours and then merge, it's a minor thing anyway I think and again I think in production nobody will want to have all local modules disabled, otherwise remove them altogether at that point |
Okay, let me get back to testing. I'm pretty sure no more changes unless a problem. Will explain some of previous changes soon. |
Sweet! 🚀🚀🚀 |
@justinbeaty merged!! thank you so much for such amazing work! I'll create a page on the website with the info from your last commit. I've published the new version to https://demo.mahocommerce.com and check how freaking fast it is (there's not even an FPC module nor redis yet!)! |
My absolute pleasure. When I get around to it I am going to try and spin up my store on Maho locally. I have a totally janky process for building the codebase that tries to work around some of the shortcomings of the openmage composer plugins. |
Nice! 😃 And good luck again to you for the conference. Looks like you'll be speaking in about 10 hours from now. |
Thank mate, I should definitely go to sleep now ehehehe I'm reviewing the slides right now :-D |
It started with me trying to enable cache under System > Cache Management, and it not working. I tracked the problem down to this line, but the problem only occurs if you're running via git clone, as I am doing for development.
maho/app/code/core/Mage/Core/Model/Config.php
Line 350 in 737536e
The reason is that because of the
array_reverse
it loadsapp/etc/local.xml
beforeapp/etc/config.xml
and that's setting<active>0</active>
under the db connection node. I re-wrote those functions in the twoConfig.php
files to not usearray_reverse
so files are loaded in alphabetical order like before, and I can enable cache now.To make the code a bit cleaner, I defined two new globals,
MAHO_IS_STARTER_KIT
which is true if you requiredmahocommerce/maho
with composer, andMAHO_ROOT_SOURCE_DIR
which always points to the root of maho's code, either in vendor or where you cloned it.I was also debugging something else, and on a hunch I tried changing the order of
include_paths
and the autoloaders. I'm pretty sure I solved OpenMage/magento-lts#3462. You can override Zend classes in any ofapp/code/core/
,app/code/local/
,app/code/community/
,lib/
, and any of those directories in 3rd party modules.One thing that threw me for a loop though was the behavior of opcache. If you were to override
Zend/Log/Formatter/Abstract.php
, it wouldn't load because opcache has already cached the file withrequire_once 'Zend/Log/Formatter/Abstract.php'
. There is an opcache setting to disable that, and I put that in for developer mode, but on a production system you may need to restart httpd or php-fpm.Also I wanted to say how much I appreciate your idea of the whole autoloading system. It's amazing. Makes the whole project cleaner and more robust. I need to be offline for a bit, but take some time to review and ask any questions.