Skip to content

Commit

Permalink
Update Autoloader docs to include more limitations. (#39752)
Browse files Browse the repository at this point in the history
* Added more docs about Autoloader limitations.

* Changelog.

* Added caveats and rephrased.
  • Loading branch information
zinigor authored Oct 14, 2024
1 parent 15f3015 commit e331da5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
30 changes: 20 additions & 10 deletions projects/packages/autoloader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ During development, you can force the autoloader to use development package vers
- `9999999-dev`
- Versions with a `dev-` prefix.


Autoloader Limitations and Caveats
-----

### Plugin Updates

When moving a package class file, renaming a package class file, or changing a package class namespace, make sure that the class will not be loaded after a plugin update.

The autoloader builds the in memory classmap as soon as the autoloader is loaded. The package class file paths in the map are not updated after a plugin update. If a plugins's package class files are moved during a plugin update and a moved file is autoloaded after the update, an error will occur.

### Moving classes to a different package

Jetpack Autoloader determines the hierarchy of class versions by package version numbers. It can cause problems if a class is moved to a newer package with a lower version number, it will get overshadowed by the old package.

For instance, if your newer version of a class comes from a new package versioned 0.1.0, and the older version comes from a different package with a greater version number 2.0.1, the newer class will not get loaded.

### Jetpack Autoloader uses transient cache

This is a caveat to be aware of when dealing with issues. The JP Autoloader uses transients to cache a list of available plugins to speed up the lookup process. This can sometimes mask problems that arise when loading code too early. See the [Debugging](#debugging) section for more information on how to detect situations like this.

Debugging
-----

Expand All @@ -70,13 +90,3 @@ PSR-4 and PSR-0 namespaces are converted to classmaps.

Supports PSR-4 autoloading. PSR-0 namespaces are converted to classmaps.


Autoloader Limitations
-----

Plugin Updates

When moving a package class file, renaming a package class file, or changing a package class namespace, make sure that the class will not be loaded after a plugin update.

The autoloader builds the in memory classmap as soon as the autoloader is loaded. The package class file paths in the map are not updated after a plugin update. If a plugins's package class files are moved during a plugin update and a moved file is autoloaded after the update, an error will occur.

5 changes: 5 additions & 0 deletions projects/packages/autoloader/changelog/update-docs-autoloader
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Added new information about limitations to the README.md.


0 comments on commit e331da5

Please sign in to comment.