Jump to content

Topic on Project:Support desk

problems after updateing wiht $wgHooks

10
Kyebert (talkcontribs)

I have an older script "Werbung.php" which was intecrated per

require_once( "$IP/extensions/Werbung/Werbung.php" );

$wgHooks['ParserBeforeStrip'][]='Werbung';

in the LocalSettings.php and now don't work under version 1.42.

Unfortunately I can't find any hint in error.log of PHP for the problem. What's the best way to fix this update-problem?

Thanks in advance.

TheDJ (talkcontribs)

It is probably no longer compatible. You would have to ask the author of Werbung.php to release a newer version, or update the code yourse to be conpatible with newer versions of Mediawiki.

Kyebert (talkcontribs)

Thank your for this information. The author is not available. Perhaps someone has a hint as to what should be adapted here (ins the (in the manageable code):

function getPOIs($cmd) { require_once("/usr/www/users/data.php"); 

$mysqli = new mysqli($DBHost, $DBUser, $DBPass, $DBName);

#Aufbau des Kommandos:<!-- Karte;latitude;longitude;zoom;NumberOfPOIs -->

$c = preg_split('/;/', $cmd[0]);
$latitude = $c[1];
$longitude = $c[2];
$zoom = $c[3];
$c4 = intval($c[4]); #30.5.15 Anzahl der POIs begrenzen
$maxNumberOfPOIs = $c4;
if ($c4 == 0)    $maxNumberOfPOIs =   50; # POI Anzahl
if ($c4 > 1500)  $maxNumberOfPOIs = 1500; 
$map = "{{#display_map:
";
$query = "select src from vaPOIs2 order by sqrt( power(lat-$latitude,2) + power(lon-$longitude,2) ) limit $maxNumberOfPOIs";
$result = $mysqli->query($query);
while($row = $result->fetch_row()) {
	$map .= $row[0] . "\n";
}
$map = trim ($map);
$map = trim ($map, ';');
$map .= "|service=openlayers|center=$latitude, $longitude|width=100%|zoom=$zoom}}";

return $map; } #funct getPOIs

function Werbung(&$parser, &$text) {	$text = preg_replace_callback ('/<!-- Karte.* -->/', "getPOIs", $text);	echo $text;	return(true); }
Osnard (talkcontribs)
Kyebert (talkcontribs)

Thanks for the tip. My idea with the board here was just to get an approach to solving the problem. I thought that some people would have to fix similar problems with an update...

Osnard (talkcontribs)
Kyebert (talkcontribs)

I had already tried a few things - unfortunately always without success:

1. with Manual:Hooks/de to replace $wgHooks['ParserBeforeStrip'][]='Werbung';

-> Werbung ( $parser, $text );

2. Manual:Hooks/ParserBeforeInternalParse extensions.json -> add:

   "HookHandlers": {

       "main": {

           "class": "MediaWiki\\Extension\\Werbung",

       }

   },

   "Hooks": {

       "ParserBeforeStrip": "Werbung",

       "services": [ "UserNameUtils" ]

   }

alternativ:

"Hooks": {

       "ParserBeforeStrip": "MediaWiki\\Extension\\Werbung\\Hooks::onParserBeforeStrip"

   },

(at least there was no error message with this version)

But I probably just don't have the right approach ?

Bawolff (talkcontribs)

The error probably went away because your changes made it fail before the error was encountered.

You should probably post any error message you got.

Kyebert (talkcontribs)

I have found the error messages of the function


function Werbung(&$parser, &$text) {

   $text = preg_replace_callback ('//', "getPOIs", $text);

   #echo $text;

   #echo "<br><brblblb lblbllbd lbalbab.<br><br>";

   return(true);

}

which I set in the LocalSettings.php

Werbung ( $parser, $text );

(instead of the old Hook #$wgHooks['ParserBeforeStrip'][]='Werbung';)


Deprecated: preg_replace_callback(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /usr/www/users/abc/archiv24/extensions/Werbung/Werbung.php on line 49

Notice: Headers already sent, should send headers earlier than require [Called from MediaWiki\Request\HeaderCallback::warnIfHeadersSent in /usr/www/users/veikkoc/archiv24/includes/Request/HeaderCallback.php at line 94] in /usr/www/users/abc/archiv24/includes/debug/MWDebug.php on line 492

Warning: session_name(): Session name cannot be changed after headers have already been sent in /usr/www/users/abc/archiv24/includes/Setup.php on line 472

Osnard (talkcontribs)

You can not call something like Werbung ( $parser, $text ); within LocalSettings.php. There is neither a $parser nor a $text in this context. You need to register the method as a hook handler.

The messages are (more or less) unrelated. I guess you have an empty line somewhere before a <?php or after a ?>.

Reply to "problems after updateing wiht $wgHooks"