Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-03-23 13:23:40

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,319

Situation around plugin (de-)activation in preferences

Currently I’m troubleshooting some things with active/inactive plugins and notice that—though plugins are de-activated in preferences—I’m getting a list of active plugins displayed in Diagnostics. This is not helpful because

  1. It’s not true, they’re activated, at best
  2. Reading this is irritating/misleading while in the troubleshooting process, not only for less proficient Textpatterners
  3. It brings wrong information to the forum for getting troubleshooting help

Now, while plugins are de-activated via prefs, you’re not informed about this situation in the plugins panel. Usually plugins will be de-activated/re-activated there, so if you forget about your previous proceedings in the preferences and then look after “not working” plugins, you’ll go to the Plugins panel and see: “Yes, the darn things are active. So why doesn’t it work?” An indicator could help here, informing that plugin use is turned off generally or turned off for admin side plugins.

Which brings me back to the preferences for admin side plugins: In my understanding, this setting might be invisible or greyed out with “Allow plugins” set to No. That would make the situation there a little more self-explaining/less error prone.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#2 2018-03-23 13:32:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Situation around plugin (de-)activation in preferences

Umm, wot?

How do you deactivate a plugin from the Preferences panel? You can only activate and deactivate them from the Plugins panel (or from ied_plugin_composer, but that’s broken right now for 4.7.0).

When a plugin is deactivated it’s prefs should disappear from the Preferences panel. I’ve broken smd_article_stats in recent commits so I need to fix that. But on the whole, plugin prefs should only be active if the plugin is active as dictated by the Yes/No on the Plugins panel.

EDIT: Hang on, just got what you’re talking about.. the global admin-side plugins on/off toggle in prefs. Sorry. Let me investigate!

Last edited by Bloke (2018-03-23 13:33:29)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#3 2018-03-23 13:34:33

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,319

Re: Situation around plugin (de-)activation in preferences

I mean the general use of plugins, on the tab “Publish”.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2018-03-23 13:35:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Situation around plugin (de-)activation in preferences

Yeah, got it sorry. I was being dim. Investigation in progress…


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#5 2018-03-23 13:41:18

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,319

Re: Situation around plugin (de-)activation in preferences

Bloke wrote #310267:

You can only activate and deactivate them from the Plugins panel

So much about my remark “Usually plugins will be de-activated/re-activated there” ;)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#6 2018-03-23 13:44:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Situation around plugin (de-)activation in preferences

Yeah, I didn’t read properly. Mea culpa.

I’ve just been a little confused by the options actually:

Use plugins? really should read Use public-side plugins? because it only seems to affect those on the main site. Admin plugins still continue to run unless you turn off the Use admin-side plugins? toggle.

In either case, the Diagnostics panel should act accordingly. I’ll get it to take those settings into account. Thanks for the report.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#7 2018-03-23 13:49:41

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,319

Re: Situation around plugin (de-)activation in preferences

Thanks! What do you think about the two other last point?

  • An indicator in Plugins panel informing on deactivated plugins (Admin/Public) turned off from the prefs panel
  • Not listing active plugins in Diagnostics as long as plugins are deactivated globally

Edited because … see below

Last edited by uli (2018-03-23 13:53:03)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#8 2018-03-23 13:52:15

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,319

Re: Situation around plugin (de-)activation in preferences

Bloke wrote #310271:

In either case, the Diagnostics panel should act accordingly.

Ah, missed that one.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#9 2018-03-23 14:01:18

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,319

Re: Situation around plugin (de-)activation in preferences

I/me wrote #310270:

So much about my remark “Usually plugins will be de-activated/re-activated there” ;)

Bloke wrote #310271:

Yeah, I didn’t read properly. Mea culpa.

No, didn’t want to underline any misunderstandings. I just see your line “You can only activate and deactivate them from the Plugins panel” as a proof for my theory that the Plugins panel is THE place for deactivating plugins, and hence there is a need for a hint on the Plugins panel informing on the global deactivation of plugins done from the prefs when that setting makes the use of plugins impossible.

Hm, have I been clear enough here?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#10 2018-03-23 15:22:42

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Situation around plugin (de-)activation in preferences

uli wrote #310274:

there is a need for a hint on the Plugins panel informing on the global deactivation of plugins done from the prefs when that setting makes the use of plugins impossible.

Yes, you’re right. We have the following options:

  • Some kind of banner or something on the Plugins panel that admin plugins, or public plugins, or both are deactivated globally.
  • An indicator alongside each plugin to show that plugins of this type are deactivated globally.
  • Some kind of other indicator for each plugin (dimmed? strikethrough?) that such plugins are not currently enabled globally (as distinct from still being enabled individually).
  • An indication of the plugin’s type via another column in the table. A possible option would be to indicate the global status here, maybe?

Not exactly sure how best to show this. Any better ideas?

The problem is compounded by the fact we technically have 6 “types” of plugin. And they’re (annoyingly) not easily accumulable in terms of internal representation.

To the layperson, we have “public” and “admin” but for plugin authors (and people debugging things) the full range of types is something that is potentially very useful information. Perhaps we should add that to the list of plugins on Diagnostics, alongside the (m) marker? I’ll probably do that.

Anyway, one thing that’s been bubbling away at the back of my mind for ages is that our plugins type designators are, quite frankly, crap. Here’s what we have:

  • 0 = public : only on the public side of the website (default)
  • 1 = public+admin : on both the public and admin side
  • 2 = library : only when include_plugin() or require_plugin() is called
  • 3 = admin : only on the admin side (no AJAX)
  • 4 = admin+ajax : only on the admin side (AJAX supported)
  • 5 = public+admin+ajax : on both the public and admin side (AJAX supported)

In terms of programming, that means an activated “admin-side” plugin is loaded:

a) On the public-side, unless it’s designated admin-only (type 3).
b) On the admin-side for regular panel actions.
c) On the admin-side for AJAX calls if it’s of type 4 or 5.
d) AND only check a, b, and c conditions if the Use admin-side plugins pref is set.

An activated public-side plugin is loaded:

a) On the public-side if its type is unset or 0.
b) On the public-side if its type is 5.
c) AND only check a and b conditions if the Use plugins flag pref is set.

Activated library plugins are never loaded autoamtically, only when explicitly called by other plugins.

What a mess!

We really need to unpick all this and introduce proper type flags, for example:

define('PLUGIN_TYPE_PUBLIC', 0x0008);
define('PLUGIN_TYPE_ADMIN', 0x0010);
define('PLUGIN_TYPE_LIBRARY', 0x0020);
define('PLUGIN_HAS_AJAX', 0x0040);

That system has the following properties:

  • No need for explicit values for each type combination, meaning fewer overall values.
  • Combinations can be specified more intuitively, e.g. PLUGIN_TYPE_PUBLIC | PLUGIN_TYPE_ADMIN | PLUGIN_HAS_AJAX means a public-side and admin-side plugin with Ajax support, equivalent to our current type ‘5’. Easy
  • All values are opt-in (unlike the current ‘public’ flag, which is 0 and can’t therefore be implied).
  • Much easier to parse and apply in code using bitwise operators.
  • The numbers are higher than the highest current value we have, which allows for a migration path from “crappy type numbers” to “proper flags” :-)

The trick is to figure out how to map the current system to the flags. If it’s not too much hassle, I might just do that now. If I put a translation function in place in our new Plugin class, that should suffice to make it backwards compatible but allow us to start using the new flags from 4.7.0. And, crucially, it’ll make it a truckload easier to filter them out by type on the Diagnostics panel.

Phew!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#11 2018-03-23 16:00:49

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,319

Re: Situation around plugin (de-)activation in preferences

Bloke wrote #310278:

Phew!

I certainly didn’t want to stir up as much as it seems it has become now.
But if things get better in the end …

We have the following options:

  • Some kind of banner or something on the Plugins panel that admin plugins, or public plugins, or both are deactivated globally.
  • An indicator alongside each plugin to show that plugins of this type are deactivated globally.
  • Some kind of other indicator for each plugin (dimmed? strikethrough?) that such plugins are not currently enabled globally (as distinct from still being enabled individually).
  • An indication of the plugin’s type via another column in the table. A possible option would be to indicate the global status here, maybe?

The first one is what I thought should be enough. That’s Textpattern style, like the current banner in the forum.

Then, having read the palette of options you mention, I think a mixture of your second and third point has merit. I’d find it sufficient when—in the Active column—the terms Yes/No were striked through. I see no need, though, to inform the user why a certain plugin is deactivated when s/he has a banner on top of the page with a generalized plugin type info.

Last edited by uli (2018-03-23 16:04:24)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#12 2018-03-23 16:47:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Situation around plugin (de-)activation in preferences

uli wrote #310279:

I certainly didn’t want to stir up as much as it seems now.

Well, it kinda needs doing anyway as it’s not very good.

I’m not entirely sure my initial thought on using the 4 status flags is enough as I don’t know if it’s easy to cater for extracting “admin only”. It’s not just accumulated logic, it’s pulling out rows that match public|admin|ajax but NOT just admin. Can that be done cleanly in bitwise logic when querying MySQL? I don’t know. My MySQL-fu wrt bitwise stuff is severely lacking.

I’d find it sufficient when—in the Active column—the terms Yes/No were striked through.

Yes, I like that. But I just thought of something. When Use plugins is ON and Use admin-side plugins is OFF, all plugins except those designated admin-only are still active on the public side.

So what exactly do we show as struck out? And what would we exclude from the Active plugins on Diagnostics? The only ones we know for sure that are not loaded are the “admin only” plugins. All others are on, unless you toggle Use plugins OFF. Only then would there be no active plugins running. And only if both prefs were off.

If Use plugins is OFF and Use admin-side plugins is ON, only those designated as ‘admin-only’ remain active.

The upshot is that only in the latter case would you ever see a few admin-side-only plugins available in the list, with everything else struck out. Any other combination of prefs would leave the list unaltered, and all plugins except admin-only active.

The bottom line is that all plugins are considered fair game on the public-site at all times regardless of their type. There’s no such thing as a “public-only” plugin. The only time their type is taken into consideration is for admin-only (well, and library plugins but they’re not loaded at all unless requested).

Last edited by Bloke (2018-03-23 16:50:40)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#13 2018-03-24 14:48:29

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,319

Re: Situation around plugin (de-)activation in preferences

I’ve read your post(s) several times, but for my graphic designer brain your considerations sound quite complicated, I can hardly follow. Additionally, what you’re aiming at seems too much for what Textpattern has represented throughout its existence.

My suspect is it might be easier to accomplish to switch off all plugin-use altogether with switch “a”, and with switch “b” turn off only admin side ones, so the website is running normally for the public. (Then, of course, hiding/graying-out switch b as long as switch a is ON.)

Then, on the Plugins panel, a banner should inform about the deactivated-in-prefs setting, be it a general or an admin-side deactivation.

On Diagnostics, an additional sentence might give an analogous hint to anyone reading that text.
To those only? Quite hard to spot.

Which brings in one more idea: It might be useful to indicate the plugin deactivation in each admin panel, so that the deactivation is not forgotten when the admin is sidetracked somehow.

Bloke wrote #310287:

There’s no such thing as a “public-only” plugin.

I think there’s nothing to misunderstand in this sentence, and you’ll have tested thoroughly. Yet it sounds hard to grasp to me that e.g. the many conditional plugins aren’t public-only.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#14 2018-03-24 20:34:54

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Situation around plugin (de-)activation in preferences

uli wrote #310313:

what you’re aiming at seems too much for what Textpattern has represented throughout its existence.

Sorry if it’s confusing but that’s how Textpattern works now, and has worked since at least 4.0.7 (or whenever admin-only plugins were introduced, and probably before).

  • On the public site, both admin AND public plugins are always loaded UNLESS you set the Use plugins pref off.
  • On the admin-side, only admin-side plugins are loaded UNLESS you set the Use admin-side plugins pref off.

So, consider this:

  1. You turn OFF admin-side plugins (Use admin-side plugins in prefs). No Extensions panels appear, there are no extra plugin features on the admin side. Nothing plugin related runs at all.
  2. You visit the Diagnostics panel. It still shows that some plugins with admin-side components are active. Why? Because they are! Because if you visit the public site, they still run. They might have public tags defined in them.

The fact you’ve turned off the plugins on the admin-side does not affect their status on the public site. So what is showing on Diagnostics is correct. Although you might no longer be able to administer their settings, they are still technically active.

The only plugins that should not be shown on Diagnostics in this situation are the ones designated as “admin-only” (type 3). The fact they are still shown is a bug and we should hide them in this specific case.

Now consider this:

  1. You turn OFF public plugins (Use plugins in prefs). No public tags are available from any plugins.
  2. You visit the Diagnostics panel. It still shows that plugins with admin-side components are active. Why? Because they are! Because if you visit the admin side, they still run.

The only time you should see no plugins in the Diagnostics panel is if BOTH plugin-related prefs are off. That, again, is a bug and should be fixed, because currently they are listed as active.

My suspect is it might be easier to accomplish to switch off all plugin-use altogether with switch “a”, and with switch “b” turn off only admin side ones, so the website is running normally for the public. (Then, of course, hiding/graying-out switch b as long as switch a is ON.)

Yes, but this raises a backwards-compatibility issue. We’d have to work around it (by introducing a third pref and phasing out the old ‘Use plugins’ one). For now, we should probably just relabel them:

  • Allow plugins to run on the public site.
  • Allow plugins to run on the admin side.

it might be useful to indicate the plugin deactivation in each admin panel, so that the deactivation is not forgotten when the admin is sidetracked somehow.

No, sorry. The choice of not running plugins might be a conscious one on behalf of an admin. Maybe the site doesn’t need any. Or they’re disabled for security reasons. We shouldn’t nag people on every panel for something they might have chosen to do.

On the plugins panel, sure, a helpful indicator of which types are disabled might be handy. Similarly on the Diagnostics panel just before the list of “active” plugins, maybe. Beyond that, nothing.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#15 2018-03-24 20:45:54

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,499
Website GitHub

Re: Situation around plugin (de-)activation in preferences

uli wrote #310313:

it sounds hard to grasp to me that e.g. the many conditional plugins aren’t public-only.

At the risk of making this more complicated than it is:

  • The plugin type (0-5) determines where it runs – public side (0) or admin side (3) or both (1). Ignore ‘Ajax mode’ for now, that’s a distraction.
  • Inside the plugin code, the author can do a check “Am I running on the public site? or “Am I running on the admin side?” and execute relevant code based on where it is running

It’s perfectly feasible to construct a plugin that is designated as “Admin” (type 1) – remember, this type really means “Both admin and public” but is poorly labelled – and have code inside it that is only executed if the plugin is running on the public site! It’s poor design and wastes processor cycles on the admin side to load a plugin that’s never used there, but it’s possible.

Likewise, you could construct a “type 1” plugin that has no public components, because you do an ‘if’ inside the code to detect only the admin-side case. Again, wastes cycles to load it on the public site, but it’s possible. It’s down to the plugin author to choose the appropriate type.

However:

  • it’s not possible to write a “type 0” plugin that runs on the admin-side. They are never loaded there.
  • it’s not possible to write a “type 3” plugin that runs on the public site. They are never loaded there.

How’s that?!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB