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

Implements __serialize and __unserialize #255

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bastienho
Copy link
Contributor

required for Serializable since PHP 8.1.0

https://www.php.net/manual/en/class.serializable.php

required for Serializable since PHP 8.1.0
@civibot civibot bot added the master label Oct 13, 2023
@eileenmcnaughton
Copy link
Owner

@bastienho can we just call the existing serialize & unserialize functions - that clean up function for class removes some stuff that doesnt serialize well/ blows out the size / may have sensitive info

@bastienho
Copy link
Contributor Author

@eileenmcnaughton this was my first thought, but serialize() returns a string and _serialize() HAVE TO return an array.

@eileenmcnaughton
Copy link
Owner

@bastienho ok - so we should probably do the same things the cleanup function does in that function too - slightly differently as we would perhaps take get_object_vars & filter stuff out

    if (\Civi::settings()->get('omnipay_developer_mode') && !empty($this->history)) {
      $this->logHttpTraffic(FALSE);
    }
    $this->history = [];
    $this->client = NULL;
    $this->lock = NULL;
    $this->guzzleClient = NULL;
    if ($isIncludeGateWay) {
      $this->gateway = NULL;
    }

@bastienho
Copy link
Contributor Author

I Agree

Should I implement this code in my PR ?

@eileenmcnaughton
Copy link
Owner

@bastienho that would be great

@bastienho
Copy link
Contributor Author

After some tests, we can keep the same behaviour in both functions.

So I suggest to implement the cleanup function in __serialize() and call it in serialize()

@bastienho
Copy link
Contributor Author

@eileenmcnaughton, based on your thougths, I've revamped by PR.

Specially, the implementation of cleanupObjectForSerialization() is not insignificant.

@eileenmcnaughton
Copy link
Owner

thanks @bastienho I'll take a look - I've tagged a release in the meantime to get the regression fix out

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

Successfully merging this pull request may close these issues.

None yet

2 participants