21
trabis
Re: XoopsCalander Error
  • 2009/12/3 14:22

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Sure, the class is never included when you use xoops_load('calendar'); because core check if calendar class already exists(which is the case if extcal is installed) instead of checking if xoopscalendar class already exists.
We now need to change core lines to xoops_load('xoopscalendar') because it is xoopscalendar we are looking for and not calendar. Since some modules may already been using xoops_load() since 2.3.x we need to be careful in order to maintain backward compatibilities. More to come...

22
djtom
Re: XoopsCalander Error
  • 2009/12/3 14:45

  • djtom

  • Just popping in

  • Posts: 15

  • Since: 2004/10/27


Hi Trabis,

Thank you for this information... and a thank you too much if you arrive to fix it ... because I have doing the crazy man ... and I push directly the new XOOPS core in my production site !!!
(I've never had problem with a XOOPS upgrade...)

And in french country there is other people who have the same problem !!!

For now I back them with the information you gave me part.

So I wait hoping you could find a patch Trabis? you think it's feasible?

23
trabis
Re: XoopsCalander Error
  • 2009/12/3 20:44

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


ok, so to reproduce this I had to use Minical block in all pages. I suposed uninstall/install fixed it because the block was removed! So when block is rendered it will load a class called "calendar" and any module that uses xoopscalendar on submit form will get a XoopsCalendar not found. Core is assuming it is already loaded and that is a bug. To fix it I suggest calling classes using their real names, so instead of using xoops_load('calendar'), we should use xoops_load('xoopscalendar'). Here is my propose for class/xoopsload.php
<?php
/*
 You may not change or alter any portion of this comment or credits
 of supporting developers from this source code or any supporting source code
 which is considered copyrighted (c) material of the original comment or credit authors.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
 *  XOOPS Form Class Elements
 *
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         kernel
 * @subpackage      class
 * @since           2.3.0
 * @author          Kazumi Ono <onokazu@xoops.org>
 * @author          Taiwen Jiang <phppp@users.sourceforge.net>
 * @author          John Neill <catzwolf@xoops.org>
 * @version         $Id: xoopsload.php 3512 2009-08-27 22:43:57Z trabis $
 */
defined('XOOPS_ROOT_PATH') or die('Restricted access');

/**
 * XoopsLoad
 *
 * @author Taiwen Jiang <phppp@users.sourceforge.net>
 * @author John Neill <catzwolf@xoops.org>
 * @copyright copyright (c) XOOPS.org
 * @package kernel
 * @subpackage form
 * @access public
 */
class XoopsLoad
{
    
/**
     * XoopsLoad::load()
     *
     * @param mixed $name
     * @param string $type
     * @return
     */
    
function load($name$type 'core')
    {
        static 
$loaded;
        static 
$deprecated;
        
        if (!isset(
$deprecated)) {
            
$deprecated = array(
                
'uploader' => 'xoopsmediauploader',
                
'utility' => 'xoopsutility',
                
'captcha' => 'xoopscaptcha',
                
'cache' => 'xoopscache',
                
'file' => 'xoopsfile',
                
'model' => 'xoopsmodelfactory',
                
'calendar' => 'xoopscalendar'
                
);
        }
        
$name strtolower($name);
        if (
array_key_exists($name$deprecated)) {
            
trigger_error("XoopsLoad::load('{$name}') is deprecated, use XoopsLoad::load('{$deprecated[$name]}')"E_USER_WARNING);
            
$name $deprecated[$name];
        }

        
$type = empty($type) ? 'core' $type;
        if (isset(
$loaded[$type][$name])) {
            return 
$loaded[$type][$name];
        }
        
        if (
class_exists($name)) {
            
$loaded[$type][$name] = true;
            return 
true;
        }

        
$isloaded false;
        switch (
$type) {
            case 
'framework':
                
$isloaded XoopsLoad::loadFramework($name);
                break;
            case 
'class':
            case 
'core':
                
$type 'core';
                
$isloaded XoopsLoad::loadCore($name);
                break;
            default:
                
$isloaded XoopsLoad::loadModule($name$type);
                break;
        }
        
$loaded[$type][$name] = $isloaded;
        return 
$loaded[$type][$name];
    }

    
/**
     * Load core class
     *
     * @access private
     */
    
function loadCore($name)
    {
        static 
$configs;

        if (!isset(
$configs)) {
            
$configs XoopsLoad::loadCoreConfig();
        }
        if (isset(
$configs[$name])) {
            require 
$configs[$name];
            if (
class_exists($name) && method_exists($name'__autoload')) {
                
call_user_func(array($name '__autoload'));
            }
            return 
true;
        } else if (
file_exists($file XOOPS_ROOT_PATH '/class/' $name '.php')) {
            include_once 
$file;
            
$class 'Xoops' ucfirst($name);
            if (
class_exists($class)) {
                return 
$class;
            } else {
                
trigger_error('Class ' $name ' not found in file ' __FILE__ 'at line ' __LINE__E_USER_WARNING);
            }
        }
        return 
false;
    }

    
/**
     * Load Framework class
     *
     * @access private
     */
    
function loadFramework($name)
    {
        if (!
file_exists($file XOOPS_ROOT_PATH '/Frameworks/' $name '/xoops' $name '.php')) {
            
trigger_error('File ' str_replace(XOOPS_ROOT_PATH''$file) . ' not found in file ' __FILE__ 'at line ' __LINE__E_USER_WARNING);
        }
        include 
$file;
        
$class 'Xoops' ucfirst($name);
        if (
class_exists($class)) {
            return 
$class;
        }
    }
    
/**
     * Load module class
     *
     * @access private
     */
    
function loadModule($name$dirname null)
    {
        if (empty(
$dirname)) {
            return 
false;
        }
        if (
file_exists($file XOOPS_ROOT_PATH '/modules/' $dirname '/class/' $name '.php')) {
            include 
$file;
            if (
class_exists(ucfirst($dirname) . ucfirst($name))) {
                return 
true;
            }
        }
        return 
false;
    }

    
/**
     * XoopsLoad::loadCoreConfig()
     *
     * @return
     */
    
function loadCoreConfig()
    {
        return 
$configs = array(
            
'xoopskernel' => XOOPS_ROOT_PATH '/class/xoopskernel.php',
            
'xoopssecurity' => XOOPS_ROOT_PATH '/class/xoopssecurity.php',
            
'xoopslogger' => XOOPS_ROOT_PATH '/class/logger/xoopslogger.php',
            
'xoopspagenav' => XOOPS_ROOT_PATH '/class/pagenav.php',
            
'xoopslists' => XOOPS_ROOT_PATH '/class/xoopslists.php',

            
'xoopsmediauploader' => XOOPS_ROOT_PATH '/class/uploader.php',
            
'xoopsutility' => XOOPS_ROOT_PATH '/class/utility/xoopsutility.php',
            
'xoopscaptcha' => XOOPS_ROOT_PATH '/class/captcha/xoopscaptcha.php',
            
'xoopscache' => XOOPS_ROOT_PATH '/class/cache/xoopscache.php',
            
'xoopsfile' => XOOPS_ROOT_PATH '/class/file/xoopsfile.php',
            
'xoopsmodelfactory' => XOOPS_ROOT_PATH '/class/model/xoopsmodel.php',
            
'xoopscalendar' => XOOPS_ROOT_PATH '/class/calendar/xoopscalendar.php',

            
'xoopslocal' => XOOPS_ROOT_PATH '/include/xoopslocal.php',
            
'xoopslocalabstract' => XOOPS_ROOT_PATH '/class/xoopslocal.php',
            
'xoopseditor' => XOOPS_ROOT_PATH '/class/xoopseditor/xoopseditor.php',
            
'xoopseditorhandler' => XOOPS_ROOT_PATH '/class/xoopseditor/xoopseditor.php',
            
'xoopsformloader' => XOOPS_ROOT_PATH '/class/xoopsformloader.php',
            
'xoopsformelement' => XOOPS_ROOT_PATH '/class/xoopsform/formelement.php',
            
'xoopsform' => XOOPS_ROOT_PATH '/class/xoopsform/form.php',
            
'xoopsformlabel' => XOOPS_ROOT_PATH '/class/xoopsform/formlabel.php',
            
'xoopsformselect' => XOOPS_ROOT_PATH '/class/xoopsform/formselect.php',
            
'xoopsformpassword' => XOOPS_ROOT_PATH '/class/xoopsform/formpassword.php',
            
'xoopsformbutton' => XOOPS_ROOT_PATH '/class/xoopsform/formbutton.php',
            
'xoopsformbuttontray' => XOOPS_ROOT_PATH '/class/xoopsform/formbuttontray.php',
            
'xoopsformcheckBox' => XOOPS_ROOT_PATH '/class/xoopsform/formcheckbox.php',
            
'xoopsformselectcheckgroup' => XOOPS_ROOT_PATH '/class/xoopsform/formselectcheckgroup.php',
            
'xoopsformhidden' => XOOPS_ROOT_PATH '/class/xoopsform/formhidden.php',
            
'xoopsformfile' => XOOPS_ROOT_PATH '/class/xoopsform/formfile.php',
            
'xoopsformradio' => XOOPS_ROOT_PATH '/class/xoopsform/formradio.php',
            
'xoopsformradioyn' => XOOPS_ROOT_PATH '/class/xoopsform/formradioyn.php',
            
'xoopsformselectcountry' => XOOPS_ROOT_PATH '/class/xoopsform/formselectcountry.php',
            
'xoopsformselecttimezone' => XOOPS_ROOT_PATH '/class/xoopsform/formselecttimezone.php',
            
'xoopsformselectlang' => XOOPS_ROOT_PATH '/class/xoopsform/formselectlang.php',
            
'xoopsformselectgroup' => XOOPS_ROOT_PATH '/class/xoopsform/formselectgroup.php',
            
'xoopsformselectuser' => XOOPS_ROOT_PATH '/class/xoopsform/formselectuser.php',
            
'xoopsformselecttheme' => XOOPS_ROOT_PATH '/class/xoopsform/formselecttheme.php',
            
'xoopsformselectmatchoption' => XOOPS_ROOT_PATH '/class/xoopsform/formselectmatchoption.php',
            
'xoopsformtext' => XOOPS_ROOT_PATH '/class/xoopsform/formtext.php',
            
'xoopsformtextarea' => XOOPS_ROOT_PATH '/class/xoopsform/formtextarea.php',
            
'xoopsformdhtmltextarea' => XOOPS_ROOT_PATH '/class/xoopsform/formdhtmltextarea.php',
            
'xoopsformelementtray' => XOOPS_ROOT_PATH '/class/xoopsform/formelementtray.php',
            
'xoopsthemeform' => XOOPS_ROOT_PATH '/class/xoopsform/themeform.php',
            
'xoopssimpleform' => XOOPS_ROOT_PATH '/class/xoopsform/simpleform.php',
            
'xoopsformtextdateselect' => XOOPS_ROOT_PATH '/class/xoopsform/formtextdateselect.php',
            
'xoopsformdatetime' => XOOPS_ROOT_PATH '/class/xoopsform/formdatetime.php',
            
'xoopsformhiddentoken' => XOOPS_ROOT_PATH '/class/xoopsform/formhiddentoken.php',
            
'xoopsformcolorpicker' => XOOPS_ROOT_PATH '/class/xoopsform/formcolorpicker.php',
            
'xoopsformcaptcha' => XOOPS_ROOT_PATH '/class/xoopsform/formcaptcha.php',
            
'xoopsformeditor' => XOOPS_ROOT_PATH '/class/xoopsform/formeditor.php',
            
'xoopsformselecteditor' => XOOPS_ROOT_PATH '/class/xoopsform/formselecteditor.php',
            
'xoopsformcalendar' => XOOPS_ROOT_PATH '/class/xoopsform/formcalendar.php',
        );
    }

    
/**
     * XoopsLoad::loadConfig()
     *
     * @param mixed $data
     * @return
     */
    
function loadConfig($data null)
    {
        if (
is_array($data)) {
            
$configs $data;
        } else {
            if (!empty(
$data)) {
                
$dirname $data;
            } else if (
is_object($GLOBALS['xoopsModule'])) {
                
$dirname $GLOBALS['xoopsModule']->getVar('dirname''n');
            } else {
                return 
false;
            }
            if (
file_exists($file XOOPS_ROOT_PATH '/modules/' $dirname '/include/autoload.php')) {
                if (!
$configs = include $file) {
                    return 
false;
                }
            }
        }
        return 
$configs array_merge(XoopsLoad::loadCoreConfig(), $configs);
    }
}
// To be enabled in XOOPS 3.0
// spl_autoload_register(array('XoopsLoad', 'load'));
?>
This will trow a lot of warnings about deprecated use of XoopsLoad but, after we fix the calls made by core, the messages will be module side only.

24
ghia
Re: XoopsCalendar Error
  • 2009/12/4 2:40

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Is this also the case for the 2.3.x versions?

25
djtom
Re: XoopsCalander Error
  • 2009/12/4 7:31

  • djtom

  • Just popping in

  • Posts: 15

  • Since: 2004/10/27



Hi Trabis !!!

Wow you are too efficient:)

I will try your suggestion tonight when I go home and I will inform !!

Thank you too much for you participation in this problem

@ +


26
trabis
Re: XoopsCalendar Error
  • 2009/12/4 13:58

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

ghia wrote:
Is this also the case for the 2.3.x versions?


The problem with the false check is from 2.3.x and latter. The calendar bug is 2.4.x only because it was one of the new introduced features.

djtom, please inform back. If no problems are found we will submit it to SVN.

27
ghia
Re: XoopsCalander Error
  • 2009/12/5 8:41

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


What I don't understand about that piece of code (in the light of the wrong class check with d3downloads) is how it could go wrong, since all formelement classes of the various types seems to me checked twice!
Once by including /class/xoopsformloader.php (which actually does not result in the loading of the checked xoopsformloader class), and then again in the following list, where every type of the form element classes are rechecked and loaded individually if needed, eg xoopsformelement, etc.
Or did I miss something in my interpretation?

28
trabis
Re: XoopsCalander Error
  • 2009/12/5 13:25

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

ghia wrote:
What I don't understand about that piece of code (in the light of the wrong class check with d3downloads) is how it could go wrong, since all formelement classes of the various types seems to me checked twice!
Once by including /class/xoopsformloader.php (which actually does not result in the loading of the checked xoopsformloader class), and then again in the following list, where every type of the form element classes are rechecked and loaded individually if needed, eg xoopsformelement, etc.
Or did I miss something in my interpretation?


I supose you mean that if we include class/xoopsformloader.php and then use xoops_load('xoopsformelement'); xoopsformelement class would be included twice?

$type = empty($type) ? 'core' $type;
//first check        
if (isset($loaded[$type][$name])) {
            return 
$loaded[$type][$name];
        }
        
//second check
        
if (class_exists($name)) {
            
$loaded[$type][$name] = true;// added this line in the propose
            
return true;
        }


Time line:
include class/xoopsformloader.php -> nothing happens in xoopsload but all form elements class are loaded.

xoop_load('formelement')-> class already exists(2 check), it is added to list of loaded and return without including any file.

xoops_load('formelement')-> class already in list of loaded classes(1 check) and return without loading any file.

----

In the other post you mention that xoopsformelement and xoopsformdhtmltextarea are both loaded initially, where?

29
ghia
Re: XoopsCalander Error
  • 2009/12/5 14:02

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
I supose you mean that if we include class/xoopsformloader.php and then use xoops_load('xoopsformelement'); xoopsformelement class would be included twice?
No, there where include_once, so it won't happen twice.
But it is two times checked or trying to load, which seems like a kind of double attempt or divised operation.
I assume if you comment out the xoopsformloader, you end up with the same result = all formelement classes are loaded.
Quote:
In the other post you mention that xoopsformelement and xoopsformdhtmltextarea are both loaded initially, where?
I assumed that all these classes were loaded at the start of XOOPS.

30
trabis
Re: XoopsCalander Error
  • 2009/12/5 15:52

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

ghia wrote:
I assumed that all these classes were loaded at the start of XOOPS.


No, they are loaded when requested.
I changed xoopsformloader so it uses xoops_load. The propose of using xoops_load is to abstract the location of the classes. If latter we decide to move this classes to trust path this will save us some troubles. All we will need is to change the mapping in XoopsLoad class.

Login

Who's Online

171 user(s) are online (115 user(s) are browsing Support Forums)


Members: 0


Guests: 171


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits