Topic on Extension talk:LastUserLogin

LastUserLogin not working correctly in MediaWiki 1.27

14
Summary by Kghbln

Fixed in the repo.

DikkieDick (talkcontribs)

When using this extension in MediaWiki 1.27 a blank screen shows up and error_log says:

[Fri Sep 09 13:40:27 2016] [error] [client 10.10.10.50] PHP Fatal error:  Call to undefined method User::getSkin() in /u01/mediawiki/extensions/LastUserLogin/LastUserLogin.body.php on line 113, referer:http://10.10.10.100/index.php/Special:SpecialPages

Seems that getSkin() is deprecated. I solved this by commenting line 113 and adding a new line 113:

$userName = $row[ $key] ;

That seems to do the trick and shows the username, realname and lastlogin.

128.252.214.219 (talkcontribs)

I cannot make it working, it says extension.json is not found.

DikkieDick (talkcontribs)

You still need to use require_once and not use wfLoadExtension.

Wustldli23 (talkcontribs)

Not working for me too, tried both latest developmental version and stable version...

Harry0725 (talkcontribs)

not working in MediaWiki 1.27 for me.......

Exception encountered, of type "Error" [8e72268e138ee5de460958af] /wiki/%E7%89%B9%E6%AE%8A:%E6%9C%80%E5%BE%8C%E7%94%A8%E6%88%B6%E7%99%BB%E5%85%A5 Error from line 111 of /var/lib/mediawiki/extensions/LastUserLogin/LastUserLogin.body.php: Cannot use object of type stdClass as array

DikkieDick (talkcontribs)

Hmmm... so it's getting wrong prior to line 113. Might be a php-issue. Which PHP-version are you using?

I have

Installed software

Product Version
MediaWiki 1.27.1
PHP 5.6.17 (apache2handler)
MySQL 5.1.73

MediaWiki 1.27 requires PHP 5.5.9 or above.

This post was hidden by DikkieDick (history)
Harry0725 (talkcontribs)

I have

Installed software

Product Version
MediaWiki 1.27.0
PHP 7.0.8-0ubuntu0.16.04.2 (apache2handler)
MySQL 5.7.13-0ubuntu0.16.04.2

line111:$userPage = Title::makeTitle( NS_USER, $row[ $key ] );

I tried to comment line 111 and add $userName = $row[ $key] ;, but seems not working. It even make my wiki down.

Rrosenfeld (talkcontribs)

Same problem here with MediaWiki 1.27.1, LastUserLogin-REL1_27-403e107, Debian jessie, which means PHP 5.6.24+dfsg-0+deb8u1.

I also run into PHP Fatal error:  Cannot use object of type stdClass as array in .../ver127/extensions/LastUserLogin/LastUserLogin.body.php on line 111.

Where line 111 is

$userPage = Title::makeTitle( NS_USER, $row[ $key ] );
Rrosenfeld (talkcontribs)

I noticed that replacing all

$row[ $key ]

by

$row->$key

in LastUserLogin.body.php seems to fix the issue for me.

This results in the following patch:

--- LastUserLogin.body.php.org  2016-06-14 00:07:47.000000000 +0200
+++ LastUserLogin.body.php      2016-12-06 15:43:10.672687802 +0100
@@ -103,16 +103,16 @@
                        $out .= '<tr>';
                        foreach ( $fields as $key => $value ) {
                                if ( $key === 'user_touched' ) {
-                                       $lastLogin = $wgLang->timeanddate( wfTimestamp( TS_MW, $row[ $key ] ), true );
-                                       $daysAgo = $wgLang->formatNum( round( ( time() - wfTimestamp( TS_UNIX, $row[ $key ] ) ) / 3600 / 24, 2 ), 2 );
+                                       $lastLogin = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->$key ), true );
+                                       $daysAgo = $wgLang->formatNum( round( ( time() - wfTimestamp( TS_UNIX, $row->$key ) ) / 3600 / 24, 2 ), 2 );
                                        $out .= '<td>' . $lastLogin . '</td>';
                                        $out .= '<td style="text-align:right;">' . $daysAgo . '</td>';
                                } elseif ( $key === 'user_name' ) {
-                                       $userPage = Title::makeTitle( NS_USER, $row[ $key ] );
+                                       $userPage = Title::makeTitle( NS_USER, $row->$key );
                                        $userName = Linker::link( $userPage, htmlspecialchars( $userPage->getText() ) );
                                        $out .= '<td>' . $userName . '</td>';
                                } else {
-                                       $out .= '<td>' . htmlspecialchars( $row[ $key ] ) . '</td>';
+                                       $out .= '<td>' . htmlspecialchars( $row->$key ) . '</td>';
                                }
                        }
                        $out .= '</tr>';
Harry0725 (talkcontribs)

@Rrosenfeld, change all to $row->$key seems like working. However, I still have to disable this extension since it still makes my Parsoid down. But thanks for you.

80.138.153.40 (talkcontribs)

@Rrosenfeld Thanks, that worked for me!

Kghbln (talkcontribs)
Kghbln (talkcontribs)

Now merged on also backported to REL1_27. Manual patches are no longer necessary.