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

replace require with require_once in entryPoint.php #554

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from

Conversation

JoshMcCullough
Copy link

Description

I am not a "PHP Guy", so this could be wrong. However, it fixes error messages such as:

PHP Fatal error: Cannot declare class TemplateText, because the name is already in use

Same with LanguageManager.php and VardefManager.php, and likely but not confirmed, TemplateText.php.

Motivation and Context

I noticed the error while authenticating via the API, when the server returned 500.

How To Test This

Execute the below command and verify that the above error message does not appear in the log.

curl --location --request GET 'localhost/service/v4_1/rest.php' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'method=login' \
--data-urlencode 'input_type=JSON' \
--data-urlencode 'response_type=JSON' \
--data-urlencode 'rest_data={"user_auth":{"user_name":"admin","password":"password"},"application_name":"test"}'

Types of changes

  • [ x ] Bug fix (non-breaking change which fixes an issue)
  • [ _ ] New feature (non-breaking change which adds functionality)
  • [ _ ] Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

  • [ x ] My code follows the code style of this project found here.
  • [ _ ] My change requires a change to the documentation.
  • [ x ] I have read the How to Contribute guidelines.

@SuiteBot
Copy link

SuiteBot commented Oct 10, 2024

CLA assistant check
All committers have signed the CLA.

@JoshMcCullough JoshMcCullough changed the title replace require with require_once in entryPoint.php replace require with require_once in entryPoint.php Oct 11, 2024
@JoshMcCullough
Copy link
Author

Can we get this simple fix merged soon, please?

@vladaman
Copy link

vladaman commented Dec 30, 2024

I am getting the same issue with SuiteCRM 8.7.1 after an upgrade. This issue is only when we call an API endpoint.

If I replace require to require_once in entryPoint the error bubbles down to Currency error. It looks like after an upgrade the require has been broken and loads it multiple times on API.

Uncaught Error: already defined in /var/www/crm/public/legacy/include/SugarObjects/LanguageManager.php:52
Stack trace:
#0 /var/www/crm/public/legacy/include/entryPoint.php(134): require()
#1 /var/www/crm/config/bootstrap.php(70): require_once('...')
#2 /var/www/crm/vendor/autoload_runtime.php(12): require('...')
#3 /var/www/crm/public/index.php(5): require_once('...')
#4 {main}
  thrown in /var/www/crm/public/legacy/include/SugarObjects/LanguageManager.php on line 52

After replacing to require_once I get:

PHP Fatal error:  Cannot redeclare currency_format_number() (previously declared in /var/www/crm/public/legacy/modules/Currencies/Currency.php:279)

Copy link

@sadiq-geeky sadiq-geeky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple but effective change, Looks perfect.

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

Successfully merging this pull request may close these issues.

4 participants