따로 포인트 관리 애드온을 사용하고 있는데

 

특정 횟수 미만일때에는 포인트 차감이 되지 않도록 

포인트 모듈에 트리거가 개입해서 동작하는 애드온인데

 

PHP Fatal error:  Cannot make static method ModuleHandler::triggerCall() non static in class TriggerModuleHandler in /home/addons/control_download_trigger/class/TriggerModuleHandler.php on line 0

 

이런식으로 애러가나네요..

 

라인이 0번째 줄인건 처음보네요.. 

 

해당 에러가 난 소스는 이런식으로 시작되는데

 

라이믹스의 호출명이 XE와는 다른가요..? 

$output = TriggerModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj);


 

<?php
/* Copyright (C) UPGLE <http://www.upgle.com> */
class TriggerModuleHandler extends ModuleHandler
{
    /**
     * call a trigger
     * @param string $trigger_name trigger's name to call
     * @param string $called_position called position
     * @param object $obj an object as a parameter to trigger
     * @return Object
     * */
    function triggerCall($trigger_name, $called_position, &$obj)
    {
        // skip if not installed
        if(!Context::isInstalled())
        {
            return new Object();
        }

        $oModuleModel = getModel('module');
        $triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
        if(!$triggers || count($triggers) < 1)
        {
            return new Object();
        }

        foreach($triggers as $item)
        {
            $module = $item->module;
            $type = $item->type;
            $called_method = $item->called_method;

            // 포인트 모듈인 경우 패스
            if($module == 'point') continue;

            $oModule = getModule($module, $type);
            if(!$oModule || !method_exists($oModule, $called_method))
            {
                continue;
            }

            $before_each_trigger_time = microtime(true);

            $output = $oModule->{$called_method}($obj);

            $after_each_trigger_time = microtime(true);
            $elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time;

            $slowlog = new stdClass;
            $slowlog->caller = $trigger_name . '.' . $called_position;
            $slowlog->called = $module . '.' . $called_method;
            $slowlog->called_extension = $module;
            if($trigger_name != 'XE.writeSlowlog') writeSlowlog('trigger', $elapsed_time_trigger, $slowlog);

            if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
            {
                return $output;
            }
            unset($oModule);
        }

        return new Object();
    }
}
/* End of file TriggerModuleHandler.class.php */
/* Location: ./addons/control_download_trigger/class/TriggerModuleHandler.class.php */
 

 

  • profile
    애드온에 포함된 TriggerModuleHandler 클래스가 옛날 방식으로 작성되어서 PHP 최신 버전에서 에러가 발생합니다. 12줄의 function 앞에 static을 붙여 주세요.

    아무튼 저런 식으로 애드온에서 코어를 주물러대는 기능은 앞으로 라이믹스와 호환되지 않게 될 가능성이 높습니다. 라이믹스에서는 저렇게 하지 않아도 애드온에서 트리거를 사용하는 새로운 방법을 제공합니다.
  • profile ?
    아 계속 php 조금씩 공부하고 있었는데 static non-static 이냐 관련 문제로 보고 있었는데

    그 부분 때문인가보네요:))

    기진곰님말씀처럼 알려주신대로 하니까 너무 잘됩니다 캄사합니다+_+//..

    흑흑 호환이 차후 안되면 걱정이 되네요..
  • profile profile
    오.... 애드온에서 트리거가 되는군요.
    저는 이런줄도 모르고 맨날 간단한 모듈로 만들어서 괜히 파일 갯수만 늘렸네요.
  • profile ?

    애드온조건에 맞는 값일 때,

    기존과 같은 500에러는 안뜨는데, 잘못된 요청입니다 페이지로 다운로드가 안되는데


    혹시 다운로드 관련된 부분에서 XE와 라이믹스가 다른 부분이 있을까요?
    지금은 XE개발자분이 되신분이 제작하신 애드온이라, 코드 짜여진 난이도가 상당히 높아보이네요ㅜㅜ

     

        // Call a trigger (after)
        $output = TriggerModuleHandler::triggerCall('file.downloadFile', 'after', $file_obj);

        $file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = hash('md5',rand());
        header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key));
        Context::close();
        exit();

     

  • profile ?

    아 라이믹스는
    // Redirect to procFileOutput using file key
    if(!isset($_SESSION['__XE_FILE_KEY__']) || !is_string($_SESSION['__XE_FILE_KEY__']) || strlen($_SESSION['__XE_FILE_KEY__']) != 32)
    {
    $_SESSION['__XE_FILE_KEY__'] = Rhymix\Framework\Security::getRandom(32, 'hex');
    }
    $file_key_data = $file_obj->file_srl . $file_obj->file_size . $file_obj->uploaded_filename . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'];
    $file_key = substr(hash_hmac('sha256', $file_key_data, $_SESSION['__XE_FILE_KEY__']), 0, 32);
    header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key));
    Context::close();
    exit();

    이런식으로 변경되었네요:))

     

     

    변경된 코드 참조해서 고쳤습니다@.@

  • ? profile
    네, 코어 소스를 저렇게 복사해서 만들어 놓은 애드온은 코어가 변경되면 호환되지 않게 될 가능성이 높습니다.