Feature #31893
closedAllow XCLASSes to be defined via ext_autoload.php
100%
Description
For XCLASSes to work currently, one needs to
a) set the according XCLASS statement in every PHP file that can/should be subclassed
b) use this XCLASS statement in an extensions' ext_localconf.php to include the subclass statement
This process is somehow unflexible, produces code, and as it is somehow incomplete for some classes, a hassle to maintain.
The attached change does the following:
1) It makes use of the autoloader to search for classes of the XCLASS prefix "ux_*" as well.
2) It provides a way to also include the XCLASS paths via the "old way", but sends a deprecation warning for that.
There is one drawback however right now: There is no how an admin can see which XCLASSes are currently in use with "the new way" as the admin cannot browse the ext_autoload.php files of all extensions through the backend in a nice way.
Also: Beware that you might need to clear your autoload cache when trying out this feature, which you can do with a simple "rm -rf Cache/Code/cache_phpcode/*"
There is a small extension that I've built that you can use to try out. This extension should work without the patch on a plain introduction package as it just includes the XCLASS statement in ext_localconf.php. The extension XCLASSes tslib_fe and replaces the title "Introduction Package" before outputting the content. Now, you should remove the XCLASS statement in typo3/sysext/cms/tslib/class.tslib_fe.php at the very last lines. Now, the XCLASS (of course) does not work anymore. However, the extension itself has a ext_autoload.php, so after applying the patchset the XCLASS will work again, as the autoloader loads the XCLASS now. Maybe you need to clear your autoloader-cache for that though (see above).
Everything works as before now, even the limitation that only one XCLASS can be used of course still applies. The XCLASS to use is of course the one of the last extension installed, same principle as before, just not in the ext_localconf.php anymore, but in ext_autoload.php.
The advantages of "the new XCLASS way":
- "faster?" - Less initialization in ext_localconf.php, only when it is needed
- "more flexible" - XCLASS every class in use now
- "more transparent" - no XCLASS statement on the bottom of each core class anymore
I'm also interested how this affects the overall performance.
Further jobs once this is included in the TYPO3 Core:
- Update documentation properly, add it to the release notes of TYPO3 4.7
- Remove XCLASS statements from all core files
- Create a Status Report about it that an installation still uses wrong XCLASS syntax
- Talk about it, Blog about it
Files
Updated by Mr. Hudson over 12 years ago
Patch set 1 of change I4af4116108fecd9df0874c3e07e10b86f74d556e has been pushed to the review server.
It is available at http://review.typo3.org/6717
Updated by Gerrit Code Review over 12 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6717
Updated by Oliver Hader over 12 years ago
- Target version changed from 4.7.0-alpha2 to 4.7.0-alpha3
Updated by Steffen Ritter about 12 years ago
- Target version changed from 4.7.0-alpha3 to 4.7.0-beta1
Updated by Steffen Ritter about 12 years ago
- Target version deleted (
4.7.0-beta1)
Updated by Gerrit Code Review about 12 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6717
Updated by Gerrit Code Review about 12 years ago
Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6717
Updated by Gerrit Code Review about 12 years ago
Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6717
Updated by Michael Stucki about 12 years ago
Regarding backwards compatibility:
Let's add an update wizard to scan all ext_localconf.php files in loaded extensions.
Additionally, extdeveval might be used to convert these inclusions automatically.
Updated by Gerrit Code Review about 12 years ago
Patch set 6 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6717
Updated by Gerrit Code Review about 12 years ago
Patch set 7 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/6717
Updated by Benni Mack about 12 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 59328ee9aee6141a68259cc3196f06731b678277.