symphonists / search_index

Search Index provides an easy way to implement high performance fulltext searching on your Symphony site
32 stars 21 forks source link

Symphony Warning: Use of undefined constant DS_FILTER_AND #63

Open cylkee opened 4 years ago

cylkee commented 4 years ago

Steps to reproduce:

Create or save an entry in a Section that is configured in Search Index's indexes.

If I roll back to PHP 7.1 all is well.

Symphony Warning: Use of undefined constant DS_FILTER_AND - assumed 'DS_FILTER_AND' (this will throw an Error in a future version of PHP)

An error occurred in /path-redacted/extensions/search_index/lib/class.search_index.php around line 81

76    if((is_array($filter) && empty($filter)) || trim($filter) == '') continue;
77    
78    if(!is_array($filter)){
79        $filter_type = DataSource::__determineFilterType($filter);
80
81        $value = preg_split('/'.($filter_type == DS_FILTER_AND ? '\+' : '(?<!\\\\),').'\s*/', $filter, -1, PREG_SPLIT_NO_EMPTY);            
82        $value = array_map('trim', $value);
83
84        $value = array_map(array('Datasource', 'removeEscapedCommas'), $value);
85    } 

Backtrace

[/path-redacted/extensions/search_index/lib/class.search_index.php:81]
    GenericErrorHandler::handler();
[/path-redacted/extensions/search_index/extension.driver.php:232]
    SearchIndex::indexEntry();
[/path-redacted/symphony/lib/toolkit/class.extensionmanager.php:702]
    Extension_Search_Index->indexEntry();
[/path-redacted/symphony/content/content.publish.php:1159]
    ExtensionManager::notifyMembers();
[/path-redacted/symphony/content/content.publish.php:356]
    contentPublish->__actionNew();
[/path-redacted/symphony/content/content.publish.php:332]
    contentPublish->__switchboard();
[/path-redacted/symphony/lib/toolkit/class.administrationpage.php:465]
    contentPublish->action();
[/path-redacted/symphony/content/content.publish.php:327]
    AdministrationPage->build();
[/path-redacted/symphony/lib/core/class.administration.php:205]
    contentPublish->build();
[/path-redacted/symphony/lib/core/class.administration.php:483]
    Administration->__buildPage();
[/path-redacted/symphony/lib/boot/func.utilities.php:253]
    Administration->display();
[/path-redacted/symphony/lib/boot/func.utilities.php:235]
    symphony_launcher();
[/path-redacted/index.php:19]
    symphony();

Database Query Log

[0.0004] SET character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8';
[0.0001] SET CHARACTER SET 'utf8';
[0.0001] SET time_zone = '+00:00';
[0.0007] SELECT SQL_CACHE t1.name, t2.page, t2.delegate, t2.callback FROM `sym_extensions` as t1 INNER JOIN `sym_extensions_delegates` as t2 ON t1.id = t2.extension_id WHERE t1.status = 'enabled' ORDER BY t2.delegate, t1.name;
[0.0002] SELECT SQL_CACHE `session_data` FROM `sym_sessions` WHERE `session` = 'session-redacted' LIMIT 1;
[0.0002] SELECT SQL_CACHE a.* FROM `sym_authors` AS `a` WHERE `username` = 'user-redacted' ORDER BY a.id ASC LIMIT 1;
[0.0002] UPDATE sym_authors SET `last_seen` = '2020-03-02 16:31:40' WHERE `id` = 1;
[0.0002] SELECT SQL_CACHE `name` FROM `sym_extensions` WHERE `status` = 'enabled';
[0.0002] SELECT SQL_CACHE * FROM `sym_extensions`;
[0.0002] SELECT SQL_CACHE `id` FROM `sym_sections` WHERE `handle` = 'general' LIMIT 1;
[0.0003] SELECT SQL_CACHE * FROM `sym_sections_association` AS `sa`, `sym_sections` AS `s` WHERE `sa`.`child_section_id` = 2 AND `s`.`id` = `sa`.`parent_section_id` ORDER BY `s`.`sortorder` ASC;
[0.0003] SELECT SQL_CACHE * FROM `sym_sections_association` AS `sa`, `sym_sections` AS `s` WHERE `sa`.`parent_section_id` = 2 AND `s`.`id` = `sa`.`child_section_id` ORDER BY `s`.`sortorder` ASC;
[0.0003] SELECT SQL_CACHE `s`.* FROM `sym_sections` AS `s` ORDER BY `s`.`sortorder` asc;
[0.0002] SELECT SQL_CACHE `id` FROM `sym_sections` WHERE `handle` = 'general' LIMIT 1;
[0.0002] SELECT SQL_CACHE `id` FROM `sym_sections` WHERE `handle` = 'general' LIMIT 1;
[0.0002] SELECT SQL_CACHE `id`, `element_name`, `type`, `location` FROM `sym_fields` WHERE `parent_section` = 2 ORDER BY `sortorder` ASC;
[0.0002] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`id` IN(18);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_input` WHERE `field_id` IN (18);
[0.0001] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`id` IN(19);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_textarea` WHERE `field_id` IN (19);
[0.0002] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`id` IN(21);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_select` WHERE `field_id` IN (21);
[0.0002] SELECT SQL_CACHE CASE hide_association WHEN "no" THEN "yes" ELSE "no" END as show_association FROM `sym_sections_association` WHERE `child_section_field_id` = 21;
[0.0002] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`id` IN(20);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_upload` WHERE `field_id` IN (20);
[0.0001] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`id` IN(180);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_input` WHERE `field_id` IN (180);
[0.0001] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`id` IN(22);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_input` WHERE `field_id` IN (22);
[0.0001] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`id` IN(172);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_textarea` WHERE `field_id` IN (172);
[0.0001] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`id` IN(178);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_checkbox` WHERE `field_id` IN (178);
[0.0002] INSERT INTO `sym_entries` (`author_id`, `section_id`, `creation_date`, `modification_date`, `modification_date_gmt`, `creation_date_gmt`, `modification_author_id`) VALUES ('1', '2', '2020-03-02 16:31:40', '2020-03-02 16:31:40', '2020-03-02 16:31:40', '2020-03-02 16:31:40', '1');
[0.0002] SELECT SQL_CACHE `id`, `element_name`, `type`, `location` FROM `sym_fields` WHERE `parent_section` = 2 ORDER BY `sortorder` ASC;
[0.0002] SELECT SQL_CACHE `file`, `mimetype`, `size`, `meta` FROM `sym_entries_data_20` WHERE `entry_id` = 3796 LIMIT 1;
[0.0002] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`parent_section` = '2' ORDER BY t1.`sortorder` ASC;
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_input` WHERE `field_id` IN (18,180,22);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_textarea` WHERE `field_id` IN (19,172);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_select` WHERE `field_id` IN (21);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_upload` WHERE `field_id` IN (20);
[0.0001] SELECT SQL_CACHE * FROM `sym_fields_checkbox` WHERE `field_id` IN (178);
[0.0001] UPDATE sym_entries SET `modification_author_id` = '1', `modification_date` = '2020-03-02 16:31:40', `modification_date_gmt` = '2020-03-02 16:31:40' WHERE `id` = 3796;
[0.0005] SHOW TABLES LIKE 'sym_entries_data_18';
[0.0001] LOCK TABLES `sym_entries_data_18` WRITE;
[0.0001] DELETE FROM `sym_entries_data_18` WHERE `entry_id` = 3796;
[0.0001] INSERT INTO `sym_entries_data_18` (`entry_id`, `value`, `handle`) VALUES ('3796', 'test', 'test');
[0.0001] UNLOCK TABLES;
[0.0004] SHOW TABLES LIKE 'sym_entries_data_19';
[0.0001] LOCK TABLES `sym_entries_data_19` WRITE;
[0.0001] DELETE FROM `sym_entries_data_19` WHERE `entry_id` = 3796;
[0.0002] INSERT INTO `sym_entries_data_19` (`entry_id`, `value`, `value_formatted`) VALUES ('3796', 'test', '<p>test</p>\n');
[0.0001] UNLOCK TABLES;
[0.0004] SHOW TABLES LIKE 'sym_entries_data_21';
[0.0001] LOCK TABLES `sym_entries_data_21` WRITE;
[0.0001] DELETE FROM `sym_entries_data_21` WHERE `entry_id` = 3796;
[0.0001] INSERT INTO `sym_entries_data_21` (`entry_id`, `value`, `handle`) VALUES ('3796', 'White', 'white');
[0.0001] UNLOCK TABLES;
[0.0004] SHOW TABLES LIKE 'sym_entries_data_20';
[0.0001] LOCK TABLES `sym_entries_data_20` WRITE;
[0.0001] DELETE FROM `sym_entries_data_20` WHERE `entry_id` = 3796;
[0.0001] UNLOCK TABLES;
[0.0004] SHOW TABLES LIKE 'sym_entries_data_180';
[0.0001] LOCK TABLES `sym_entries_data_180` WRITE;
[0.0001] DELETE FROM `sym_entries_data_180` WHERE `entry_id` = 3796;
[0.0001] UNLOCK TABLES;
[0.0004] SHOW TABLES LIKE 'sym_entries_data_22';
[0.0001] LOCK TABLES `sym_entries_data_22` WRITE;
[0.0001] DELETE FROM `sym_entries_data_22` WHERE `entry_id` = 3796;
[0.0001] UNLOCK TABLES;
[0.0004] SHOW TABLES LIKE 'sym_entries_data_172';
[0.0001] LOCK TABLES `sym_entries_data_172` WRITE;
[0.0001] DELETE FROM `sym_entries_data_172` WHERE `entry_id` = 3796;
[0.0001] UNLOCK TABLES;
[0.0004] SHOW TABLES LIKE 'sym_entries_data_178';
[0.0001] LOCK TABLES `sym_entries_data_178` WRITE;
[0.0001] DELETE FROM `sym_entries_data_178` WHERE `entry_id` = 3796;
[0.0001] INSERT INTO `sym_entries_data_178` (`entry_id`, `value`) VALUES ('3796', 'no');
[0.0001] UNLOCK TABLES;
[0.0002] SELECT SQL_CACHE t1.* FROM sym_fields AS `t1` WHERE 1 AND t1.`type` = 'reflection' AND t1.`parent_section` = '2' ORDER BY t1.`sortorder` ASC; 
cylkee commented 4 years ago

Submitted PR #64 after I discovered the DS_FILTER_AND constant was replaced in Sym 2.4+. Tested above steps in PHP 7.3 okay.