#3 if Channel Synching enabled fatal error happens

0.5.0
closed-fixed
Mirco Bauer
MAIN (11)
5
2003-03-27
2003-03-17
Anonymous
No

Fatal error: Call to a member function on a non-object in
c:\documents and settings\stephen\my documents\web
pages\includes\s_bot\SmartIRC.php on line 2236

As far as I can tell the problem occurs when the
following code is run after a PART event on channel

else if (is_string($messagecode)) { // its not
numericcode so already a name/string
$methodname = strtolower($messagecode);
$_methodname = '_'.$methodname;

// same as above
if (method_exists($messagehandlerobject,
$_methodname)) {
$this->log
(SMARTIRC_DEBUG_MESSAGEHANDLER, 'DEBUG_
MESSAGEHANDLER: calling internal
method "'.get_class($messagehandlerobject).'-
>'.$_methodname.'" (by string)');
print 'Devo Debug - $messagehandlerobject-
>'.$_methodname.'($this, $ircdata)<br><br>';
$messagehandlerobject->$_methodname
($this, $ircdata);
$found = true;
print 'Final Test...';
}

The final output to the browser before the crash is:

Mar 17 22:26:00 DEBUG_IRCMESSAGES:
received: ":Devo!~Devo@Devo.users.netgamers.org
PART :#RTI"
Mar 17 22:26:00 DEBUG_MESSAGEHANDLER: calling
internal method "net_smartirc_messagehandler->_part"
(by string)
Devo Debug - $messagehandlerobject->_part($this,
$ircdata)

As you can see, the script crashes before the 'Final
Test,,,', so at least the origin of the problem is slim...

Discussion

  • Logged In: NO

    Sorry - Email address stephen.edmonds5@btinternet.com

    Thank you for your time

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-17

    Logged In: YES
    user_id=598557

    please tell me which version of SmartIRC this is and the
    botcode script, at least the settings and actionhandler part
    till the disconnect(), your bot methods don't have to be
    pasted (if you don't want to)...

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-17

    • assigned_to: nobody --> meebey
     
  • Logged In: NO

    Smart IRC version - 0.5.1

    bot code - copied striaght out of an example script (My
    experiements show that it never reaches this stage thou...)

    class IRCBot
    {
    function onjoin_greeting(&$irc, &$data)
    {
    // if _we_ join, don't greet ourself, just jump out via return
    if ($data->nick == $irc->_nick)
    return;

    // now check if this is the right channel
    if ($data->channel == '#RTi')
    // it is, lets greet the joint user
    $irc->message
    (SMARTIRC_TYPE_CHANNEL, '#RTi', 'hi '.$data->nick);
    }
    }

    $S_bot = &new IRCBot();
    $irc = &new Net_SmartIRC();

    $irc->net_smartirc_messagehandler->_part( $a, $b );
    print 'fine...';
    exit;

    $irc->setDebug(SMARTIRC_DEBUG_ALL);
    $irc->setUseSockets(TRUE);
    $irc->setChannelSynching(TRUE);
    $irc->setCtcpVersion( 'S-Bot (Scryt IRC Robot) - Coded by
    Devo - Powered by PHP and MySQL' );
    //$irc->registerActionhandler(SMARTIRC_TYPE_JOIN, '.*',
    $S_bot, 'onjoin_greeting');
    $irc->connect('irc.netgamers.org', 6667);
    $irc->login('[Scryt-Bot]', 'scryt-bot', 8, 'scryt-bot@scryt.no-
    ip.com');
    $irc->join( '#RTi' );
    $irc->listen();
    $irc->disconnect();

     
  • Logged In: YES
    user_id=737158

    This is like following a ball of string...

    After some more messin about with the code (IE adding
    debug messages to pinpoint exactly WHERE it crashes,
    nothing else), i have localised the problem to the channel
    sync code. The function _removeuser in the class
    Net_SmartIRC. The error occurs here:

    $channel->users[$lowerednick]->_Net_SmartIRC_user();

    It occurs in this block of code:

    $channel = &$this->_channels[$ircdata->channel];
    $channel->users[$lowerednick]->_Net_SmartIRC_user();
    unset($channel->users[$lowerednick]);

    if (isset($channel->ops[$nick])) {
    unset($channel->ops[$nick]);
    }

    if (isset($channel->voices[$nick])) {
    unset($channel->voices[$nick]);
    }

     
  • Logged In: YES
    user_id=737158

    Hope this helps... (BTW, i am the original bug posted,
    thought I should register so I can more easily keep track)

    Good luck fixing this!

     
  • Logged In: YES
    user_id=737158

    Wahoo! I am a genious ;-)

    I found the problem. For some reason (Okay, i don't know the
    cause), there was a : appended to the channel name in the
    _removeuser function.

    Mar 19 16:39:37 DEBUG_MESSAGEHANDLER: calling
    internal method "net_smartirc_messagehandler->_part" (by
    string)

    Bad channel name! Remove the ;
    After fix - #rti
    IRC Data - Object
    IRC Nick - devo

    Object Variables of $ircdata:
    Array
    Expanding array...
    Array! [from] == Devo!~Devo@Devo.users.netgamers.org
    Array! [nick] == Devo
    Array! [ident] == ~Devo
    Array! [host] == Devo.users.netgamers.org
    Array! [channel] == #rti
    Array! [message] ==
    Array! [messageex] == Array
    Array! [type] == 524288
    Array! [rawmessage] == :Devo!
    ~Devo@Devo.users.netgamers.org PART :#RTI
    Array! [rawmessageex] == Array
    Testing for channel - #rti

    Without my little *fix*, [channel] was actually :#RTi
    Hence why it crashed.

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-22

    Logged In: YES
    user_id=598557

    ok then this is a real bug which has to be check out...
    please try the CVS version of SmartIRC an see if the bug
    happens also there, if not, then I fixed and found it
    already... if it also happens there I have to recheck the
    handling of _removeuser

    The CVS version of SmartIRC you get here:
    http://cvs.php.net/cvs.php/pear/Net_SmartIRC?login=2

    It's enough to replace SmartIRC.php and
    SmartIRC/messagehandler.php

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-22

    • summary: Fatal error: Call to a member function on a non-object --> if Channel Synching enabled fatal error happens
     
  • Logged In: YES
    user_id=737158

    Yep, its been solved... TY for that

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-22

    Logged In: YES
    user_id=598557

    I still want to know what the IRC message was when it
    crashed...

    the channelname is now right used in the CVS version?
    without the ":" ?

     
  • Logged In: YES
    user_id=737158

    The CVS version works fine, the raw message shows the
    channel as :#RTI, but the code doesn't crash so *hopefully*
    its fixed :-)

    The IRC message - if you mean what we saw in #RTi, it was
    a 'Read Error: Connection reset by peer'

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-23

    Logged In: YES
    user_id=598557

    rawmessage must be ":#RTI2 because thats the answer from the
    server... but what about channelname ? is that ":#RTI" or
    #"RTI"?
    and I need the full IRC rawmessage line before the crash...

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-25

    Logged In: YES
    user_id=598557

    I need this info because I still believe its a real bug in
    SmartIRC, the CVS version has just a workaround which is
    _not_ bugfixing!

     
  • Logged In: YES
    user_id=737158

    Sorry, been quite busy with skool work etc etc... I will go and
    find out now...

     
  • Logged In: YES
    user_id=737158

    21:48:48 DEBUG_IRCMESSAGES: received: ":Devo!
    ~Devo@Devo.users.netgamers.org PART :#RTI"

    25 21:48:48 DEBUG_MESSAGEHANDLER: calling internal
    method "net_smartirc_messagehandler->_part" (by string)

    Fatal error: Call to a member function on a non-object in
    c:\server\webpages\includes\s_bot\SmartIRC.php on line 2234

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-26

    Logged In: YES
    user_id=598557

    In the current version of SmartIRC.php in the CVS repository
    this bug should be fixed now... please try that version and
    report the results....

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-26

    • status: open --> pending
     
  • Mirco Bauer
    Mirco Bauer
    2003-03-26

    • status: pending --> pending-fixed
     
  • Logged In: YES
    user_id=737158

    Mar 27 17:34:29 DEBUG_IRCMESSAGES:
    received: ":Devo|Awol!~Devo@Devo.users.netgamers.org
    PART :#RTI"
    Mar 27 17:34:29 DEBUG_MESSAGEHANDLER: calling
    internal method "net_smartirc_messagehandler->_part" (by
    string)

    Works fine! I'll let you know if i find any more bugs

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-27

    Logged In: YES
    user_id=598557

    ok thank you for reporting and testing, I am closing this
    bug now...

     
  • Mirco Bauer
    Mirco Bauer
    2003-03-27

    • status: pending-fixed --> closed-fixed