Comments

dave reid’s picture

Issue tags: +7.x-2.0 beta blocker
Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new19.08 KB

Here you go!

saltednut’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Looks like this needs a reroll?

*[7.x-2.x][~/Sites/drupal7/sites/all/modules/media]$ git apply media_wysiwyg_view_mode-2062659-2.patch -v
Checking patch includes/media.admin.inc...
Hunk #1 succeeded at 223 (offset -12 lines).
Checking patch media.install...
Hunk #1 succeeded at 58 (offset -29 lines).
error: while searching for:
    file_type_disable($application);
  }
}

error: patch failed: media.install:1013
error: media.install: patch does not apply
Checking patch media.media.inc...
Checking patch media.module...
Hunk #4 succeeded at 1306 (offset -65 lines).
Checking patch modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.admin.inc...
Checking patch modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.info...
Checking patch modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.module...
Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new19.09 KB

New patch with update hook renamed.

Status: Needs review » Needs work

The last submitted patch, media_wysiwyg_view_mode-2062659-4.patch, failed testing.

aaron’s picture

Status: Needs work » Needs review
StatusFileSize
new19.76 KB

Here's a reroll.

fengtan’s picture

Thanks for the patchs.
Tried #6 against 7.x-2.x, looks like it does not apply anymore (see output attached).

fengtan’s picture

StatusFileSize
new19.12 KB

Rolled a new patch that should apply against the current 7.x-2.x.

fengtan’s picture

StatusFileSize
new19.12 KB

Found another issue: media_variable_get() should not be used since #1406948: Clean up and remove includes/media.variables.inc. Attached is a new patch that should fix it. Here is the diff with #8:

190c190
 +  $default_view_mode = variable_get('media__wysiwyg_default_view_mode');
 -  $default_view_mode = media_variable_get('wysiwyg_default_view_mode');

Also had a few tests:

  • Tested config 'Wysiwyg allowed view modes'
  • Tested config 'File wysiwyg view mode'

Looks good. Maybe someone else can test ?

Status: Needs review » Needs work
Issue tags: -Needs reroll, -7.x-2.0 beta blocker

The last submitted patch, media-wysiwyg-view-mode-2062659-9.patch, failed testing.

fengtan’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +Needs reroll, +7.x-2.0 beta blocker

The last submitted patch, media-wysiwyg-view-mode-2062659-9.patch, failed testing.

aaron’s picture

I am not certain why it's not passing for Drupal. It passes the tests when I run them locally. This is the error that it's failing on:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'file_managed.type' in 'where clause': SELECT file_managed.fid AS entity_id, :entity_type AS entity_type, NULL AS revision_id, :bundle AS bundle FROM {file_managed} file_managed WHERE (file_managed.type = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => image [:entity_type] => file [:bundle] => file ) in EntityFieldQuery->execute() (line 1140 of /var/lib/drupaltestbot/sites/default/files/checkout/includes/entity.inc).

I will try to force it to retest again.

aaron’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll, -7.x-2.0 beta blocker

Status: Needs review » Needs work

The last submitted patch, media-wysiwyg-view-mode-2062659-9.patch, failed testing.

ParisLiakos’s picture

Status: Needs work » Needs review
Issue tags: +Needs reroll, +7.x-2.0 beta blocker
jrreid’s picture

Looks like it passed this time. Tested locally as well, seems to work as intended for me.

aaron’s picture

Status: Needs review » Reviewed & tested by the community
ParisLiakos’s picture

  1. +++ b/media.media.inc
    @@ -134,3 +134,34 @@ function media_query_media_browser_alter($query) {
    + * Implements hook_media_wysiwyg_allowed_view_modes_alter().
    ...
    +function media_media_wysiwyg_allowed_view_modes_alter(&$view_modes, &$file) {
    ...
    + * Implements hook_media_token_to_markup_alter().
    ...
    +function media_media_token_to_markup_alter(&$element, $tag_info, $settings) {
    

    is there any reason we impement the hooks instead of putting directly the logic to the corresponding functions?

    i mean they could serve as an example but there is no other point

  2. +++ b/media.media.inc
    @@ -134,3 +134,34 @@ function media_query_media_browser_alter($query) {
    +  if (variable_get("media_{$file->type}_wysiwyg_restricted_view_modes_status", FALSE) == TRUE) {
    
    +++ b/media.module
    @@ -1292,3 +1307,60 @@ function _media_get_migratable_file_types() {
    +    if (variable_get("media_{$file->type}_file_wysiwyg_view_mode_status", FALSE) == TRUE) {
    

    we should either remove the == TRUE or make it strict, which i think is not needed..just remove it

  3. +++ b/media.module
    @@ -267,6 +279,9 @@ function media_permission() {
    +    'administer media wysiwyg view mode' => array(
    +      'title' => t('Administer Media WYSIWYG View Mode'),
    +    ),
    

    i dont see where this permission is used?

ParisLiakos’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs reroll +Needs tests

Finally we should write some tests, i will do it if noone else does.

fengtan’s picture

Thanks for the review ParisLiakos. I believe you are right:
1. The logic should lie in the actual functions.
2. ok
3. This permission does not seem to be used, guess we can remove it.
Note: the submodule is also being rolled in media as part of #1792738: Allow custom file view modes for WYSIWYG display

ParisLiakos’s picture

Status: Needs work » Closed (duplicate)