Skip to content

[3.0] Import the classes the theme actions actually use - #9387

Open
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/theme-actions-imports
Open

[3.0] Import the classes the theme actions actually use#9387
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/theme-actions-imports

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

SMF\Actions\ThemeChooser uses UserDataset without importing it, so choosing a
theme for a member fatals:

Class "SMF\Actions\UserDataset" not found

I hit this from the UI: Admin → Themes → Choose a theme, pick one, submit. The
member's theme is never saved and the page is replaced by the error. It is logged
in smf_log_errors against ?action=themechooser.

The same file, and SMF\Actions\ThemeSetOption, also import SMF\CacheApi. There
is no such class — it is SMF\Cache\CacheApi; Sources/CacheApi.php does not
exist and nothing aliases the short name. BackwardCompatibility::exportStatic()
returns immediately when $backward_compatibility is empty, which it is by
default in both Settings.php and the shipped other/Settings.php.

ThemeChooser reaches its CacheApi::put() only when a theme variant was chosen,
and the bundled theme ships no variants, which is presumably why this has gone
unnoticed. ThemeSetOption calls it on both of its paths.

Testing

Before, on release-3.0 (a7ac468b1): submitting the theme picker gives the
error above and smf_members.id_theme is unchanged.

After: the same submission redirects to ?action=profile;area=theme;u=1, which is
the success path, and nothing new appears in smf_log_errors.

composer lint is clean on both files.

Found while testing the theme picker for the #7933 split.

Issues References (Fixes|Related|Closes)

Related to #7933

SMF\Actions\ThemeChooser imports SMF\CacheApi and calls UserDataset without
importing it at all; SMF\Actions\ThemeSetOption imports SMF\CacheApi as well.
There is no SMF\CacheApi — the class is SMF\Cache\CacheApi — so both names
resolve inside SMF\Actions and are not found.

Choosing a theme for a member fatals with 'Class "SMF\Actions\UserDataset"
not found' before it reaches the cache line, and saving a theme option would
fail the same way on SMF\Actions\CacheApi.

Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant