You install an application and a tab appears in the AdminCP navigation called:
menutab_system
sitting between Community and Members, looking like a corrupted install. Nothing is logged, nothing errors, and the application otherwise works perfectly.
The cause
The tab value in data/acpmenu.json is never validated. Invision Community takes whatever you write, creates a tab for it, and looks up its display name from the language key menutab__<tab> — note the double underscore. If no such key exists anywhere, the AdminCP renders the raw key as the tab's name.
{
"backup": {
"archives": {
"tab": "system", <-- there is no "system" tab
"controller": "archives",
"restriction": "archives_manage"
}
}
}
The tabs that exist
Core defines these:
community core customization members stats support developer
The trap is that there is no system tab, even though "System" is exactly what the section is called in the AdminCP interface. That section is core. Anything to do with the running of the site — settings, logs, applications, backups — belongs on core.
Applications may create their own
Commerce uses nexus and Pages uses cms, and both are correct: they supply menutab__nexus and menutab__cms in their own language files. So the rule is not "use one of the seven core tabs" — it is:
The tab is valid if something, anywhere, defines menutab__<tab>.
If you want your own tab, define the key. If you do not, use an existing one. What you must not do is invent a name and define nothing, which is the case that produces the stray string.
Checking it
This is worth a static check, because it will never announce itself:
foreach ( glob( \IPS\ROOT_PATH . '/applications/*/data/acpmenu.json' ) as $file )
{
foreach ( json_decode( file_get_contents( $file ), TRUE ) as $module => $items )
{
foreach ( $items as $key => $item )
{
if ( isset( $item['tab'] )
and !\IPS\Member::loggedIn()->language()->checkKeyExists( 'menutab__' . $item['tab'] ) )
{
// renders as its own raw key in the AdminCP
}
}
}
}
Do not implement it as a whitelist of the core seven — that reports Commerce and Pages as broken when they are not. Ask whether the name resolves; that is the only thing that actually matters.
Why nothing catches this
The application installs cleanly. The menu entry is created and clicking it works. Every screen renders. The only symptom is a piece of text in the navigation, which is easy to skim past on your own site and immediately obvious to a customer.
Recommended Comments