lairdshaw / fups

FUPS: Forum user-post scraper
GNU Affero General Public License v3.0
21 stars 9 forks source link

Serialization of 'CurlHandle' is not allowed #7

Closed malebuffy closed 1 year ago

malebuffy commented 1 year ago

Any idea why I get this error while it is scraping? For this instance it is at post 177 from 190, so don't really know why it worked for the first 177 posts. Second try stopped at 153 post.

Set $serialize_filename to "D:\xampp\php\fups\optionslist.txt.serialize.txt".
PHP Fatal error:  Uncaught Exception: Serialization of 'CurlHandle' is not allowed in D:\xampp\php\fups\classes\CFUPSBase.php:393
Stack trace:
#0 D:\xampp\php\fups\classes\CFUPSBase.php(393): serialize(Object(phpBBFUPS))
#1 D:\xampp\php\fups\classes\CFUPSBase.php(1504): FUPSBase->check_do_chain()
#2 D:\xampp\php\fups\fups.php(157): FUPSBase->run(true)
#3 {main}
  thrown in D:\xampp\php\fups\classes\CFUPSBase.php on line 393

Fatal error: Uncaught Exception: Serialization of 'CurlHandle' is not allowed in D:\xampp\php\fups\classes\CFUPSBase.php:393
Stack trace:
#0 D:\xampp\php\fups\classes\CFUPSBase.php(393): serialize(Object(phpBBFUPS))
#1 D:\xampp\php\fups\classes\CFUPSBase.php(1504): FUPSBase->check_do_chain()
#2 D:\xampp\php\fups\fups.php(157): FUPSBase->run(true)
#3 {main}
  thrown in D:\xampp\php\fups\classes\CFUPSBase.php on line 393
lairdshaw commented 1 year ago

From what I gather from those error messages, it seems that serialising resources (in this case the handle returned by curl_init()) now throws an exception whereas in older version(s) of PHP - the ones I developed FUPS with - it didn't.

Without testing, it seems that a solution could be to move this line:

https://github.com/lairdshaw/fups/blob/f69b41baca54cd5e83118bb90cfbaf733d1839aa/classes/CFUPSBase.php#L408

to just before (or after - doesn't really matter) this line:

https://github.com/lairdshaw/fups/blob/f69b41baca54cd5e83118bb90cfbaf733d1839aa/classes/CFUPSBase.php#L389

And to add after it this line:

            $this->ch = null;

If that doesn't work, then please let me know, otherwise I'll commit it as the fix.

Also, if you'd like more of a backgrounder on this ("chaining"), then just let me know and I'll oblige.

malebuffy commented 1 year ago

This worked! Thanks