3

I have a project that is using Views PHP, and I'd like to figure out which views are using PHP from this module. This will help me determine if I can easily remove the dependency on the module.

Is there a query or something else I can use to figure out what views are using this module?

3 Answers 3

1

Using the PHP filter in the fields should require you to use <?php ?> tags as part of the content.

The views data (unless its been exported with features) will sit inside the cache_views table in your DB, so you should be able to reliably find views using PHP filter by searching like so:

SELECT * FROM cache_views WHERE data LIKE '%<?php%';

There is probably a more sophisticated way of finding this.. but hopefully its a good start!

1
  • This is a cache, so data is not guaranteed to be there. For example, if the cache was just cleared, it will be empty.
    – mbomb007
    Commented Aug 2, 2019 at 14:52
0

Searching cache_views as this answer suggested is a partial solution that helps, but a full solution will include views that are not cached.

In order to do this, you can export views to code (e.g. using the Features module), and search the views for 'php' or php to find Global: PHP fields and sort criteria.

0

Searching the views table directly seems to be best approach:

SELECT
  v.vid,
  v.name,
  d.display_title
FROM
  views_display d
JOIN
  views_view v
USING
  (vid)
WHERE
  d.display_options LIKE '%<?php%'
ORDER BY v.name;
+-----+----------------------------------------------+-------------------------------+
| vid | name                                         | display_title                 |
+-----+----------------------------------------------+-------------------------------+
| ID  | VIEW MACHINE NAME                            | VIEW DISPLAY NAME             |
+-----+----------------------------------------------+-------------------------------+

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.