Opened 12 years ago

Closed 11 years ago

#1244 closed Bug (fixed)

Wrong variable renaming related to constants

Reported by: Frederico Caldeira Knabben Owned by:
Priority: Normal Milestone:
Component: Project : CKPackager Version:
Keywords: Cc:

Description

The following variables:

var IDM_ASSIGNABLEUNIT = 28;
var IDM_CHAPTER = 29;
var IDM_SECTION = 30;
var IDM_PAGE = 31;
var IDM_OBJECT = 32;
var IDM_ACTION = 33;

Get changed to this:

var IDM_ASSIGNABLEUNIT = 28;
var IDM_2 = 29;
var IDM_3 = 30;
var IDM_4 = 31;
var IDM_OBJECT = 32;
var IDM_6 = 33;

Because of the following definitions in the fckpackager.xml file:

<Constant name="CHAPTER" value="2" />
<Constant name="SECTION" value="3" />
<Constant name="PAGE" value="4" />
<Constant name="CWOBJECT" value="5" />
<Constant name="ACTION" value="6" />

Change History (2)

comment:1 Changed 11 years ago by Joe Wieloch

I was able to fix this behavior by modifying fckpackager.php

FCKConstantProcessor class:

$output = preg_replace_callback(
	'/(?<!var\\s|...\.|\\w)(?:' . $this->_ContantsRegexPart . ')(?!\\w)/',
	array( &$this, '_Contant_Replace_Evaluator' ), $output ) ;

The changes are in the lookbehind var s was changed to var\s and \w was added as a condition. The \s matches the condition in the code above this (in fckpackager.php) that checks for a constant's declaration. The \w keeps the packager from modifying subparts of other variables and fixes the problem stated in this bug.

We currently pack some 181 js files, the largest being approx. 350k bytes. We do not see any issues with the above code, but wanted to post this description in the event there is a special case we are missing.

comment:2 Changed 11 years ago by Wojciech Olchawa

Resolution: fixed
Status: newclosed

The packager output is now:

var IDM_ASSIGNABLEUNIT=28;var IDM_CHAPTER=29;var IDM_SECTION=30;var IDM_PAGE=31;var IDM_OBJECT=32;var IDM_ACTION=33;

as is suppose to be.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy