Coder Social home page Coder Social logo

Comments (7)

jj449 avatar jj449 commented on June 2, 2024 1

my environment :

wordpress version : 5.6.10
php 7.3.31

from wp-graphql.

jj449 avatar jj449 commented on June 2, 2024

I found it's related to php version , from php error message , str_ends_with() undefined , and str_ends_with() start from php 8.
So if your php version lower than 8.0 , you encounter this error .

How to fix it? Since php 7.x without str_ends_with() , you must make one to php to run correctly :

in wp-content/plugins/wp-graphql/src/Type/WPConnectionType.php , find line 238 , that's where problem from , add below check before line 238
if (!function_exists('str_ends_with')) { function str_ends_with($haystack, $needle) { return $needle !== '' ? substr($haystack, -strlen($needle)) === $needle : true; } }

save WPConnectionType.php , then try to reach end point again , or run IDE from wordpress's left side menu. Now it works ~ Hope this help someone.

from wp-graphql.

jj449 avatar jj449 commented on June 2, 2024

the final get_edge_interfaces function in WPConnectionType.php , should be like this :

image

from wp-graphql.

justlevine avatar justlevine commented on June 2, 2024

WordPress provides this as a polyfill in 5.9+ but looks like WPCS isn't catching it because a different dev-deps is installing symfony's polyfill.

@jj449

  1. Can you please provide the exact PHP and WordPress version you are using? I want to make sure other things arent getting by the code sniffs.
  2. In the interim, instead of modifying the plugin and sticking that function definition inside a foreach loop, you should put the entire if ( ! function_exists(.....){ ...} into your own functions.php file.

from wp-graphql.

jj449 avatar jj449 commented on June 2, 2024

" you should put the entire bla bla fix codes into your own functions.php file "

yes , you are right , man ~ thanks ~

from wp-graphql.

jj449 avatar jj449 commented on June 2, 2024

@justlevine

I didn't fork this repo , Would you like to do the PR & fix ?

from wp-graphql.

justlevine avatar justlevine commented on June 2, 2024

@jj449 There is already a fix pending in #2992 , feel free to try it out

from wp-graphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.