Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught ArgumentCountError: Too few arguments to function get_client_language(), 0 passed in /var/www/html/core/bekah.php on line 247 #6

Open
midivue opened this issue Apr 4, 2024 · 5 comments

Comments

@midivue
Copy link

midivue commented Apr 4, 2024

Hey!

First of all thanks for your wonderful work on BF I appreciate it!

As I wanted to dive in to work on my project using BF I encountered a syntax error. Requesting index.php throws an error related to core.php calling bekah.php.

This is with BF 3.0 out of the box version, no changes to the codebase yet.

Warning: A non-numeric value encountered in /var/www/html/core/bekah.php on line 153

Warning: A non-numeric value encountered in /var/www/html/core/bekah.php on line 188

Warning: A non-numeric value encountered in /var/www/html/core/bekah.php on line 188

Fatal error: Uncaught ArgumentCountError: Too few arguments to function get_client_language(), 0 passed in /var/www/html/core/bekah.php on line 247 and at least 1 expected in /var/www/html/core/bekah.php:235 Stack trace: #0 /var/www/html/core/bekah.php(247): get_client_language() #1 /var/www/html/core/core.php(6): require_once('/var/www/html/c...') #2 /var/www/html/index.php(4): require('/var/www/html/c...') #3 {main} thrown in /var/www/html/core/bekah.php on line 235

I'm using docker compose for local development and php:7.4-apache image from Docker hub:

version: '3.8'
services:
  web:
    image: php:7.4-apache
    container_name: web
    ports:
      - "40000:80"
    volumes:
      - ./bf:/var/www/html
    restart: always

If I comment require_once('bekah.php'); in core.php I can override this and BF loads correctly but then I lose bekah.php functionality.

I have not found recommended php version for BF in the docs so I tried different versions because I suspected it might be related to that. Trying to serve with php:8.3-apache threw this error:

Fatal error: Uncaught TypeError: Unsupported operand types: int + string in /var/www/html/core/bekah.php:153 Stack trace: #0 /var/www/html/core/core.php(6): require_once() #1 /var/www/html/index.php(4): require('/var/www/html/c...') #2 {main} thrown in /var/www/html/core/bekah.php on line 153

What am I missing? What's the recommended version to run BF? How should I approach resolving this issue? I didn't want to modify the codebase until getting feedback on this.

Thanks!

@pinecreativelabs
Copy link
Owner

Thank you for bringing this to my attention. I have not tested BF on PHP version 8.x, and I can confirm that it fails on PHP 7.4.

Currently, it seems to work fine on PHP 7.0, but NOT 7.1 or greater.

Ideally, BF should be made to work with the newer versions of PHP (8.x+), especially since BF 3.1 will include a backend portal. In the meantime, if you have access to change your PHP version, use 7.0.

@NoPMK
Copy link

NoPMK commented Apr 4, 2024

Thank you for your answer!

@pinecreativelabs
Copy link
Owner

BUG FIX: I've updated the bekah.php script with a bug fix. BF should now work on PHP 7.0 and up. Tested with PHP 8.3, and seems to work fine. I've uploaded the updated file to the CORE directory.

The culprit was the get_client_language function (which returns the user's default browser language code).

@midivue
Copy link
Author

midivue commented Apr 4, 2024

Thank you for the swift response and fix!

We just debugged the issue ourselves and came up with a pretty similar solution to yours and were contemplating a contribution although we were glad the issue was resolved by you with much more domain knowledge.

We are very excited to start working on our project with BF. :)

@midivue
Copy link
Author

midivue commented Apr 4, 2024

There seems to be a new issue within the new bekah.php:

 Parse error: syntax error, unexpected ')', expecting ']' in /var/www/html/core/bekah.php on line 236
function get_browser_language( $available = [], $default = 'en') {
   if (isset( $_SERVER['HTTP_ACCEPT_LANGUAGE' )) {
       //* Rest of the function...

The issue seems to be a typo, a missing closing square bracket ] in the isset() function:

function get_browser_language( $available = [], $default = 'en') {
    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
    //* Rest of the function...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants