xoops forums

Forum Index


Board index » All Posts




geekwright

Quite a regular
Posted on: 2019/12/13 1:53
geekwright
geekwright (Show more)
Quite a regular
Posts: 283
Since: 2010/10/15
#11

Re: Really NOT a stupid php / sql problem

This is an interesting problem. I am not an expect on oledrion, nor multi-thread PHP, but I can see the problem.

I started with the current master of the code here:
https://github.com/mambax7/oledrion.git

I did a quick scan of the code to see this:
grep -r pcntl *
class/
Gateways/Paypal/PaypalGateway.php:                    $pid pcntl_fork();


The takeaway from this is that there is only one 'pcntl' call in the code, and that is a fork. Nothing is waiting or watching for another fork, i.e. a pcntl_wait() call.

The botched mysqli connection is due to the fact that the process was forked, and the first fork that exits closes the database connection, leaving all other forks with a dead database object.

I am not sure how things ended up in this state. It is possible that the mysql and mysqli extensions behave differently in this circumstance. It is also possible something important is just missing.

It will take more research to get a handle on this and determine a plan of action. But, this is not a stupid problem. It is a very interesting problem.


alain01

Quite a regular
Posted on: 2019/12/13 0:52
alain01
alain01 (Show more)
Quite a regular
Posts: 308
Since: 2003/6/20
#12

Re: Which editor do you use ?

Quote:

geekwright wrote:
The first thing that will happen is the program will build an index of all the files in that directory. From that index, it will know in most cases all the functions, classes, and variables by type and signature. That enables auto-completion, parameter hints and easy access to documentation blocks.
Haaaaa, ok, thanks for this very usefull detail


geekwright

Quite a regular
Posted on: 2019/12/13 0:48
geekwright
geekwright (Show more)
Quite a regular
Posts: 283
Since: 2010/10/15
#13

Re: Which editor do you use ?

Quote:

alain01 wrote:
...
Is there any snippets, extension for XOOPS, for
PhPstorm and Visual Studio Code ? (didnt find)

(XMF words, xoops smarty) ?
...


With VSCode, you will want to install the PHP IntelliSense extension. (It will offer useful extensions when you open a file type for the first time,)

With both PHPStorm and VSCode (and Eclipse as I recall,) you will open a directory (i.e. your XoopsCore25 clone.) The first thing that will happen is the program will build an index of all the files in that directory. From that index, it will know in most cases all the functions, classes, and variables by type and signature. That enables auto-completion, parameter hints and easy access to documentation blocks. Those features are one of the reasons for making the move from simple editors to integrated development environments (IDE)


rossb

Just popping in
Posted on: 2019/12/12 22:01
rossb
rossb (Show more)
Just popping in
Posts: 54
Since: 2006/8/28
#14

How to create a new xoopsDB connection - from scratch

Hi;

I am using pcntl_fork and ran into this issue:
https://www.php.net/manual/en/function.pcntl-fork.php#70721
- no database connection in child, after parent exits.

so; I need a new db connection and am not sure how to do so properly.

something along lines of:
$xoopsDB = new XoopsMySQLDatabase();
$xoopsDB->connect();


just need to know the "proper way"

Anyone?
Thanks;
Bill


rossb

Just popping in
Posted on: 2019/12/12 21:56
rossb
rossb (Show more)
Just popping in
Posts: 54
Since: 2006/8/28
#15

Progress: Re: Really stupid php / sql problem

OK; starting to make sense.

Code forks to return to return paypal callback quickly (they spec 30 seconds max). Parent returns immediately, child (time consuming work) does db updates, sends confirmation emails, etc.

apparently, when the parent exits, db connection is closed after an indeterminate time. This causes a race condition where child may or may not have a db connection.

It is a known "issue":
https://www.php.net/manual/en/function.pcntl-fork.php#70721

Starting a new thread regarding how to get a new database connection within the child process.

I'll leave it to the reader to decide whether it is a stupid problem or coder...


rossb

Just popping in
Posted on: 2019/12/12 20:04
rossb
rossb (Show more)
Just popping in
Posts: 54
Since: 2006/8/28
#16

Re: Really stupid php / sql problem

Thanks; caught that one already. Not the issue.

Issue is: code is called out of site context by paypal callback.
...and, it forks to offload processing.

All attempts to use database fail: "MySQL server has gone away", even though db object exists.

have run outa theories....


zyspec

Module Developer
Posted on: 2019/12/12 17:26
zyspec
zyspec (Show more)
Module Developer
Posts: 1056
Since: 2004/9/21
#17

Re: Which editor do you use ?

I typically use Eclipse PDT.... I like it because:
  • there are versions for both Windows and Linux - so it's easy to switch between my various systems.
  • easy to create/modify coding styles (modified PSRxx, etc)
  • it's free
  • easily "jump-to" referenced functions
  • customized syntax highlighting for PHP, JS, XML, MySQL, etc
  • refactoring
  • GitHub integration (easy to pull/push/commit/etc)
  • Composer support
  • Good build/run tools
  • Eclipse community support
  • Bug/Issue tracking integration
  • code completion


  • The one drawback is lack of Smarty syntax support - there's a plugin for it but it's old & doesn't work well.

    I also use Notepad++ for a quick editor when needed. PHPStorm is a good product too but I haven't found enough difference/advantage to it that would cause me to change from Eclipse (and pay the money).


    zyspec

    Module Developer
    Posted on: 2019/12/12 14:58
    zyspec
    zyspec (Show more)
    Module Developer
    Posts: 1056
    Since: 2004/9/21
    #18

    Re: Really stupid php / sql problem

    One thing is it appears that the print_r() in the getEmailsFromGroup() is missing the 'true' parameter in:
    file_put_contents(OLEDRION_GATEWAY_LOG_PATH"groupId: " print_r($groupId) . "n"FILE_APPEND LOCK_EX);


    should be:
    file_put_contents(OLEDRION_GATEWAY_LOG_PATH"groupId: " print_r($groupIdtrue) . "n"FILE_APPEND LOCK_EX);


    don't know if that's the only issue but looks like it should be corrected.


    alain01

    Quite a regular
    Posted on: 2019/12/12 14:20
    alain01
    alain01 (Show more)
    Quite a regular
    Posts: 308
    Since: 2003/6/20
    #19

    Re: Which editor do you use ?

    Ok, so
    i test both edidors this weekend.
    Is there any snippets, extension for XOOPS, for
    PhPstorm and Visual Studio Code ? (didnt find)

    (XMF words, xoops smarty) ?

    I think it's easy to create that from a duplicated template from other CMS and changing words keys...
    Right ?


    geekwright

    Quite a regular
    Posted on: 2019/12/12 14:08
    geekwright
    geekwright (Show more)
    Quite a regular
    Posts: 283
    Since: 2010/10/15
    #20

    Re: Where is the header links ?

    Some modules assign $xoops_module_header directly, but in general calls like these
    $GLOBALS['xoTheme']->addScript(...);
    $GLOBALS['xoTheme']->addStylesheet(...);
    $GLOBALS['xoTheme']->addMeta(...);

    are the preferred way to interact with it.



    TopTop
    « 1 (2) 3 4 5 ... 29258 »