opensourcepos / opensourcepos

Open Source Point of Sale is a web based point of sale application written in PHP using CodeIgniter framework. It uses MySQL as the data back end and has a Bootstrap 3 based user interface.
http://www.opensourcepos.org
Other
3.48k stars 2.19k forks source link

[Bug]: #3959

Closed odiea closed 7 months ago

odiea commented 8 months ago

Bug Description?

CRITICAL - 2024-03-28 04:30:18 --> Call to undefined function Tamtamchik\NameCase\str_name_case() in APPPATH\Controllers\Persons.php on line 66. 1 APPPATH\Controllers\Employees.php(115): App\Controllers\Persons->nameize('Odie') 2 SYSTEMPATH\CodeIgniter.php(942): App\Controllers\Employees->postSave(2) 3 SYSTEMPATH\CodeIgniter.php(502): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Employees)) 4 SYSTEMPATH\CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false) 5 FCPATH\index.php(79): CodeIgniter\CodeIgniter->run()

Steps to Reproduce?

Try to save Employee

Expected Behavior?

Save form. After I removed this Tamtamchik\NameCase\str_name_case() it works fine.

OpensourcePOS Version

development (unreleased)

Php version

Php 8.2

What browsers are you seeing the problem on?

No response

Server Operating System and version

Wamp

Database Management System and version

Mysql

Web Server and version

Wamp

System Information Report (optional)

System Information Report

Unmodified copy of OpensourcePOS

objecttothis commented 8 months ago

@odiea I was working on this function last week. I had to update to the latest version of the plugin. The issue I was experiencing was related to the function capitalizing html encodings when it shouldn't do that. Other than that it isn't related to your issue. I can replicate either with an existing employee or a new employee. Can you sync the latest commits from ci4-branch, build and tell me if you're still getting this problem?

objecttothis commented 8 months ago

btw the str_name_case function is needed, so removing it is a bandaid rather than a fix.

objecttothis commented 8 months ago

I did have to add use function \Tamtamchik\NameCase\str_name_case; to the top of the Persons controller, so make sure your version of the file has that.

odiea commented 8 months ago

Yes. The issue is still there.

CRITICAL - 2024-04-01 13:37:08 --> Call to undefined function Tamtamchik\NameCase\str_name_case() in APPPATH\Controllers\Persons.php on line 64. 1 APPPATH\Controllers\Customers.php(274): App\Controllers\Persons->nameize('Odie') 2 SYSTEMPATH\CodeIgniter.php(942): App\Controllers\Customers->postSave(3) 3 SYSTEMPATH\CodeIgniter.php(502): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Customers)) 4 SYSTEMPATH\CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false) 5 FCPATH\index.php(79): CodeIgniter\CodeIgniter->run() CRITICAL - 2024-04-01 13:37:27 --> Call to undefined function Tamtamchik\NameCase\str_name_case() in APPPATH\Controllers\Persons.php on line 64. 1 APPPATH\Controllers\Customers.php(274): App\Controllers\Persons->nameize('John') 2 SYSTEMPATH\CodeIgniter.php(942): App\Controllers\Customers->postSave(1) 3 SYSTEMPATH\CodeIgniter.php(502): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Customers)) 4 SYSTEMPATH\CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false) 5 FCPATH\index.php(79): CodeIgniter\CodeIgniter->run()

objecttothis commented 8 months ago

OK, I'll look into it. It's strange to me that I can edit an employee and click save, but not get the error. Can you attach of the screenshot showing the view with data that causes the error when you click save?

odiea commented 8 months ago

Any person views shows that error. Customers, Employees and suppliers.

2024-04-02 16_54_26-

2024-04-02 16_57_01-Window

odiea commented 8 months ago

And this is the folder contents. 2024-04-02 17_07_33-namecase

objecttothis commented 8 months ago

You're on php 8.2? Does the first 10 lines of your Person's controller match this? https://github.com/opensourcepos/opensourcepos/blob/ci4-branch/app%2FControllers%2FPersons.php

odiea commented 8 months ago

Appears identical to me

namespace App\Controllers;

use App\Models\Person; use function \Tamtamchik\NameCase\str_name_case;

abstract class Persons extends Secure_Controller { protected Person $person;

objecttothis commented 8 months ago

I have an idea. Did you run composer update, then npm install and npm run build? It's possible you have an old version of that package.

odiea commented 8 months ago

Tried that but Wamp server only goes to php 7.4. Too many requests for 8.1 now so cannot build any more.

odiea commented 8 months ago

I looked deeper into the package and changed to the following. Now it works. namespace App\Controllers;

use App\Models\Person; use \Tamtamchik\NameCase\function\str_name_case;

objecttothis commented 8 months ago

IMO Laragon is much better than WAMP. In my commit relating to the name case package I bumped the version to the latest version. I think that could be why you're experiencing this problem and I'm not. Just in case I'll try PHP 7.4 to see if I get the error on that but not 8.2

objecttothis commented 8 months ago

I looked deeper into the package and changed to the following. Now it works. namespace App\Controllers;

use App\Models\Person; use \Tamtamchik\NameCase\function\str_name_case;

Hmmm. If this turns out to be a difference between PHP 7.4 and 8.x then we will need to mitigate that.

odiea commented 8 months ago

Yes Wamps base php 7.4 but uses any other php that I select. So I am currently using 8.2.13

odiea commented 8 months ago

I tried building again and this is what is now showing in the command window. 2024-04-02 18_00_03-Administrator_ C__WINDOWS_system32_cmd exe

odiea commented 8 months ago

@objecttothis The good new is I was able to run composer update this morning after changing the composer.lock and composer.json to "name": "codeigniter4/framework", to "version": "v4.4.7". It might not have been the php version I was using although I did change wamps version to php 8.2.13. I guess I need to heed the build issues on github.

objecttothis commented 8 months ago

I would delete your vender directory and make sure your composer.json and composer.lock files are the same as in the ci4-branch. Then run composer install After that try running npm ci which should completely remove existing npm modules and reinstall them all based on the package.json. Before running that make sure your package.json and package-lock.json are identical to the ci4-branch. Finally run npm run build like normal. See if that fixes your problem.

objecttothis commented 8 months ago

tamtamchick/NameCase is an npm dependency, so the issue is with npm, but if you upgrade composer dependencies to the very newest of each package then it will error for other reasons.

objecttothis commented 8 months ago

@objecttothis The good new is I was able to run composer update this morning after changing the composer.lock and composer.json to "name": "codeigniter4/framework", to "version": "v4.4.7". It might not have been the php version I was using although I did change wamps version to php 8.2.13. I guess I need to heed the build issues on github.

I think the codebase is still on codeigniter 4.4.5 so if you install 4.4.7 there could be some breaking changes. I have been making th micro-changes in the code as they release new versions of CI4, but 4.4.7 is pretty new, so I haven't had a chance to go through their migration guide to see what I need to change.

odiea commented 8 months ago

If I stay with 4.4.5 it does not build possibly due to other dependencies. Yes the namecase works correctly with this build

odiea commented 8 months ago

I guess that it must have been the php version because Composer is working fine with the current ospos composer lock. Learn something new every day. I tried it again on the current ci4-branch download

objecttothis commented 8 months ago

What version of PHP fails for you. I tried it on 7.4.33 and couldn't get it to error.

odiea commented 8 months ago

I changed it last night maybe 7.2?

objecttothis commented 8 months ago

Do you mean 8.2? 7.2 isn't supported.

odiea commented 8 months ago

Yes I know. When I switched over to the newest version of Wamp it never update to my current version just the older version that it stored in my old wamp folder.

odiea commented 7 months ago

use function \Tamtamchik\NameCase\str_name_case; now works after rebuilding my copy

objecttothis commented 7 months ago

Super.