mediawiki4intranet / Wikilog

Heavily improved Wikilog extension
http://wiki.4intra.net/Wikilog
GNU General Public License v2.0
10 stars 10 forks source link

Bug Fatal error: Cannot access protected property (MW 1.25 Beta, php 5.5.9, latest wikilog #5

Closed danielkschneider closed 9 years ago

danielkschneider commented 9 years ago

Hi, I think I found an error: MediaWiki 1.25beta (696dc35) 00:43, 9 April 2015 Wikilog 1.2.0 (7928276) 08:45, 21 January 2015 PHP 5.5.9-1ubuntu4.7

Fatal error: Cannot access protected property LinksUpdate::$mDb in /data/portails/wikitest/extensions/Wikilog/WikilogLinksUpdate.php on line 44

The wiki is life online, but I soon will migrate existing wikis to this machine and then change its alias Now: http://tecfalx5.unige.ch/wt/Special:Version Later: http://edutechwiki.unige.ch/en/

Btw: This error also pops up when I install the version from Mediawiki.org. Could be a Ubuntu/PHP issue, e.g. more severe checking ?

PS: You also should say in your instructions to tell MySQL to allow temporary tables (for the installation/upgrading scripts) GRANT CREATE TEMPORARY TABLES, EXECUTE ON your_wiki . * TO 'wiki_user'@'localhost';

hermannschwaerzlerUIBK commented 9 years ago

I can confirm this bug: MediaWiki 1.25.1 PHP 5.4.16 CentOS Linux release 7.0.1406 (Core).

How did this ever work? mDB as well as mOptions of LinksUpdate and SqlDataUpdate were protected from the very beginning.

This is probably not the right way to do it, but I was able solve this problem by making this change to the code:

--- /tmp/Wikilog/WikilogLinksUpdate.php 2015-06-22 16:57:28.755332996 +0200
+++ extensions/Wikilog/WikilogLinksUpdate.php   2015-06-22 17:01:05.296358954 +0200
@@ -29,14 +29,14 @@
 if ( !defined( 'MEDIAWIKI' ) )
        die();

-class WikilogLinksUpdate
+class WikilogLinksUpdate extends LinksUpdate
 {
-       private $mId;
-       private $mTitle;
-       private $mDb;
-       private $mOptions;
-       private $mAuthors;
-       private $mTags;
+       public    $mId;
+       public    $mTitle;
+       protected $mDb;
+       protected $mOptions;
+       protected $mAuthors;
+       protected $mTags;

        function __construct( &$lupd, $parserOutput ) {
                $this->mId = $lupd->mId;
@@ -57,7 +57,7 @@
                }
        }

-       private function doIncrementalUpdate() {
+       protected function doIncrementalUpdate() {
                # Authors
                $existing = $this->getExistingAuthors();
                $this->incrTableUpdate( 'wikilog_authors',
@@ -87,7 +87,7 @@
                }
        }

-       private function incrTableUpdate( $table, $from, $to, $deletions, $insertions ) {
+       public function incrTableUpdate( $table, $from, $to, $deletions, $insertions ) {
                if ( count( $deletions ) ) {
                        $where = array(
                                $from => $this->mId,
vitalif commented 9 years ago

mDB as well as mOptions of LinksUpdate and SqlDataUpdate were protected from the very beginning.

They were overridden as public in LinksUpdate until 1.25... It seems it doesn't make sense to use these properties because mOptions is always an empty array in 1.25, and mDB is always wfGetDB(DB_MASTER). Just committed the right fix, please check if everything is ok now.

danielkschneider commented 8 years ago

Sorry Vitaly, I never got around to test this extension again and answer. Indeed the latest version seems to work just fine. MW 1.25.2 (9dd054c), PHP 5.5.9-1ubuntu4.14

thanx again for keeping this code alive ! - Daniel