modxcms/Login

MODX3 Login::__construct() must be an instance of modX

Closed this issue · 2 comments

Backtrace

[04-Sep-2019 08:27:42 America/Chicago] PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Login::__construct() must be an instance of modX, object given, called in /home/wshawn/public_html/core/cache/includes/elements/modx/revolution/modsnippet/8.include.cache.php on line 28 and defined in /home/wshawn/public_html/core/components/login/model/login/login.class.php:48
Stack trace:
#0 /home/wshawn/public_html/core/cache/includes/elements/modx/revolution/modsnippet/8.include.cache.php(28): Login->__construct(Object(MODX\Revolution\modX), Array)
#1 /home/wshawn/public_html/core/src/Revolution/modScript.php(88): include('/home/wshawn/p...')
#2 /home/wshawn/public_html/core/src/Revolution/modParser.php(504): MODX\Revolution\modScript->process(NULL)
#3 /home/wshawn/public_html/core/src/Revolution/modParser.php(218): MODX\Revolution\modParser->processTag(Array, true)
#4 /home/wshawn/public_html/core/src/Revolution/modResource.php(522): MODX\Revolution\modParser->processElementTags('', '<!doctype html>...', true, false, '[[', ']]', Array, 9)
#5 /home/wshawn/ in /home/wshawn/public_html/core/components/login/model/login/login.class.php on line 48

Temporary workaround:

<?php
/**
 * Login
 *
 * Copyright 2010 by Shaun McCormick <shaun@modx.com>
 *
 * Login is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option) any
 * later version.
 *
 * Login 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. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * Login; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * @package login
 */
if (class_exists('MODX\Revolution\modX')) {
    class_alias('MODX\Revolution\modX', 'modX');
}

/**
 * MODx Login Class
 *
 * @package login
 */
class Login {}

Additional Occurrences:

Also exists in ReCaptcha and StopForumSpam

This workaround causes a harmless "already defined" warning/error.

I switched to using:

<?php
/**
 * Login
 *
 * Copyright 2010 by Shaun McCormick <shaun@modx.com>
 *
 * Login is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option) any
 * later version.
 *
 * Login 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. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * Login; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * @package login
 */

use MODx\Revolution\modX;
/**
 * MODx Login Class
 *
 * @package login
 */
class Login {}

@wshawn — Though this should eventually be addressed in the components, these issues need to be documented in the MODX 3.x repository because it needs to support BC with a majority of existing components. If it is determined MODX 3.x cannot support a specific BC issue, then we can move them to an individual component.