omise / omise-php

Omise PHP library
https://docs.opn.ooo
MIT License
67 stars 41 forks source link

The bug related to storing keys in a singleton pattern. #161

Open zhichao-poper opened 11 months ago

zhichao-poper commented 11 months ago

Code like this:

// keys A
$keys[] = [
        'omise_public' => 'pkey_test_A',
        'omise_secret' => 'skey_test_A',
];
// keys B
$keys[] = [
        'omise_public' => 'pkey_test_B',
        'omise_secret' => 'skey_test_B',
];
$omiseKey = $keys[0];
OmiseSchedule::retrieve('schd_test_A', $omiseKey['omise_public'], $omiseKey['omise_secret']);
$omiseKey = $keys[1];
OmiseSchedule::retrieve('schd_test_B', $omiseKey['omise_public'], $omiseKey['omise_secret']);

will get

OmiseNotFoundException

schedule schd_test_B was not found

schd_test_A from keys A

schd_test_B from keys B

The issue arises from OmiseSchedule utilizing the singleton pattern to store keys. Consequently, subsequent instances of OmiseSchedule are unable to utilize their own keys for data requests, instead using the keys stored from the previous instance of OmiseSchedule.

Please verify if this is a bug or an issue with my usage.

aashishgurung commented 11 months ago

@zhichao-poper Thanks for reaching out. We will look into this and let you know about our findings.