craftcms / craftcms/ckeditor

[5.x] Plugin relies on loading order for custom plugins

Open
#621 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
47
Forks
32
PR merge metrics
No merged PRs in 30d

Description

Description

This plugin immediately registers custom plugins' namespaces in its own init function:
https://github.com/craftcms/ckeditor/blob/0abec0bba0c90c39bb586c983c9b51d57d24010b/src/Plugin.php#L71-L76

Given that Craft loads plugins in alphabetical order (as of https://github.com/craftcms/cms/commit/2540de56f99d9f3b38bbc14070c433ccf00b56ab), this prevents any custom CKEditor plugins with a name alphabetically past CKEditor's own (e.g. ckeditor-some-plugin) from registering themselves.

Steps to reproduce
  1. Set up a new CKEditor plugin with a handle alphabetically past CKEditor's (e.g. ckeditor-test)
  2. Install it
  3. Notice that it never shows up in the page's importmap and the plugin's init (where you must register the CKEditor package) is called after CKEditor's own init

A complete reproduction can be found here: https://github.com/lexisother/ckeditor-load-order-repro

Video

https://github.com/user-attachments/assets/d8a21a73-b070-46d8-9141-eacb6c58b22d

Additional info
  • Craft version: 5.11.1
  • PHP version: 8.3
  • Database driver & version: MySQL 8.0.40
  • Plugins & versions: CKEditor 5.7.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/Plugin.php lines 71-76 and compare its init behavior with the loading sequence described in the issue. Use the linked ckeditor-load-order-repro to verify a custom plugin such as ckeditor-test is included in the page importmap and initialized successfully regardless of alphabetical order.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.