Hi folks,
Before I start, sorry the length of this post, but I'm at the end of
my tether with this one...
I've been ripping chunks of hair out over the past two days trying
to diagnose a problem with one out of two near identical blocks of
code in an application I am working on.
The code forms a small part of the set-up routine to export content
from one server for staging/syndication to another - it's essentially
an early prototype for a larger system.
The code that is troubling me basically does this:
- extracts one or more records from a content database
- loops over each record in the query result set, and
+ deserialises the WDDX-encoded structure
stored in szContent
+ searches for a particular key ("filename" in
this structure
+ adds the value contained in the filename element
to a list created outwith the loop
- loop ends
Sample (slightly simplified) structures are shown below:
IMAGE ASSET ALIGN
CAPTION
FILENAME
HEIGHT
WIDTH
FEATURE BODY
TEASER
TEASER IMAGE (embed the "IMAGE ASSET" struct above)
TITLE
Okay, looking at the simplified psuedo-code above, here's what
works:
- the database query is fine
- the loop kicks off great
+ the WDDX is deserialised back into a struct
+ an error is thrown, on the SECOND LOOP ITERATION
when StructFindKey is called and...
+ .. we don't get here
- loop crashes out
The error message is: "Cannot assign result to symbol
Variables.stAssetVersion"
where Variables.stAssetVersion is the name of the structure recreated each
time in the loop I call CFWDDX on szContent.
This is accompanied by an "error has occurred while processing the
expression
Variables.stAssetVersion=CFTempOnlyForSetVariableNeverUseThisNameInYourCFMLC
ode
122333444455555654321" which we all know and love...
I know it's not CFWDDX which is causing it (despite the error message above)
because I can remove all the code following it, replace it with a CF_DUMP (a
custom tag we use for CF 4.5 based on CFA_DUMP in Spectra) and it shows me
a struct - not WDDX.
The error is only introduced when I call StructFindKey. Bizarrely though, it
works the first time round throwing the error on the second loop iteration.
Is StructFindKey somehow locking the struct it searches through and not
releasing.
I have replaced the call to StructFindKey with a collection loop which
basically
does the same job and even creates the same array/struct combo such that the
code
below the (replaced) call to StructFindKey works as expected.
Now for the real killer, this loop is performed twice - once for the
"content
created" query and the second time for the "content modified" query. The
loop
including StructFindKey _always_ works for the modified content, but it
_always_ fails for the created content.
I've tried swapping the loops around (doing the created loop before and
after
the modified loop but to no avail); I've stripped all the code right back
removing all but the call to CFWDDX and StructFindKey; I've tried locking
the
code obsessively; I've switched CF to "Single Threaded Sessions" and that
made
no difference; I've removed the "modified" loop so it's only the "created"
loop which runs; I've serialised the query results into WDDX, stored them in
files and read these in before the loop in case the query was somehow
affecting
it. The final straw - I moved the test files (which use the WDDX queries,
not the database) to a different dev location with a new Application.cfm to
ensure that the app was not somehow affecting the loops and that still
didn't
work.
I moved my test package to a different server I had access to (WinNT Server,
same version of CF) and it failed there too...
I've got a workaround for the problem using my manual "struct find key" but
that
limits its flexibility as it only handles one nested struct level - I don't
want to write a recursive custom tag (or UDF for CF5 which I've not
installed
yet) for something that looks like a bug in CF 4.5.1 SP-2.
I've searched Macromedia, the Knowledge Base, the Forums, the CF-Talk
archive
and Google Groups but I seem to be pretty much alone in this one.
Would anyone (a) have any ideas on what is going on and how to fix it and/or
(b) be prepared to take a look at my test package (which I can supply if
needed) to see if it affects you too?
Thanks in advance,
Colin
P.S. Sorry again for the length of this post!
______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
Instant Activation � $99/Month � Free Setup
http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists