The panels ipe javascript is loaded, even if you don't have access to it. This is unnecessary, especially for anonymous users.

CSS doesn't seem to be loaded, which is fine.

Comments

swentel created an issue. See original summary.

swentel’s picture

Issue summary: View changes
StatusFileSize
new166.62 KB
swentel’s picture

Hmm, I don't have it on a regular ipe page, so this might be a panelizer problem, let me double check.

swentel’s picture

Project: Panels » Panelizer (obsolete)
Component: In-Place Editor (IPE) » Code

Confirmed, only happens on panelizer - moving to different queue.

swentel’s picture

Status: Active » Needs review
StatusFileSize
new618 bytes
swentel’s picture

StatusFileSize
new546 bytes

meh, wrong path

The last submitted patch, 5: panelizer-2688951-2.patch, failed testing.

dsnopek’s picture

Status: Needs review » Needs work

Good catch!

However, I think this should be inside of the existing if() { ... } statement just before the $build['#attached']['library'][] = 'panelizer/panels_ipe'; (I think it's that line that's causing the Panels IPE Javascript to be added, since it depends on it).

And, maybe rather than checking for the permission, we could check something on the $build array that would let us know if the IPE added itself? Otherwise, we could be getting the permissions wrong if/when this issue is committed: #2667754: Allow other modules to disable the IPE based on custom logic. Maybe it could look in $build['#attached']['library'] and if it finds the IPE Javascript, it could figure it's safe to add the Panelizer Javascript?

wiifm’s picture

hampercm’s picture

Assigned: Unassigned » hampercm

Working on a new patch for this, based on the suggestions from #8

hampercm’s picture

Assigned: hampercm » Unassigned
Status: Needs work » Needs review
StatusFileSize
new753 bytes

New patch based on the suggestions from #8. This will disable the attachment of the Panelizer library any time the panels_ipe/panels_ipe library isn't already attached.

I've tested it for Anonymous and Authenticated users without sufficient privileges to use the IPE, and verified no IPE-related JS files were linked.

  • dsnopek committed 1ddfa61 on 8.x-3.x authored by hampercm
    Issue #2688951 by swentel, hampercm, wiifm: Panels IPE javascript loaded...
dsnopek’s picture

Status: Needs review » Fixed

Thanks! Committed. :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Gravypower’s picture

It seems that this change has started to cause some notices and warnings to show for me.

Notice: Undefined index: #attached in panelizer_panels_build_alter() (line 101 of modules/contrib/panelizer/panelizer.module).

I believe that the issue has some roots in the fact I am using workbench moderation so am not 100% sure which module is causing this issue. However I was wondering if there was any reason why a test to see it the '#attached' key exists before accessing the 'library' key.

something along the lines of


if (isPanelizer($build, $builder, $storage_type)) {

....

function isPanelizer(&$build, $builder, $storage_type)
{
  return $builder->getPluginId() == 'ipe' &&
  in_array($storage_type, ['panelizer_default', 'panelizer_field']) &&
  in_array('#attached', $build) &&
  in_array('library', $build['#attached']) &&
  in_array('panels_ipe/panels_ipe', $build['#attached']['library']);
}

thoughs?

Aaron

Gravypower’s picture

StatusFileSize
new1.37 KB

Here is a patch with my idea.

dsnopek’s picture

Thanks!

A couple things:

  1. Let's make a new issue that links back to this issue. While they're related, we accomplished the original goal here, which is not to load the the IPE javascript when you have no access to the IPE. Making a separate issue will make our Git history easier to understand
  2. Using isset() is easier to read and fits in with other Drupal code better than in_array(), for example: isset($build['#attached'])
  3. I don't think we should make a separate function, because it's available globally and there's no other use for it really. I'd say declare a variable in the original function that's like:
    $is_panelizer = $builder->getPluginId() == 'ipe' &&
      in_array($storage_type, ['panelizer_default', 'panelizer_field']) &&
      in_array('#attached', $build) &&
      in_array('library', $build['#attached']) &&
      in_array('panels_ipe/panels_ipe', $build['#attached']['library']);
    

I'm looking forward to the new issue and patch ;-)

Gravypower’s picture

I have created a new issue (2760051) as per direction of @dsnopek and posted new patch there. Thanks for your reply.

Gravypower’s picture