Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Unidentified Issue in Code crashes Dreamweaver 2017

Community Beginner ,
Jan 05, 2017 Jan 05, 2017

Copy link to clipboard

Copied

I have a few php files that I am unable to open without crashing the app.  There must be an issue with my coding style or something that I haven't yet Identified.  The files open fine in brackets and other editors.  Most of the files aren't very large, only a few kb.  They don't generate any errors compiling or at runtime so I know the code is valid.  But something about the code itself Dreamweaver doesn't like because just creating a new file and inserting the same code crashes the app.

Anyone else experienced this and / or identified the issue?

TIA

Views

1.3K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Jan 05, 2017 Jan 05, 2017

Hi Ben,

While grabbing you a snippet I happened to find the culprit at least for this file I think.

It appears Dreamweaver doesn't like me unpacking a constant... On line 22 I have a constant array value ( ROLES ) that I apply as arguments with the ( ... ) spread operator.  If I switch it to a variable representation ( $ROLES ) the app doesn't crash.

<?php namespace byto; !DIRECT || die( 'Oops...' );

/* *                                                * *

    *****************************************

...

Votes

Translate
Community Expert ,
Jan 05, 2017 Jan 05, 2017

Copy link to clipboard

Copied

Any chance of posting problem code?

Wappler, the only real Dreamweaver alternative.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 05, 2017 Jan 05, 2017

Copy link to clipboard

Copied

Hi Ben,

While grabbing you a snippet I happened to find the culprit at least for this file I think.

It appears Dreamweaver doesn't like me unpacking a constant... On line 22 I have a constant array value ( ROLES ) that I apply as arguments with the ( ... ) spread operator.  If I switch it to a variable representation ( $ROLES ) the app doesn't crash.

<?php namespace byto; !DIRECT || die( 'Oops...' );

/* *                                                * *

    ************************************************

    --- CLASS FOR MANAGING  ROLES & CAPABILITIES ---

    ************************************************

* *                                                * */

// CREATE ROLES CONSTANT

con( 'roles', ( new Roles() )->names() );

con( 'ROLES', array_map( 'strtoupper', $roles = array_keys( roles ) ) );

// CREATE THE INITIAL ROLES BITMASKS

// SET MODIFIER RESERVATIONS FIRST

wize::caps( 'ALL', 'NONE', 'OR_DIE', 'CAPS', ...ROLES );     // UNPACKING - OR RATHER THE SYNTAX OF UNPACKING - A CONSTANT WITH

                                                             // THE SPREAD OPERATOR IS WHAT THE APP HAS AN ISSUE WITH.

// CREATE STRING CONSTANTS

strconst( 'admin', ...$roles );

// ALIASES

walk([

  'ADMIN'   => ADMINISTRATOR,

  '»admin'  => ADMINISTRATOR,

  'DEV'     => DEVELOPER,

  'USER'    => MEMBER,

], function( int $mask, string $alias ) { wize::caps( $alias, $mask ); } );

// CREATE A MAP TO THE ROLE CAP AND ROLE MASK AND ALIAS

$ROLES_CAP_MAP = array_combine( $roles, ROLES );

array_walk( $ROLES_CAP_MAP, function( &$mask, $role ) { wize::caps( "»$role", $mask = constant( Ns.$mask ) ); } );

con( 'ROLES_MASKS', $ROLES_CAP_MAP );

con( 'MASKS_ROLES', array_flip( $ROLES_CAP_MAP ) );

// ADD PREFIXED ALIASES

foreach( ROLES as $ROLE ) :

  $bit_value = constant( Ns.$ROLE );

  wize::caps( "CAN_$ROLE", $bit_value );

  wize::caps( "ROLE_$ROLE", $bit_value );

endforeach;

// CREATE ALIASES

wize::caps( 'CAN_ADMIN', ADMINISTRATOR );

wize::caps( 'ROLE_ADMIN', ADMINISTRATOR );

wize::caps( 'ALL_ROLES', fold( ROLES_MASKS ) );

// FILTER OUT ROLES FOR AT LEAST ROLE OPTION

wize::caps( 'MIN_TEAM',     $MIN = ADMIN|DEV|MGR|TEAM );

wize::caps( 'MIN_MEMBER',   $MIN );

wize::caps( 'MIN_MANAGER',  $MIN &= ~TEAM );

wize::caps( 'MIN_MGR',      $MIN );

wize::caps( 'MIN_DEV',          $MIN &= ~MANAGER );

wize::caps( 'MIN_DEVELOPER',    $MIN );

wize::caps( 'MIN_ADMIN',    $MIN &= ~DEV );

// LIMIT ROUTES FOR SPECIFIC GROUPS OF MAX CAP

wize::caps( 'NO_ADMIN',   $MAX = (ALL_ROLES & ~ADMIN) );

wize::caps( 'MAX_DEV',    $MAX );

wize::caps( 'NO_DEV',          $MAX &= ~DEV );

wize::caps( 'MAX_MANAGER',     $MAX );

wize::caps( 'NO_MANAGER',      $MAX &= ~MANAGER );

wize::caps( 'MAX_TEAM',        $MAX );

// SHORCUT FOR USER CAN

function can( $cap ) { return user()->CAN( $cap ); }

// GETS THE ROLE PASSED IN THE DESIRED FORMAT

//(OR OPOSITE FORMAT AS THE CASE WILL USUALLY BE)

function get_role( $role, $type = NULL ) {

    

     switch( $type ?? ( $role & ALL_ROLES ? Str : Int ) ) :

          case Int:

              

               if( $role & ALL_ROLES )

               foreach( ROLES_MASKS as $mask )

               if( $role & $mask )

               return $mask;

              

               return ROLES_MASKS[ $role ] ?? ADMINISTRATOR;

          

          case Str:

               

               // GET STRING FOR ROLE

               if( isset( MASKS_ROLES[ $role ] ) )

               return MASKS_ROLES[ $role ];

               

               foreach( ROLES_MASKS as $_role => $mask )

               if( $role & $mask )

               return $_role;

     

     endswitch;

    

     return 'administrator';

}

  if( $role & ALL_ROLES )

  foreach( ROLES_MASKS as $mask )

  if( $role & $mask )

  return $mask;

  return ROLES_MASKS[ $role ] ?? ADMINISTRATOR;

  case Str:

  // GET STRING FOR ROLE

  if( isset( MASKS_ROLES[ $role ] ) )

  return MASKS_ROLES[ $role ];

  foreach( ROLES_MASKS as $_role => $mask )

  if( $role & $mask )

  return $_role;

  endswitch;

  return 'administrator';

}

Going to check now and let you know but I assume I have something like this in the other symptomatic scripts.

Thanks for the volley Ben

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 10, 2017 Jan 10, 2017

Copy link to clipboard

Copied

Same issue with my other files.

Here is my quick workaround for now.  Just assign to a temp var inside parens.

// THIS CRASHES

myFunc( ...CONSTANT );

// THIS WORKS

myFunc( ...( $temp = CONSTANT ) );

It would be interesting to know what exactly is crashing.  Is it validation, code hints, parsing?  Maybe some preference setting could bypass it.

Anyway hope this helps someone or even better gets patched soon .  Thanks again!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 17, 2017 Aug 17, 2017

Copy link to clipboard

Copied

Hi,

Thanks for the detailed steps, we were able to reproduce this crash at our end. Also, this crash is only occurring if the PHP version used is 5.6 and since before Dw 17.1 update the version supported was 5.6 so it occurs there as well.

Apart from the workaround suggested by you, if you are using Dw 17.1 or above please try using PHP 7.6 and you wont see the crash.

We have raised this issue to the team and will get this fixed.

Regards,

Niharika Gupta

Adobe Dreamweaver

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 01, 2017 Sep 01, 2017

Copy link to clipboard

Copied

LATEST

Hi,

We have fixed the issue as stated above, and it will be available in the next release of Dw. If you are a pre-release user, you can go ahead and verify the fix in the build shared.

Regards,

Niharika Gupta

Adobe Dreamweaver

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines