WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#10505 closed defect (bug) (wontfix)

Gears not override-able by plugins

Reported by: Denis-de-Bernardy Owned by: ryan
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Cache API Keywords:
Focuses: Cc:

Description

Found this while looking into #10504...

It's rather complex to override the icons dir. And while looking into it, it occurred to me that the Gears manifest had no trace of anything plugins might add. Would it be possible to add a few hooks in there?

Change History (9)

comment:1 Denis-de-Bernardy5 years ago

Also affected would be TinyMCE. If a plugin adds TinyMCE plugins, they should get cached too.

comment:2 dd325 years ago

Gears doesnt load the WordPress libraries which is what is required for plugin hooks IIRC.

Same goes for the TMce Cache..

comment:3 Denis-de-Bernardy5 years ago

ya, hence the ticket... :-)

comment:4 azaozz5 years ago

The Gears manifest location can be set by overwriting wpGears.createStore() from another script (it's only loaded on the Tools screen).

When the Gears manifest is requested we can either:

  • Load all of WordPress and output list of all static files plus files added by plugins
  • Bypass loading everything and output list of all default files.

As the manifest is requested quite often, it kind of defeats the purpose if we load all to output it. That would also mean we will be loading WordPress twice for each page. The same applies for the scripts concatenation.

comment:5 dd325 years ago

  • Version set to 2.9

it kind of defeats the purpose if we load all to output it. That would also mean we will be loading WordPress twice for each page

The other option is to bootstrap them:

  • Store a cached manifest, If it exists, and its within whatever time limit, use that
  • Else, if the cache file is writable, Load WP for hooks
    • Else, If not writable, just use the default items

Use a much-longer-than-normal cache timeout, ie. a week or something, and add something on a hook in wp-admin to delete the cached file if the number of hooking functions changes.. (ie. on admin_footer, if get_transient('manifest_files') != get_current_hoooking_functions('gears_manifest_files') delete_file($manifest_cache)) - Just a thought.. seems a bit much for something simple to me though..

comment:6 Denis-de-Bernardy5 years ago

Hehe, seems DD32 and I had a similar idea at the same time... Posting the reply nonetheless...

---

Makes sense, yeah. What if we stored some kind of reference in a php file?

On the first page load, we'd load WP in its entirety, and we provide a hook to add to the manifest. After outputting the result, we cache it (as a php file or a serialized array, stored in wp-content or wherever is appropriate).

On subsequent page loads, that cached array exists, so we fetch it directly without bothering to load WP.

WP could flush the file where it's the most likely to be needed (e.g. activate/deactivate plugin and theme). We'd also want a hook or function that allows plugins to force a flush in the event it's needed (e.g. a change of user pref).

comment:7 azaozz5 years ago

The initial idea was to generate and save the Gears manifest file (similar to how WP manages .htaccess). We still can do that, perhaps moving it one level up. The same can be done for load-scripts.php and load-styles.php, we can add all script URLs there and pass all handles from script-loader. All this should be easier now as we have WP_Filesystem.

comment:8 ryan4 years ago

  • Milestone changed from 2.9 to Future Release

comment:9 Denis-de-Bernardy4 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.