Closed GoogleCodeExporter closed 9 years ago
One of the work arounds for now is to use a different name for it
Original comment by albertdi...@gmail.com
on 20 Dec 2013 at 5:32
I think this is important
Original comment by albertdi...@gmail.com
on 31 Jan 2014 at 3:57
ctrl_abstract:
public function process_mode( $common_gpc = array() ) {
$mode = $this->mode;
$method_name = "process_mode_$mode";
if (method_exists($this,$method_name)) {
$gpc_key_var = "mode_gpc_$mode";
$mode_gpc = array();
if ( isset( $this->$gpc_key_var ) ) {
$mode_gpc = $this->recursive_compact( $this->$gpc_key_var );
}
else if ($mode != 'default') {
throw new e_developer(get_called_class()."->$gpc_key_var not declared");
}
$reserved_gpc = array('mode' => $this->mode);
if (!empty($this->sub_mode)) {
$reserved_gpc['sub_mode'] = $this->sub_mode;
}
$merged_gpc = array_merge($reserved_gpc, $common_gpc, $mode_gpc);
$this->assign($merged_gpc);
$this->assign('mode',$mode);
$this->assign('sub_mode',$this->sub_mode);
return $this->$method_name($merged_gpc);
}
else {
$this->mode = 'default';
$this->assign($common_gpc);
$this->assign('mode','default');
}
return false;
}
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 5:19
ctrl_tpl_page:
/**
* The pre-display process of the controller
* (former $this->process())
*
* @since ADD MVC 0.0
*
* @version 0.1
*
* @param array $common_gpc
*
* @todo ADD MVC 1.0: remove version 0.5 and version 0.8 support
*/
public function process_data( $common_gpc = array()/* ADD MVC 0.8 support */) {
$this->pre_mode_process( $common_gpc );
# ADD MVC 0.5 backward support
if (method_exists($this,'process')) {
return $this->process();
}
$process_mode_result = $this->process_mode( $common_gpc );
$this->post_mode_process( $common_gpc );
}
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 5:20
solution 1.0:
we have to pass an updated $common_gpc to process_mode and post_mode_process
question: how to pass the updated var?
possible solution: pass $this->data instead
^ ALL WRONG
the problem is here
$merged_gpc = array_merge($reserved_gpc, $common_gpc, $mode_gpc);
$this->assign($merged_gpc);
$this->assign('mode',$mode);
$this->assign('sub_mode',$this->sub_mode);
$this->assign($merged_gpc) overwrites the update variables
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 5:24
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 5:24
Weird: On this code, it appears as if that $this->data doesn't exist yet
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 5:25
Well it probably doesn't exist yet
/**
* Process before the main mode process
*
* @param array $common_gpc
* @since ADD MVC 0.9
*/
public function pre_mode_process($common_gpc) {
}
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 5:36
Possible fix:
$merged_gpc = array_merge($this->data,$reserved_gpc, $common_gpc, $mode_gpc);
$this->assign($merged_gpc);
$this->assign('mode',$mode);
$this->assign('sub_mode',$this->sub_mode);
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 5:37
I think I need a testing file first
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 5:38
This:
$merged_gpc = array_merge($reserved_gpc, $common_gpc, $mode_gpc,$this->data);
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 5:48
test file:
<?php
require 'add_configure.php';
CLASS ctrl_issue_129 EXTENDS ctrl_tpl_page {
public $common_gpc = array(
'_GET' => array( 'x' )
);
public $mode_gpc_test = array();
public function pre_mode_process($common_gpc) {
debug::var_dump($common_gpc);
$this->assign('x',$common_gpc['x']+1);
debug::var_dump($this->data);
}
public function process_mode_test($gpc) {
debug::var_dump($gpc,$this->data['x']);
}
}
$ctrl = new ctrl_issue_129();
$ctrl->execute();
Original comment by albertdi...@gmail.com
on 3 Mar 2014 at 6:00
Revision #1870
Original comment by albertdi...@gmail.com
on 24 Sep 2014 at 3:23
Original comment by albertdi...@gmail.com
on 24 Sep 2014 at 3:23
Original comment by albertdi...@gmail.com
on 28 Jan 2015 at 4:56
Original issue reported on code.google.com by
albertdi...@gmail.com
on 20 Dec 2013 at 5:23