* Add enclair_db option to UserDB.pm. Allows logging of enclair password
[interchange.git] / UPGRADE
1 -----------------------------------------------------------------------------
2
3                 U P G R A D I N G     I N T E R C H A N G E
4
5
6 Interchange is designed to be drop-in compatible in its major version.
7 Briefly summarized, here's what you can expect when upgrading from the
8 following versions:
9
10  5.6.x -- Perl 5.8.5 or newer is now required to run Interchange.
11
12  5.4.x -- A number of incompatible changes were made. Most of them will be
13           simple to deal with, but please consult the list below in the
14           "Known Issues" section. Your code will almost certainly fail to
15           work properly until you make the necessary changes described!
16
17  5.2.x -- There should be few to no compatibility issues in
18           upgrading from Interchange 5.2.x.
19
20  5.0.x -- There should be few to no compatibility issues in
21           upgrading from Interchange 5.0.x.
22
23  4.8.x -- There should be only a few issues in upgrading from 4.8.x; known
24           issues are shown below. The major change is in the admin UI,
25           and you will have a distinctly different look and feel 
26           in that area. Most people find it an improvement.
27           
28  4.6.x -- Upgrading from 4.6.x and before is problematic if you rely on
29           the admin UI -- particularly if you have customized it. The public-
30           facing side should be fairly straightforward to port. See
31           "UPGRADING FROM 4.6.x" below.
32
33  ALL VERSIONS -- A security vulnerability has been found that allows
34           remote searching of any table in your database configured in
35           Interchange.  To fix this vulnerability, you may need to 
36           make some adjustments to your catalog.  See "REMOTE SEARCHING"
37           below.
38
39 INSTALLING INTERCHANGE IN THE SAME LOCATION
40 --------------------------------------------
41
42 NOTE:    All below procedures assume you have installed in
43          /usr/local/interchange -- substitute paths as appropriate.
44
45 WARNING: BACK UP EVERYTHING BEFORE YOU START!
46
47     1. Make a tar backup of your Interchange software directory, e.g.
48
49         tar czvf ~/ic_backup.tar.gz /usr/local/interchange 
50
51     2. Unpack the new version of the software to a temporary directory,
52        and change to that directory.
53
54         tar xzf interchange-5.x.x.tar.gz
55         cd interchange-5.x.x
56
57     3. You can see the section below, "TO TEST BEFORE YOU UPGRADE", if
58        you want to try it out before you switch your running catalog.
59
60     4. Install it to the same location as your current software:
61
62         ## Create the makefile
63         perl Makefile.PL
64
65         ## Make the software
66         make
67
68         ## Test -- if this fails, don't worry too much.
69         make test
70
71         ## Install the software
72         make install
73
74     5. You don't need to run makecat again!!!
75
76     6. Restart Interchange.
77
78 That's it. Verify your catalog's operation, and you are live.
79
80 ---------------------------------------------------------------------------
81
82                          K N O W N   I S S U E S
83
84
85 KNOWN ISSUES UPGRADING FROM 5.6
86
87 Perl 5.8.5 or newer is now required.
88
89 AdminUser configuration directive has been removed.
90
91 PROBLEM WORKAROUND FOR POSTGRESQL 8.3 USERS
92
93 In PostgreSQL 8.3 many implicit casts were removed, some of which Interchange
94 relied on. By default, the Standard demo and some Interchange core SQL does
95 not work with PostgreSQL 8.3.
96
97 We expect to work around this in a future version of Interchange, but at the
98 moment the easiest way to get things working is to manually put back any
99 removed casts that you need. The included eg/pg83-implicit-casts.sql script
100 fixes the known problems with the Standard demo.
101
102 This issue does not affect earlier versions of PostgreSQL.
103
104
105 KNOWN ISSUES UPGRADING FROM 5.5.2
106
107 1. Several old versions of CPAN modules were distributed in the extra/
108 directory but have been removed:
109
110     Business::UPS - part of Bundle::InterchangeKitchenSink
111     File::Spec - now distributed with Perl itself
112     Tie::ShadowHash - part of Bundle::Interchange
113     URI::URL - part of Bundle::Interchange
114
115 If you find Interchange won't start up, check to make sure you have all the
116 necessary Perl modules.
117
118 2. We have removed the option available in some polymorphs of the
119 database abstraction layer's set_slice() routine that allowed key/value
120 pairs to be passed in as a simple array. For example, this will no longer
121 work:
122
123     $db->set_slice($key, $field1, $value1)
124
125 But it can be rewritten as this, which has long worked:
126
127     $db->set_slice($key, [$field1], [$value1])
128
129 3. The syntax of the custom SQL function for counters has changed. At the time
130 of the feature's introduction on 2007-11-17, the syntax was e.g.:
131
132     UserDB  default   sql_counter  "userdb:custom_counter('userdb_username_seq')"
133
134 That conflicted with MySQL pseudo-sequence functionality that used the same
135 syntax. The new syntax does not conflict and has the benefit of being more
136 generic, allowing any SELECT statement:
137
138     UserDB  default   sql_counter  "userdb:SELECT custom_counter('userdb_username_seq')"
139
140
141 KNOWN ISSUES UPGRADING FROM 5.5.1
142
143 SpecialSub catalog_init has been renamed to request_init.
144
145 UserTrack now defaults to "no", so if you want the X-Track HTTP response header
146 to be output, add "UserTrack yes" to your catalog.cfg.
147
148 UserTrack also no longer affects TrackFile, so if you don't want TrackFile
149 output, you should not have a TrackFile directive in catalog.cfg.
150
151
152 KNOWN ISSUES UPGRADING FROM 5.4.x
153
154 Check the "special_pages/missing.html" file, in all of your Interchange-driven
155 websites, for a line that looks like the following:
156
157     [if type=explicit compare="q{[subject]} =~ m{^admin/}"]
158
159 If found then replace with the following two lines:
160
161     [tmpn missing_subject][subject][/tmpn]
162     [if scratch missing_subject =~ /^admin/]
163
164 Perl 5.8.0 or newer is now required. Running with threads is still not
165 recommended for production installations, but is allowed under Perl 5.8.5
166 or newer.
167
168 The long-deprecated [sql] tag has been removed. You'll likely want to
169 rewrite queries to use the [query] tag.
170
171 The ConfigParseComments directive has been removed, and Interchange now
172 behaves as if "ConfigParseComments No" has been specified. That means that
173 no configuration file line beginning with # will be parsed, including
174 #ifdef, #include, etc., as was done in the past. Bare ifdef, include, etc.
175 must now be used.
176
177 Global ActionMaps: Previously, the path passed to a global ActionMap
178 did not include the action itself, but the path passed to a catalog
179 ActionMap did include the action. This discrepancy was annoying to keep
180 track of. Now both kinds of ActionMaps receive a path that includes
181 the action. This means that all global ActionMap code will need to be
182 updated to deal with the action. Most simply, you can strip off the
183 action at the beginning of the sub something like this:
184
185     ActionMap your_action <<EOR
186     sub {
187         my ($path) = @_;
188         # remove action
189         $path =~ s:^[^/]+/::;
190         # your code here
191     }
192     EOR
193
194 Removed SOAP_Host, RequiredFields, HTMLmirror and UseCode directives.
195
196 All previously deprecated configuration directives have been removed.
197
198 Deprecated-feature pragmas and associated code have been removed:
199 * compatible_5_2 - used to keep table editor error text (mistakenly)
200   hidden, as it was the case up to Interchange 5.2.
201 * no_html_parse - used to disable parsing of MV= arguments inside HTML tags.
202
203 If MV_COUNTRY_FIELD was in use to determine the country for tax
204 purposes, then that setting needs to be changed to MV_COUNTRY_TAX_VAR.
205
206 The [either] tag historically reparsed its output. This has been changed
207 so that while the tag body parts are interpolated, the tag output is not
208 reparsed.
209
210 Removed the [fedex-query] tag, which hasn't been useful for some time
211 because FedEx discontinued their web API that the tag interfaced with.
212
213 Removed the [/page] and [/order] macros. The [page] and [order] tags have
214 never been container tags; [/page] and [/order] were macros that were
215 replaced with </a>. You should now just use </a> in HTML instead.
216
217 The various *Robot* directives have been split from the interchange.cfg
218 file into a new robots.cfg file.  If you are upgrading then you will
219 need to remove any existing *Robot* directives from your interchange.cfg
220 file and add "include robots.cfg" in their place.
221
222 A new subdomains.cfg file has been created, and should be included into
223 your interchange.cfg file with "include subdomains.cfg".  This file defines
224 a list of country-specific standardised subdomains that should be taken
225 into account when the DomainTail directive is in effect.
226
227 The session per IP counters have been changed to the new "timecard" round-robin
228 style counters.  You will need to delete the old counter files from the
229 tmp/addr_ctr directory with a command similar to the following:
230
231     rm -rf catroot/tmp/addr_ctr/*
232
233 ...be careful with the above command. If mistyped it can seriously mess up
234 your filesystem.
235
236 The [error] and [formel] tags now make use of the following CSS class,
237 that will need to be added to your CSS file:
238
239     .mv_contrast {
240         color: #FF0000;
241     }
242
243 The name of the class can be specified using the CSS_CONTRAST Variable,
244 or will default to "mv_contrast".
245
246
247 KNOWN ISSUES UPGRADING FROM 5.2.x
248
249     None.
250
251
252 KNOWN ISSUES UPGRADING FROM 5.0.x
253
254     None.
255
256
257 KNOWN ISSUES UPGRADING FROM 4.8.x
258
259 Interchange is designed to be compatible between major versions, and
260 for the most part a catalog designed under Interchange 4.8 should
261 be compatible with 5.0.
262
263 More information on upgrades is available in the document icupgrade, part
264 of the Interchange documentation package.
265
266 UPGRADE NOTES FOR FOUNDATION-STYLE CATALOGS
267 -------------------------------------------
268
269 * Add a new column "extended" to products/mv_metadata.asc. This just involves
270   adding a TAB and "extended" to the end of the first line of the file.
271
272 * If MV_COUNTRY_FIELD was in use to determine the country for
273   tax purposes, then that setting needs to be changed to
274   MV_COUNTRY_TAX_VAR.
275
276 * Remove variables UI_IMAGE_DIR and UI_IMAGE_DIR_SECURE or point
277   them to the new location, e.g. replace /interchange/
278   with /interchange-5/.
279
280 * If you didn't follow Interchange's SKU naming convention for Matrix
281   options, and assigned them arbitrary part numbers, or you hand-edited
282   the options table, you may find that your product options don't work. 
283   You should post the question to the user mail list or contact a
284   competent Interchange consultant at interchange-biz@icdevgroup.org.
285
286 * You will probably receive a message about "history-scan tag overrides global
287   definition". See the section "PROBLEMS WITH USERTAGS" below.
288
289 * The static-page build capability is no longer supported in
290   Interchange 5. You will receive warnings about "Directive StaticPath
291   no longer supported at line XXX". 
292
293   To stop these warnings, remove the NoCache directive and any
294   directive beginning with "Static" from your catalog.cfg file.
295   In the standard-style catalog, these are all located near
296   each other.
297
298   If you use the static page build facility, there are other means of
299   accomplishing the same thing with scripts. Contact a competent
300   Interchange consultant at interchange-biz@icdevgroup.org to get help.
301
302 * See the section "PROBLEMS WITH USERTAGS" below.
303
304 ---------------------------------------------------------------------------
305
306 TO TEST BEFORE YOU UPGRADE
307 --------------------------
308
309 YOU SHOULD STILL BACK UP, and in addition it is recommended you back
310 up your catalog. While the new server should not impact your running
311 catalog beyond normal catalog interaction for orders, statistics,
312 userdb, and such, it is not outside of the realm of possiblity that
313 something could happen. It should not happen in a catalog that is
314 based on Foundation and not heavily customized (i.e. using global UserTag
315 routines).
316
317 1. Install the new Interchange 5.x.x in /usr/lib/interchange-5.x.x
318 using the procedure from the README file.
319
320 2. Make /usr/lib/interchange-5.x.x/interchange.cfg match your
321 /usr/lib/interchange.cfg. Note that there may be new options; but the
322 existing one should work if you just copy it.
323
324 3. Run bin/compile_link:
325
326     cd /usr/lib/interchange-5
327     bin/compile_link -p 7787
328
329 NOTE: If you use the INET mode linking method, you have to run the
330       test server on a different port. Assuming you use the standard
331       7786 on your live catalog, you would add to interchange.cfg:
332
333          TcpMap  localhost:7787
334
335 After running compile_link, you should see four new files in the
336 /usr/lib/interchange-5.x.x/src:
337
338 -rwxr-xr-x  1 root  root  8088 Oct  3 09:59 tlink
339 -rwxr-xr-x  1 root  root  8088 Oct  3 09:59 tlink.localhost.7787
340 -rwxr-xr-x  1 root  root  7704 Oct  3 09:59 vlink
341 -rwxr-xr-x  1 root  root  7704 Oct  3 09:59 vlink._usr_lib_interchange_5_etc_socket
342
343 4. Note the Catalog lines in your interchange.cfg:
344
345   EXAMPLE:
346
347     Catalog standard /var/lib/interchange/standard /cgi-bin/standard
348
349 You should comment out all but the one you want to test.
350
351 5. Change the /cgi-bin/standard script link name to /cgi-bin/test5.
352
353   EXAMPLE:
354
355     Catalog standard /var/lib/interchange/standard /cgi-bin/test5
356
357 6. Copy the src/vlink (UNIX mode) or src/tlink (INET mode) link executable
358 to your CGI directory and name it "test5", i.e.
359
360   EXAMPLE:
361
362     cp -p src/vlink /var/www/cgi-bin/test5
363
364 7. IMPORTANT: Make sure its permissions match the permissions on your
365 running 4.x catalog! You may have to make it SUID, i.e.:
366
367   EXAMPLE:
368
369     chmod u+s /var/www/cgi-bin/test5
370
371 That should only be done if you are in UNIX mode and your current 
372 link program is SUID.
373
374 8. Add this line to the /usr/lib/interchange-5/interchange.cfg file:
375
376     Variable TEST_SERVER 1
377
378 9. Copy any *custom* global UserTag files to the usertag/ directory. Do not
379 copy any that were distributed with Interchange if you did not modify them.
380
381 10. Copy the new Interchange image and CSS files to the interchange-5
382 subdirectory in your document root, i.e.:
383
384         EXAMPLE:
385
386                 cp -r /usr/lib/interchange-5/share/interchange \
387                           /var/www/html/interchange-5
388
389 11. Modify your /var/lib/interchange/standard/catalog.cfg file to
390 point the URLs to the test server if appropriate by placing at the
391 end:
392
393    ifdef @TEST_SERVER
394    Variable  CGI_URL             /cgi-bin/test5
395    Variable  UI_IMAGE_DIR        /interchange-5/
396    Variable  UI_IMAGE_DIR_SECURE /interchange-5/
397    ## This ensures the UI image directory will be set properly
398    Pragma    dynamic_variables_file_only
399    VendURL   http://__SERVER_NAME____CGI_URL__
400    SecureURL   https://__SERVER_NAME____CGI_URL__
401    endif
402
403 12. Start the new interchange server:
404
405     /usr/lib/interchange-5/bin/restart
406
407 At that point, your catalog should be running on both Interchange 5 and
408 Interchange 4. Test thoroughly and then upgrade. Note that the UI will
409 be significantly changed, and that all features of the UI may not be
410 supported by your old catalog. The customer-facing side should function
411 in much the same way.
412
413 ------------------------------------------------------------------------
414
415 UPGRADING FROM 4.6.x
416
417 The public-facing side of a 4.6.x catalog is fairly straightforward to
418 port. The Admin UI is problematic, particularly if you have customized
419 it.
420
421 You should be able to update a catalog from 4.6.x if you are reasonably
422 proficient in Perl and/or Interchange. If you expect to rely on the
423 backend admin UI, it is sometimes better to build a new catalog from
424 scratch, and integrate your look and feel with that. Contact a competent
425 Interchange consultant to help (interchange-biz@icdevgroup.org).
426
427 That being said, here are some of the issues.
428
429 If you have this line in interchange.cfg:
430
431         #include usertag/*
432
433        You should change it to:
434
435         include usertag/*.tag
436
437        (The leading # sign is no longer needed).
438
439        If you have created any other UserTag definitions you will need
440        to either rename the file to add a .tag extension, or include
441        them explicitly like:
442
443           include usertag/my_tag
444
445        See the "problems with UserTags" section, below.
446
447 If you use CyberCash, you should replace these lines in catalog.cfg
448
449         Variable CYBER_MODE       mauthonly
450         Variable CYBER_CONFIGFILE /path/to/your/merchant_conf
451
452     with
453
454         Variable MV_PAYMENT_MODE        cybercash
455         Variable MV_PAYMENT_CONFIGFILE  /path/to/your/merchant_conf
456
457 There is one security change that can break constructs that ran under 4.6.x.
458
459     safe_data=1
460
461         If you had a database object which contained ITL tags and
462         they now show up as [itl-tag arg=val], then you probably
463         need to add the safe-data=1 parameter around your [loop ...]
464         or [query ...] construct.
465
466         The reason this change was made was the capability of Interchange
467         to directly enter user submissions into a database. If the
468         user put in something in [square brackets], knowingly or even
469         unknowingly, it could cause anomalous or insecure behavior. 
470         (There were no known exploits in the demo, but they could
471         easily be constructed.)
472
473
474 PROBLEMS WITH USERTAGS
475 ----------------------
476
477 You may see the following error/warning messages when you (re)start
478 Interchange:
479
480 1. Duplicate usertag xxxx found.
481
482     This message is most likely to mean that you have a global "usertags"
483     directory included from your interchange.cfg file.  Interchange 4.9 has a
484     new location (code/UserTag) for global UserTags.  Your old globals may
485     "clash" with the new ones.  Delete the old usertags that are named in the
486     error messages.  As always, it is recommended that you back up everything
487     before you start.
488
489     This message will also be raised if Interchange notices two local UserTags
490     with the same name.  If this is detected then rename or delete one of the
491     two UserTags.
492
493 2. Local usertag xxxx overrides global definition.
494
495     This message is most likely to refer to your local history_scan UserTag.
496     If you have this tag definition in your catalog.cfg file then you may
497     safely delete it;  Interchange 4.9 includes this as a global UserTag.
498
499     This message will also be raised if you have created a local UserTag
500     and have given it a name identical to one of the global tags (SystemTag,
501     UserTags, UI_Tag etc.)  The message is only a warning as your local UserTag
502     will override the global one.  If you didn't mean to override the global
503     tag of the same name then simply rename your tag and restart Interchange.
504
505
506 REMOTE SEARCHING
507 ----------------
508
509 A security vulnerability was recently discovered where any table configured
510 in your Interchange installation could be viewed remotely by an unauthenticated
511 user via a specially crafted search request.
512
513 This is a serious vulnerability, and all previous versions of Interchange are
514 affected. Even if you do not use the default search structure, your catalog
515 is likely to still be vulnerable.
516
517 To resolve this, a new configuration option, AllowRemoteSearch has been
518 introduced. It should be specified in each catalog configuration, and defaults
519 to:
520
521      AllowRemoteSearch products variants options
522
523 Any table specified in this option will be remotely searchable, and you should
524 not permit any table with sensitive information to be searched in this way. You
525 should carefully consider the implications of adding any further tables to this
526 configuration option.
527
528 Remote searches may be used by your existing catalog. These should continue
529 working without any changes as long as they only search tables that are permitted
530 by the AllowRemoteSearch configuration. You should carefully examine your
531 catalog for uses of the "search" form action, or pages which submit a form to
532 a page called "search" or "scan". If they specify a search file other than
533 products, variants or options, you should consider rewriting that page to just
534 accept the search terms via CGI parameters, and not the entire search. Please
535 consult the documentation on in page searches at:
536
537      http://www.icdevgroup.org/doc/icdatabase.html#In-Page%20Searches
538
539 If your catalog makes use of ActionMaps that perform searches, these should
540 continue to work as intended as long as they search a table allowed by 
541 AllowRemoteSearch. However, you should consider updating them to use the 
542 new "search" tag.  For example, an existing ActionMap that performs a search
543 like this:
544
545    ActionMap old_cat <<EOR
546    sub {
547         my ($action, $class) = split('/', shift);
548
549         $class =~ s/_/ /g;
550
551         # Originally, search parameters were placed in the CGI hash.
552         $CGI->{co} = 1;
553         $CGI->{fi} = 'products';
554         $CGI->{st} = 'db';
555         $CGI->{sf} = 'category';
556         $CGI->{se} = "$class";
557         $CGI->{sp} = 'results';
558         $CGI->{tf} = 'category,description:f';
559         $CGI->{op} = 'eq';
560
561         $CGI->{mv_todo} = 'search';
562         $CGI->{mv_nextpage} = 'results';
563         # And the "update" tag was called to re-evaluate the page with
564         # the provided search parameters.
565         $Tag->update('process');
566         return 1;
567    }
568    EOR
569
570 Would be updated to instead look like this:
571
572    ActionMap new_cat <<EOR
573    sub {
574         my ($action, $class) = split('/', shift);
575
576         $class =~ s/_/ /g;
577
578         # Now, you must create a hash to hold the search
579         # parameters.
580         my $search;
581         $search->{co} = 1;
582         $search->{fi} = 'products';
583         $search->{st} = 'db';
584         $search->{sf} = 'category';
585         $search->{se} = "$class";
586         $search->{sp} = 'results';
587         $search->{tf} = 'category,description:f';
588         $search->{op} = "eq";
589
590         $CGI->{mv_nextpage} = 'results';
591         # And call the new search tag, which isn't subject to the
592         # AllowRemoteSearch restrictions.
593         $Tag->search({ search => $search });
594
595         return 1;
596    }
597    EOR
598
599 If you are using a modern version of the standard catalog as the basis
600 for your catalog, there is a special subroutine that provides friendly
601 URLs for product categories, but is not a traditional ActionMap.  Similar
602 to the example above, you will need to alter your catalog.cfg, replacing
603 the entire Sub ncheck_category with:
604
605 Sub ncheck_category <<EOS
606 sub {
607     my ($name) = @_;
608     return unless $name =~ m{^[A-Z]};
609     $name =~ s,_, ,g;
610     my ($prod_group, $category) = split m{/}, $name;
611
612     my $search;
613     $search->{co} = 1;
614     $search->{fi} = 'products';
615     $search->{st} = 'db';
616     $search->{sf} = join "\0", 'prod_group', 'category';
617     $search->{op} = join "\0", 'eq', 'eq';
618     $search->{se} = join "\0", $prod_group, $category;
619     $search->{sp} = 'results';
620     $search->{mv_todo} = 'search';
621     $Tag->search({ search => $search });
622     if (($o = $Search->{''}) && @{$o->{mv_results}}) {
623         return (1,  $Config->{Special}->{results});
624     }
625
626     return;
627 }
628 EOS
629
630 In the standard and foundation catalogs, the "lost password" feature makes use
631 of the remote search feature to be able to retrieve lost passwords. We recommend
632 that you remove catalog/pages/query/get_password.html from your catalog, and
633 replace catalog/pages/query/lost_password.html with an updated version from this
634 distribution. As an alternative, you may apply the following patch to your
635 existing catalog/pages/query/get_password.html:
636
637 diff --git a/dist/standard/pages/query/get_password.html
638 b/dist/standard/pages/query/get_password.html
639 index 2d70c84..5aa51f1 100644
640 --- a/dist/standard/pages/query/get_password.html
641 +++ b/dist/standard/pages/query/get_password.html
642 @@ -32,8 +32,10 @@ ui_template_name: leftonly
643         if( $Scratch->{tried_pw_retrieve}++ > 10 ) {
644                 return "No way, Jos&eacute;. Too many times.";
645         }
646      $CGI->{mv_todo} = 'search';
647         $Config->{NoSearch} = '';
648 +       push(@{$Config->{AllowRemoteSearch}},'userdb');
649 +       return;
650  [/perl]
651  [update process]
652  [search-region]
653
654 This is not a recommended solution, and is only a workaround until you can
655 consider the changes in the updated lost password page.
656
657 If you do not wish to upgrade your Interchange installation to fix this
658 vulnerability, patches for all currently supported Interchange versions are
659 also available from http://www.icdevgroup.org/. You will still need to
660 follow the upgrade advice contained here.