mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
fix(em): prevent use if missing php functions
This commit is contained in:
@@ -46,6 +46,11 @@ return [
|
|||||||
&& is_writable($paths->base.'/composer.lock');
|
&& is_writable($paths->base.'/composer.lock');
|
||||||
|
|
||||||
$document->payload['flarum-extension-manager.using_sync_queue'] = resolve(Queue::class) instanceof SyncQueue;
|
$document->payload['flarum-extension-manager.using_sync_queue'] = resolve(Queue::class) instanceof SyncQueue;
|
||||||
|
|
||||||
|
$document->payload['flarum-extension-manager.missing_functions'] = array_values(array_filter(
|
||||||
|
['proc_open', 'escapeshellarg'],
|
||||||
|
fn (string $function): bool => ! function_exists($function)
|
||||||
|
));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
new Extend\Locales(__DIR__.'/locale'),
|
new Extend\Locales(__DIR__.'/locale'),
|
||||||
|
@@ -1,6 +1,4 @@
|
|||||||
import app from 'flarum/admin/app';
|
|
||||||
import Component from 'flarum/common/Component';
|
import Component from 'flarum/common/Component';
|
||||||
import Alert from 'flarum/common/components/Alert';
|
|
||||||
import { ComponentAttrs } from 'flarum/common/Component';
|
import { ComponentAttrs } from 'flarum/common/Component';
|
||||||
|
|
||||||
import Installer from './Installer';
|
import Installer from './Installer';
|
||||||
@@ -17,18 +15,10 @@ export default class ControlSection extends Component<ComponentAttrs> {
|
|||||||
return (
|
return (
|
||||||
<div className="ExtensionPage-settings ExtensionManager-controlSection">
|
<div className="ExtensionPage-settings ExtensionManager-controlSection">
|
||||||
<div className="container">
|
<div className="container">
|
||||||
{app.data['flarum-extension-manager.writable_dirs'] ? (
|
|
||||||
<Form>
|
<Form>
|
||||||
<Installer />
|
<Installer />
|
||||||
<Updater />
|
<Updater />
|
||||||
</Form>
|
</Form>
|
||||||
) : (
|
|
||||||
<div className="Form-group">
|
|
||||||
<Alert type="warning" dismissible={false}>
|
|
||||||
{app.translator.trans('flarum-extension-manager.admin.file_permissions')}
|
|
||||||
</Alert>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -8,6 +8,7 @@ import ControlSection from './ControlSection';
|
|||||||
import ConfigureComposer from './ConfigureComposer';
|
import ConfigureComposer from './ConfigureComposer';
|
||||||
import ConfigureAuth from './ConfigureAuth';
|
import ConfigureAuth from './ConfigureAuth';
|
||||||
import DiscoverSection from './DiscoverSection';
|
import DiscoverSection from './DiscoverSection';
|
||||||
|
import Alert from 'flarum/common/components/Alert';
|
||||||
|
|
||||||
export default class SettingsPage extends ExtensionPage {
|
export default class SettingsPage extends ExtensionPage {
|
||||||
content() {
|
content() {
|
||||||
@@ -43,9 +44,33 @@ export default class SettingsPage extends ExtensionPage {
|
|||||||
sections(vnode: Mithril.VnodeDOM<ExtensionPageAttrs, this>): ItemList<unknown> {
|
sections(vnode: Mithril.VnodeDOM<ExtensionPageAttrs, this>): ItemList<unknown> {
|
||||||
const items = super.sections(vnode);
|
const items = super.sections(vnode);
|
||||||
|
|
||||||
|
const writableDirs = app.data['flarum-extension-manager.writable_dirs'];
|
||||||
|
const missingFunctions = app.data['flarum-extension-manager.missing_functions'] as string[] | undefined;
|
||||||
|
const usable = writableDirs && (!missingFunctions || missingFunctions.length === 0);
|
||||||
|
|
||||||
|
if (usable) {
|
||||||
items.add('discover', <DiscoverSection />, 15);
|
items.add('discover', <DiscoverSection />, 15);
|
||||||
|
|
||||||
items.add('control', <ControlSection />, 10);
|
items.add('control', <ControlSection />, 10);
|
||||||
|
} else {
|
||||||
|
items.add(
|
||||||
|
'warning',
|
||||||
|
<div className="ExtensionPage-settings">
|
||||||
|
<div className="container">
|
||||||
|
<div className="Form-group">
|
||||||
|
<Alert type="error" dismissible={false}>
|
||||||
|
{!app.data['flarum-extension-manager.writable_dirs']
|
||||||
|
? app.translator.trans('flarum-extension-manager.admin.file_permissions')
|
||||||
|
: app.translator.trans('flarum-extension-manager.admin.required_php_functions', {
|
||||||
|
functions: (app.data['flarum-extension-manager.missing_functions'] as string[]).join(', '),
|
||||||
|
})}
|
||||||
|
</Alert>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>,
|
||||||
|
10
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
items.setPriority('content', 8);
|
items.setPriority('content', 8);
|
||||||
|
|
||||||
|
@@ -99,6 +99,10 @@ flarum-extension-manager:
|
|||||||
minor_update_confirmation:
|
minor_update_confirmation:
|
||||||
content: This will also update any other extensions/packages with available updates.
|
content: This will also update any other extensions/packages with available updates.
|
||||||
|
|
||||||
|
required_php_functions: >
|
||||||
|
The extension manager requires the following PHP functions to be enabled: <code>{functions}</code>.
|
||||||
|
If you do not have access to the PHP configuration, please contact your hosting provider.
|
||||||
|
|
||||||
sections:
|
sections:
|
||||||
discover:
|
discover:
|
||||||
description: Add new features and integrations to your Flarum forum with extensions.
|
description: Add new features and integrations to your Flarum forum with extensions.
|
||||||
|
Reference in New Issue
Block a user