Forum

Thread tagged as: Error, Api, Runway

Categories and Scheduled Tasks

Hi there,

A little while a go I developed a Perch Scheduled Task, that has been working until I updated to Perch 2.8.18. The task loops through XML and creates collection items (and any categories it needs to).

It seems to fail on the catParentID method in PerchCategories_Category.php called from update_meta.

    $this->catParentID()

The main part of the script in question is as follows:

    //set category set/group id
    $categoryDetails = array('catID' => $catID);

    //instantiate single category
    $category = new PerchCategories_Category($categoryDetails);

    //set fields of category
    $catDynamicFields = array(
        "catDepth" => null,
        "desc" =>
            array(
                "raw" => "",
                "processed" => "",
            )
    );

    //more fields of category
    $data = array(
        'catTitle' => $title,
        'catSlug' => $catSlug,
        'catDisplayPath' => $title,
        'catDynamicFields' => PerchUtil::json_safe_encode($catDynamicFields)
    );

    //update the category
    $category->update($data);

I am also getting an apache error:

[Thu Dec 10 13:24:31 2015] [notice] child pid 16205 exit signal Segmentation fault (11)

When I run method_exists on catParentID, it returns false.

I've been looking at it for best part of today, trying to figure out where it's failing. Perhaps it's just a result of recent core changes. I wondered if you'd be able to shed any light on the matter.

Let me know if you need any additional information.

Thanks.

CDD Nation

CDD Nation 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

A seg fault can be hard to debug.

catParentID isn't a method - it's processed dynamically by a __call() magic method - so that's not surprising.

Do you get any debuggable output at all?

Hi Drew,

I see (catParentID)!

When I manually run the HTTP request, as I usually do for manual running of the scheduled tasks, it shows me (in chrome):

No data received ERR_EMPTY_RESPONSE

When having perch debug switched on and viewing /perch/core/settings/tasks/

It shows:


Debug Message SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=3 AND u.userHash='bdfce534e700c844be72469db7101e61' LIMIT 1 UPDATE perch2_users SET userHash='c0c2cb5fa63894243c4336821598e9c7' WHERE userID='3' SELECT p.privKey FROM perch2_user_privileges p SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=3 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID Adding: Forms SELECT collectionID, collectionKey, collectionEditRoles FROM perch2_collections WHERE collectionInAppMenu=1 ORDER BY collectionOrder ASC SELECT * FROM perch2_scheduled_tasks WHERE 1=1 ORDER BY taskStartTime DESC LIMIT 20 Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1548' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1547' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1546' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1545' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1544' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1543' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1542' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1541' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1540' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1539' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1538' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1537' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1536' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1535' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1534' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1533' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1532' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1531' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1530' Looking up missing property taskEndTime SELECT taskEndTime FROM perch2_scheduled_tasks WHERE taskID='1529' Queries: 27 Memory: 2.019

I've no idea whether that's helpful or not.

Thanks for the help, I'll let you know if I find anything else.

Cheers,

Quick update, it doesn't seem to be able to run the to_array method on line 35 of PerchBase.class.php, for whatever reason. That's as far as I can trace it.

}else{
    PerchUtil::debug('Looking up missing property ' . $method, 'notice');
    $array = $this->to_array();
    ...

Whether it's meant to be running this else block , in this context, I'm not sure.

Thanks,

Right! I've found Xdebug and it gives some more details:

Fatal error: Maximum function nesting level of '500' reached, aborting!

...PerchScheduledTasks->run() is called...

4   0.5048  5076904 import_jobs( )                              
    ../PerchScheduledTasks.class.php:80

5   0.6392  5454104 ImportApp->downloadJobs( )                              
    ../scheduled_tasks.php:134

6   2.4952  5468016 ImportApp->processExternalJobs( )                               
    ../ImportApp.php:68

7   2.4986  5479080 CustomCategories->get( )                                
    ../ImportApp.php:161

8   2.6024  5686400 PerchCategories_Category->update( )                             
    ../CustomCategories.php:65

9   2.6043  5741648 PerchCategories_Category->update_meta( )                                
    ../PerchCategories_Category.class.php:15

10  2.6043  5741864 catParentID ( )                             
    ../PerchCategories_Category.class.php:44

11  2.6043  5742048 PerchBase->__call( )                                
    ../PerchCategories_Category.class.php:44

12  2.6044  5743264 PerchCategories_Category->to_array( )                               
    ../PerchBase.class.php:36

13  2.6045  5745016 PerchCategories_Category->catDepth( )                               
    ../PerchCategories_Category.class.php:122

14  2.6045  5745184 catTreePosition ( )                             
    ../PerchCategories_Category.class.php:94

15  2.6045  5745368 PerchBase->__call( )                                
    ../PerchCategories_Category.class.php:94

16  2.6046  5746600 PerchCategories_Category->to_array( )                       
    ../PerchBase.class.php:36   

17  2.1007  5748808 PerchCategories_Category->catDepth( )                               
    ../PerchCategories_Category.class.php:122

18  2.1007  5748976 catTreePosition ( )                             
    ../PerchCategories_Category.class.php:94

19  2.1007  5749160 PerchBase->__call( )                                
    ../PerchCategories_Category.class.php:94

20  2.1008  5750392 PerchCategories_Category->to_array( )                           
    ../PerchBase.class.php:36   


...and so on for 500 rows, until it aborts.

Hope this helps.

Thanks,

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's running into an infinite loop. I'll get it fixed for 2.8.19.

The to_array() method is calling __call() which is calling to_array() ...

Drew McLellan

Drew McLellan 2638 points
Perch Support

2.8.19 is now available.

Thanks Drew,

All fixed!