When I try to export a newly created filter I get the following error message:
warning: preg_match_all() expects at least 3 parameters, 2 given in /Applications/xampp/xamppfiles/htdocs/drupal/sites/all/modules/customfilter/customfilter.export.inc on line 93.
The "Export data" textarea contains code but if I try to reimport this code another error occurs:
The import data is not valid import text.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | customfilter.export.inc_.patch | 504 bytes | acidtalks |
| #3 | customfilter.import.inc_.patch | 903 bytes | acidtalks |
Comments
Comment #1
avpadernoComment #2
avpadernoMay you report here the code that you see in the text area?
I have already resolved the issue caused by the wrong call to
preg_match_all(), which has been removed because not necessary; to understand if there is another issue I need to see the code reported in the text area.Thanks for your report.
Comment #3
acidtalks commentedFirst, here is the code for a simple filter I have exported:
The error message from line 93 occurs, because preg_match_all misses the $matches parameter. Here is a fix (see patch attached).
But this does not affect the generated export. It seems to be okay. The import fails, because the imported textarea is always empty. In customfilter.import.inc (line 29) the form parameter '#value' is set to an empty string. This should be '#default_value' (see patch).
If you have an empty database the import now works. But there is another problem if there are already some filters there. In this case the functions _customfilter_map_filter_id and _customfilter_map_rule_id don't work correct. I think because
should have a NOT-Operator:
Then there is at least a problem with the 'prid'. I think it should not be mapped. In my case the prid was '0' before the export and '5' after the import. This leads to a filter without rules. Correcting this to '0' helped.
Maybe you can have a quick look at the patches.
Comment #4
avpadernoThe first patch is not necessary. The way I used to calculate the number of rows was totally wrong; as I am saving the lines of code into an array, it's enough to count the number of items in the array, to know the number of code rows.
You are right; the IF-statement should verify if the array item is not already set, and set it in that case.
The prid field (which is the parent rule ID) needs to be mapped; only in the case it is 0 (which means "no parent rule") it should not mapped to a new value.
You are also right about "#value"; the code was meant to set "#default_value" ("#value" should never be set).
Thanks for the help given.
Comment #5
avpadernoI changed the code, and committed it in CVS.
As a rid cannot be equal to zero, I changed
_customfilter_map_rule_id()to simply return zero when the actual parameter it gets is zero.Thanks again for your help. If there is still something in the import/export code that needs to be changed, feel free to reopen this report.
Comment #6
avpadernoI was forgetting about the 6.x-1 branch that needs to be changed as well.
Comment #7
avpadernoComment #8
avpaderno