Skip to content

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

@zhichao-poper

Description

@zhichao-poper

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions