• Resolved pixeline

    (@pixeline)


    When activating the plugin, this error message pops up:

    Fatal error: Cannot redeclare Algolia\AlgoliaSearch\api_path() (previously declared in /var/www/html/web/app/plugins/simply-static-pro/vendor/algolia/algoliasearch-client-php/src/functions.php:7) in /var/www/html/web/app/plugins/wp-search-with-algolia/includes/libraries/algoliasearch-client-php/src/functions.php on line 7

    It points to another plugin (Simply Static Pro) that uses composer to include the algolia php library.
    I’ve already contacted the other plugin developers to inform them of the collision. Could you also fix that on your side?
    Thank you!
    Alexandre.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Opened an issue for this over at https://github.com/WebDevStudios/wp-search-with-algolia/issues/266

    Not quite sure yet how to best go about this, and I know it’s a fairly common issue among all distributed libraries, not just something Algolia based.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I think you may be able to get around this at the moment with this filter:

    if ( apply_filters( 'algolia_should_require_search_client', true ) )
    

    Used at https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/classmap.php#L15-L18

    just a quick add_filter( 'algolia_should_require_search_client', '__return_false' ); would make use of it and not load our copy

    We do have a newly issued pull request that we’re reviewing that would remove the filter but also would get the namespaces prefixed which would remove the conflict completely

    Thread Starter pixeline

    (@pixeline)

    Hi! Unfortunately, I’m still having the issue, even with the filter added in my theme’s functions.php

    
    add_filter( 'algolia_should_require_search_client', '__return_false' );
    

    Fatal error: Cannot redeclare Algolia\AlgoliaSearch\api_path() (previously declared in /var/www/html/web/app/plugins/simply-static-pro/vendor/algolia/algoliasearch-client-php/src/functions.php:7) in /var/www/html/web/app/plugins/wp-search-with-algolia/includes/libraries/algoliasearch-client-php/src/functions.php on line 7

    • This reply was modified 2 years, 3 months ago by pixeline.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    May be too early to catch it in time, being in the theme’s functions.php

    Try dropping the following into a file that you save in wp-content/mu-plugins/ Perhaps named bypass-algolia.php

    <?php
    /*
     * Plugin Name: Bypass Algolia
     * Plugin URI: Plugin URI
     * Description: Description of the plugin
     * Version: 1.0.0
     * Author: WebDevStudios
     * Author URI: https://webdevstudios.com
     * License: GPLv2
     * Text Domain: Text domain to use
     */
    
    add_filter( 'algolia_should_require_search_client', '__return_false' );
    

    Hopefully this is early enough to catch it in time?

    Thread Starter pixeline

    (@pixeline)

    Hi Michael, you are very helpful, thank you very much for your time helping me on my issue.

    And yes, indeed, making it a mu-plugin did the trick!

    • This reply was modified 2 years, 3 months ago by pixeline.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Awesome.

    If you want to keep an eye on the namespace scoping that we’re trying out, keep an eye on https://github.com/WebDevStudios/wp-search-with-algolia/pull/267

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Namespace conflict with other plugin’ is closed to new replies.