How-to avoid double post into custom modules

Author Message

Sébastien Antoniotti

Monday 14 December 2009 2:02:10 am

Hi,

I have a custom module who creates eZ objects based on post data.

After the publication made by the module, I would like to redirect the user to some view and disable the possibility to re-post the form (with F5 by example).

The problem is that $module->redirect... does the redirection but post data are still here.

I think a header redirection can do the job but I haven't found how to redirect properly to a custom module/view...

any ideas ?

eZ Publish Freelance
web : http://www.webaxis.fr

Łukasz Serwatka

Monday 14 December 2009 2:19:01 am

Hi,

There are few possibilities. Easiest will be set session variable after object was created and check it before. Or set a remote_id for created object which will be a hash included in the POST array and check if object exists with such remote_id if so then you skip creation process.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Sébastien Antoniotti

Monday 14 December 2009 2:47:23 am

Thanks Lukasz for the advice !

Meanwhile I found the following solution which is to redirect in 301 on the confirmation page.

In this way, post data no longer exist.

// redirect
eZHTTPTool::redirect( eZSys::indexDir().'/member/mywallet', array(), 301 );
eZExecution::cleanExit();

Cheers,

Seb

eZ Publish Freelance
web : http://www.webaxis.fr

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 29 2025 13:31:32
Script start
Timing: Jan 29 2025 13:31:32
Module start 'layout'
Timing: Jan 29 2025 13:31:32
Module start 'content'
Timing: Jan 29 2025 13:31:32
Module end 'content'
Timing: Jan 29 2025 13:31:32
Script end

Main resources:

Total runtime0.0140 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.2656151.2266
Module start 'layout' 0.00510.0029 739.492236.6797
Module start 'content' 0.00800.0045 776.171990.1875
Module end 'content' 0.01250.0014 866.359433.9922
Script end 0.0139  900.3516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002417.3209140.0002
Check MTime0.00117.5468140.0001
Mysql Total
Database connection0.00064.616510.0006
Mysqli_queries0.002517.996730.0008
Looping result0.00000.114310.0000
Template Total0.00117.810.0011
Template load0.00085.848710.0008
Template processing0.00031.925110.0003
Override
Cache load0.00064.130110.0006
General
dbfile0.00021.611180.0000
String conversion0.00000.058040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs