Extension talk:GoogleCustomWikiSearch

About this board

PHP Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

4
Kghbln (talkcontribs)
Setup
  • MediaWiki 1.39.6 (0e03068) 2024-03-11T16:26:30
  • PHP 8.1.2-1ubuntu2.14 (apache2handler)
  • MariaDB 10.6.16-MariaDB-0ubuntu0.22.04.1
  • GoogleCustomWikiSearch 0.6.0 (3436331) 2024-02-09T05:42:00
Issue

When searching for something via "Special:Search" I am getting these deprecation warnings: "PHP Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated"

Backtrace
#0 [internal function]: MWExceptionHandler::handleError()
#1 /../w/extensions/GoogleCustomWikiSearch/includes/GoogleCustomWikiSearch.php(228): str_replace()
#2 /../w/extensions/GoogleCustomWikiSearch/includes/GoogleCustomWikiSearchHooks.php(53): GoogleCustomWikiSearch::getSearchTerm()
#3 /../w/includes/HookContainer/HookContainer.php(338): GoogleCustomWikiSearchHooks::onSpecialPageAfterExecute()
#4 /../w/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook()
#5 /../w/includes/HookContainer/HookRunner.php(3673): MediaWiki\HookContainer\HookContainer->run()
#6 /../w/includes/specialpage/SpecialPage.php(704): MediaWiki\HookContainer\HookRunner->onSpecialPageAfterExecute()
#7 /../w/includes/specialpage/SpecialPageFactory.php(1428): SpecialPage->run()
#8 /../w/includes/MediaWiki.php(316): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#9 /../w/includes/MediaWiki.php(904): MediaWiki->performRequest()
#10 /../w/includes/MediaWiki.php(562): MediaWiki->main()
#11 /../w/index.php(50): MediaWiki->run()
#12 /../w/index.php(46): wfIndexMain()
#13 {main}
Elcapitan68 (talkcontribs)

Thank you, @Kghbln It looks like a PHP8 related issue. Passing to WikiTeq devs. In the meantime, please confirm if search still works despite the deprecation warnings, or it is broken.

Kghbln (talkcontribs)

Thank you for your feedback. Yes, the search results are still showing.

Tosfos (talkcontribs)

A developer was assigned to this task. We'll let you know once we have an update. Thanks for the report!

Reply to "PHP Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated"

Linked CSEs are no longer supported.

4
Summary by X-Savitar

OT

DikkieDick (talkcontribs)

Linked CSEs are no longer supported. See https://goo.gl/Gs1KIc.

Just installed this extension to receive the following as a result. Seems that since May 10th, 2017 it's not working anymore.

Anyone knows how to solve this?

Kkm5848 (talkcontribs)

I am also looking for help on this.

98.22.105.35 (talkcontribs)

Please do not help a stalker I have found many links I been stalked by this person for 4 years please do not help them stalk me I just sent letter to our Secretary of State for help on this issue

DikkieDick (talkcontribs)

Who are you referring to? Convenient to hide behind an ip-address and stay anonymous.

Not working with 1.35?

11
Kghbln (talkcontribs)

Special page "GoogleCustomWikiSearch" fails silently. Reported with task T274708

X-Savitar (talkcontribs)
Аргскригициониец (talkcontribs)

Also not working with 1.36.

Dachy (talkcontribs)

Same for 1.36

X-Savitar (talkcontribs)

@Аргскригициониец & @Dachy, are you using the master version of the extension or the release that matches the running install of MediaWiki core?

Per the compatibility policy, "Follows the MediaWiki version lifecycle. Master is not backward compatible.".


Let me know if that solves the problems for you! Thanks!

Dachy (talkcontribs)
X-Savitar (talkcontribs)

If you're using fit, then you must have the master branch running by default and in that case, you need the master branch of the extension too.


If you are downloading release bundles, the version of the extension should match the version of MediaWiki. Like so: REL1_35

Dachy (talkcontribs)
Dachy (talkcontribs)

I manually replaced it with 1.36 and now it seems to work, because the console prints a different caveat:


Mixed Content: The page at '....' was loaded over HTTPS, but requested an insecure script 'http://www.google.com/cse/cse.js?theme=V2_DEFAULT&language=.....'. This request has been blocked; the content must be served over HTTPS.


I got the point, but where should I edit? I saw this line in the main php file:

document.location.protocol == 'https' ? 'https:' : 'http:'

but my site is indeed at HTTPS now. I edited both options as HTTPS and uploaded it, still not working, like a cache somewhere still keeps the HTTP.

X-Savitar (talkcontribs)

Did you try a hard refresh after performing the edit? JS/CSS assets are cached by the browser, so a hard refresh should clear the cache.

This post was hidden by Dachy (history)
Reply to "Not working with 1.35?"
Rudloff (talkcontribs)

Hello,

It seems the extension does not work anymore (it just suddenly stopped working on one of my wikis).

I get this error in the browser console:

too much recursion[En savoir plus] www.archi-wiki.org:143:1
	gcseCallback https://www.archi-wiki.org/:143:1
	ak https://www.google.com/cse/static/element/ef505fd519591213/cse_element__fr.js:431:850
	<anonyme> https://www.google.com/cse/static/element/ef505fd519591213/cse_element__fr.js:437:268
	gcseCallback https://www.archi-wiki.org/:144:10
	ak https://www.google.com/cse/static/element/ef505fd519591213/cse_element__fr.js:431:850
	<anonyme> https://www.google.com/cse/static/element/ef505fd519591213/cse_element__fr.js:437:268
	gcseCallback https://www.archi-wiki.org/:144:10
	ak https://www.google.com/cse/static/element/ef505fd519591213/cse_element__fr.js:431:850
	<anonyme> https://www.google.com/cse/static/element/ef505fd519591213/cse_element__fr.js:437:268
...

It seems gcseCallback is calling itself too many times.

This workaround seems to make it work again:

diff --git a/GoogleCustomWikiSearch.class.php b/GoogleCustomWikiSearch.class.php
index a519217..3fe0b06 100644
--- a/GoogleCustomWikiSearch.class.php
+++ b/GoogleCustomWikiSearch.class.php
@@ -166,8 +166,6 @@ END;
                $term = $this->getTermEncoded();
                return <<<END
 function gcseCallback() {
-       if (document.readyState != 'complete')
-               return google.setOnLoadCallback(gcseCallback, true);
        google.search.cse.element.render({gname:'gcws', div:'cse', {$this->getSearchDisplayOption()}});
        var element = google.search.cse.element.getElement('gcws');
        element.execute( {$term} );

(I am not sure this is the best way to fix it though.)

require_once(__DIR__/GoogleCustomWikiSearch.Settings.php) [function.require-once]: failed to open stream

4
Gabuzo (talkcontribs)

In GoogleCustomWikiSearch.php, line 16, Please replace

$dir = __DIR__ . '/';

with

$dir = dirname(__FILE__) . '/';

otherwise I get:

Warning: require_once(__DIR__/GoogleCustomWikiSearch.Settings.php) [function.require-once]: failed to open stream: No such file or directory in /xxx/extensions/GoogleCustomWikiSearch/GoogleCustomWikiSearch.php on line 25

Fatal error: require_once() [function.require]: Failed opening required '__DIR__/GoogleCustomWikiSearch.Settings.php' (include_path='/xxx:/xxx/includes:/xxx/languages:.:/:/usr/local/php/pear5') in /xxx/extensions/GoogleCustomWikiSearch/GoogleCustomWikiSearch.php on line 25

Tosfos (talkcontribs)

Thanks for the feedback. That error is generated when using PHP < 5.3, which is required anyway to run the current version of MediaWiki (1.20). Those using an earlier version of MediaWiki and an older version of PHP should use your patch. I hope to add a branch for that in the near future.

89.97.245.226 (talkcontribs)

I have this error.. too

PHP message: PHP Fatal error: require_once(): Failed opening required '/var/www/html/sites/nethesis-wiki/extensions/GoogleCustomWikiSearch/GoogleCustomWikiSearch.Settings.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/sites/nethesis-wiki/extensions/GoogleCustomWikiSearch/GoogleCustomWikiSearch.php on line 26" while reading response header from upstream, client: 89.97.245.226, server: docs.nethesis.it, request: "GET /Nethesis HTTP/1.1", upstream: "fastcgi://unix:/tmp/php5-fpm.sock:", host: "docs.nethesis.it"

Tosfos (talkcontribs)

The near future has arrived. A fix for older versions of PHP was entered for branch REL1_19. It can be downloaded from git or from this link.

Failed opening required ...GoogleCustomWikiSearch.Settings.php

4
Summary by X-Savitar

resolved on master

Hutchy68 (talkcontribs)

There is an error in the GoogleCustomWikiSearch.php file

You have " require_once $dir . 'GoogleCustomWikiSearch.Settings.php'; " but the file name in the package is actually, GoogleCustomWikiSearch.settings.php. You'll need to adjust one or the other or it will throw a fatal error.

Tosfos (talkcontribs)

Good point. Truth is that on my system, this works fine. I think it's a PHP 5 feature. But it should be fixed, as well as some other minor issues in that file.

Hutchy68 (talkcontribs)

Nope, if you developed the extension on a Windows system with PHP, Windows is case insensitive. Linux file systems are case sensitive and the file name is called exactly as it is written.

Summary by X-Savitar

it worked!

Edmundopg (talkcontribs)

I have set all configurations: ID searcher, replace with mediawiki searcher, but doesn't do anything when I search something

www.tolkiendili.com

Tosfos (talkcontribs)

The globals on the extension's page document the latest version of the extension. Please either upgrade to the development version of the extension (recommended) or find the global names for your version in your settings file.

Edmundopg (talkcontribs)

Thanks, is it working now =)

I prefer this, to organic searcher that show all wikimedia results.

Wess (talkcontribs)

The extension will not load over wikis with https. to fix this you can delete or comment out the protocal part in line 184 at GoogleCustomWikiSearch.class.php:

/*(document.location.protocol == 'https' ? 'https:' : 'http:') +*/

and start the next line with https:

'https://www.google.com/cse/cse.js?theme...
Rudloff (talkcontribs)

I also had to edit the getScriptFileName() function in order to make it work with HTTPS:

public function getScriptFileName() {     return 'https://www.google.com/jsapi'; }

Reply to "Https problem fix"

Warning getModuleStyles

1
92.195.94.14 (talkcontribs)

Hello,

MediaWiki 1.26.2
PHP 5.4.45-nmm1 (apache2handler)
MySQL 5.5.46-nmm1-log
ICU 4.8.1.1
GoogleCustomWikiSearch 0.5.0 beta

i get the warning's:

Warning: OutputPage::getModuleStyles: style module should define its position explicitly: ext.googleCustomWikiSearch ResourceLoaderFileModule [Called from OutputPage::getModuleStyles in /www/....includes/OutputPage.php at line 623] in /www/.../debug/MWDebug.php on line 300

Warning: OutputPage::getModuleStyles: style module should define its position explicitly: ext.googleCustomWikiSearch ResourceLoaderFileModule [Called from OutputPage::getModuleStyles in /www/...includes/OutputPage.php at line 623] in /www/....../debug/MWDebug.php on line 300

What should I Change?

thanks for helps

Patric

Reply to "Warning getModuleStyles"
Jonoribol (talkcontribs)

I get "No Results" when using this extension. I'm using MediaWiki 1.24.2 and I've tried the 2014-12-02 build of GoogleCustomWikiSearch (from here) and the latest build (today, 2015-05-15, from here). I've toggled every setting I can find, making sure to check the settings file for both versions for the proper global names. Further, I have tried I see similar extensions have similar problems, but this one can't be fixed by the same things, e.g. removing all white space from Google's code. What am I missing?

Tosfos (talkcontribs)

You should definitely use the latest version from the master/development branch. If you have a live example and can post your LocalSettings (but change the API key), I'll have a look.

Reply to "No Results"
There are no older topics