Welcome Guest, Not a member yet? Register   Sign In
Upgrade from CI 1.6.0 to CI 1.7.2
#1

[eluser]popovich[/eluser]
Hello,

have just upgraded from CI 1.60 to 1.72 and have some issues with the code.

Code:
PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for Mc_answers::Mc_answers(), called in J:\***\WWW_dev\system\libraries\Loader.php on line 928 and defined
Filename: libraries/Mc_answers.php
Line Number: 5

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: module_name
Filename: libraries/Mc_answers.php
Line Number: 8

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: module_name
Filename: libraries/Mc_answers.php
Line Number: 8

A PHP Error was encountered
Severity: Notice
Message: Undefined index: answers
Filename: controllers/dispatcher.php
Line Number: 123

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: libraries/Parser.php
Line Number: 55

Before I go deep into the code, which was working fine in 1.60 — has something changed so radically, that I need to review my code now?

Thanks,
A
#2

[eluser]popovich[/eluser]
OK, maybe the code will help the situation.

From the controller:
Code:
# modules
        $pos = array('left','top','right','bottom');
        $modules = array();
        foreach ( $pos as $p ) {
            $ref_part = 'modref_'.$p;
            $parser_part = 'modules_'.$p;
            $module_content['mods'] = $this->init_modules( $this->GLO[$ref_part] );
            $this->GLO[$parser_part] = ( $module_content['mods'] ) ? $this->parser->parse('partials/modules_'.$p, $module_content) : '';
        }

    # init_models
    #
    # expects:        array
    # returns:        array
    # description:    loads and evaluates classes, the modules with the fixed orientation on the page
    #
    
    function init_modules( $modules ) {
        $retour = array();
        $this->MOD = array();
        if( count($modules) < 1 ){
            return false;
        }else{
            foreach ( $modules as $mod ) {
                $dynamic_class = 'mc_'.$mod;
                $dynamic_view = 'modules/mv_'.$mod;
                $this->load->library($dynamic_class, $mod);
                $retour[]['mod_content'] = $this->parser->parse($dynamic_view, $this->MOD[$mod]);
            }    
        }
        return $retour;
    }

The function init_modules does get the array with a variable "answers".
Here goes the custom class:

Code:
class Mc_answers {
    
     function Mc_answers( $module_name ) {
    
            $this->CI =& get_instance();
            $this->CI->load->helper('modules');
            $this->CI->MOD[$module_name] = $this->assemble( $this->CI, $module_name );
            
    }

    function assemble( $CI, $mod_label ){
    
        $retour = array();
        
        $retour['answers'] = $this->get_questions();
        $retour['headline'] = get_module_headline($CI, $mod_label, $this->CI->GLO['user_lang_id'] );
        $retour['copy'] = get_module_bodycopy($CI, $mod_label, $this->CI->GLO['user_lang_id'] );
        $retour['baseurl'] = base_url();
        
        return $retour;
    
    }

...

What is not clear, why this piece of code works fine in 1.60 but is not working in 1.72, throwing the above-quoted errors.

Cheers,
A




Theme © iAndrew 2016 - Forum software by © MyBB