1
Mamba
XOOPS Plugin for PhpStorm 1.0 Alpha 4 Released

Resized Image


XOOPS Support Plugin for PhpStorm: Alpha 4 is here

XOOPS Support Plugin brings XOOPS CMS knowledge into PhpStorm and IntelliJ IDEA: it finds the mistakes that break XOOPS modules and fixes most of them with one Alt+Enter. It covers XOOPS 2.5, 2.7, and the upcoming XOOPS 2.8 and 4.0, for Core and module development.

Every quick-fix is tested against whole-file fixtures and applied twice to prove it is idempotent. Before release the full set was run on 224 real modules: 46,000 findings and 10,000 files rewritten, with no entry point blocked and no parse error.

52 inspections with quick-fixes

  1. Database: migrates queryF() and quoteString(), picks query() or exec() from the SQL, adds result-set guards that keep the function's failure contract, and flags ORDER BY or request-in-SQL injection.
  2. Security: Xmf\Request instead of raw superglobals, missing CSRF checks, unserialize() without allowed_classes, dynamic code, weak tokens, path containment and attribute escaping.
  3. Bootstrap and structure: direct-access guards that never block an entry point, double xoops_cp_header(), form loader, admin menu autoload and file headers.
  4. Templates and Smarty: template registration in both directions, <{ }> delimiters, $smarty.get escaping and the Smarty 5 API.
  5. Language files, installer SQL and deprecated core API (the 2.7.4 deprecation list).


Version-aware fixes

The plugin reads your tree's include/version.php and only offers rewrites your core supports. Older cores get compatible code instead of an API they don't have.

Productivity

  1. New → XOOPS Module… scaffolds a legacy or hybrid module (Helper, PSR-4 autoloader, Xmf admin) whose output passes every inspection.
  2. Completion, Ctrl+B and Find Usages for language constants (_MD_*, _MI_*, _AM_*…), including in Smarty templates.
  3. Live templates for common XOOPS code.
  4. A project tool window that gives an overview of your modules.

Getting started

Install the plugin and open a XOOPS project. Detection is automatic. You can set the Core Version and other options under Settings → Languages & Frameworks → XOOPS Support, and the inspections are listed under Settings → Editor → Inspections → XOOPS. The plugin installs and updates without an IDE restart.

Source, documentation and issues on GitHub
Support XOOPS => DONATE
Use 2.7.x | Docs | Modules | Bugs

2
goffy
Re: XOOPS Plugin for PhpStorm 1.0 Alpha 4 Released
  • Today 7:48

  • goffy

  • Just can't stay away

  • Posts: 559

  • Since: 2010/12/27


Thank you, I will test it again :)

3
Mamba
Re: XOOPS Plugin for PhpStorm 1.0 Alpha 4 Released

Let me know if the plugin is of any help to you, and what extra features would be useful.
Also, if you find any bugs.

I just found couple, so Alpha 5 is coming soon
Support XOOPS => DONATE
Use 2.7.x | Docs | Modules | Bugs

4
goffy
Re: XOOPS Plugin for PhpStorm 1.0 Alpha 4 Released
  • Today 18:16

  • goffy

  • Just can't stay away

  • Posts: 559

  • Since: 2010/12/27


hi
tested , works fine, found again some issues in my code.

But only one thing I do not understand:
"A CREATE TABLE in sql/mysql.sql that no update path mentions is never created for a module that is already installed. If a released version shipped without the table, sites updating from it fail with error 1146 on first use. Whether such a version exists cannot be told from the tree, and a table as old as the module needs no update path, so this is a weak note."

I do not understand what this means. Can someone explain for dummies?

5
Mamba
Re: XOOPS Plugin for PhpStorm 1.0 Alpha 4 Released

XOOPS runs sql/mysql.sql only once, on a fresh install. When a site updates a module that's already installed, that file is never run again. Any new table has to be created by the module's update code instead, usually in onupdate.php or include/update.php.

The problem the inspection guards against:

1. Version 1.0 of a module ships with tables a and b.
2. In version 1.1 you add table c to mysql.sql.
3. New sites that install 1.1 get a, b and c.
4. Sites updating from 1.0 to 1.1 still have only a and b, because mysql.sql isn't run on update.
5. The first page that uses c fails with MySQL error 1146: Table doesn't exist.

The inspection looks at each CREATE TABLE in mysql.sql and checks whether the update code mentions that table anywhere. If it doesn't, you get this note: "updating sites might never get this table."

Why it's only a weak note:

The plugin can't tell whether the table is new or old. It only sees the current code, not which tables earlier releases shipped.

- If the table has existed since the module's first release, every site already has it and nothing needs to be done. The note is harmless.
- If the table was added in a later version, updating sites are missing it, and you need to add creation code to the update script.

Only the author knows which case applies, so the plugin reports it quietly instead of calling it an error.

What to do when you see it:

- If the table was there from the start, ignore it.
- If you added the table after a release, make the update script create it when it's missing. For example, use CREATE TABLE IF NOT EXISTS in your update callback, or use XMF's migrate or table-loading tools.


Here are two good examples, each adds a table in sql/mysql.sql for new installs, and its update script also creates that table for sites updating from an older version.

1. xnewsletter: modules/xnewsletter/include/onupdate.php

This is the clearest one, because each release that added a table has its own step:
function xoops_module_update_xnewsletter(XoopsObject $xoopsModule, $oldversion = null)
{
    ...
   if (
$oldversion < 103) { ... }   // calls xoops_module_update_xnewsletter_103()
    
if ($oldversion < 104) { ... }   // calls xoops_module_update_xnewsletter_104()
    
if ($oldversion < 130) { ... }   // calls xoops_module_update_xnewsletter_130()

- Version 1.03 added the import table. xoops_module_update_xnewsletter_103() runs CREATE TABLE mod_xnewsletter_import (line 332).
- Version 1.04 added the task table. ..._104() runs CREATE TABLE mod_xnewsletter_task (line 296).
- Version 1.30 added templates. ..._130() runs CREATE TABLE xnewsletter_template (line 193).

A site still on 1.02 gets all three tables when it updates. A fresh install gets them straight from mysql.sql.

2. news: modules/news/include/onupdate.php

if ($previousVersion < 174) {
    ...
    } elseif (!
Utility::existTable($xoopsDB->prefix('news_stories_files'))) {
        
// 1) Create, if it does not exists, the stories_files table
        
$sql = 'CREATE TABLE ' . $xoopsDB->prefix('news_stories_files') . " (
It does the same for news_stories_votedata at line 173. It checks whether the table exists first, so running it twice does no harm.

In both modules, the table appears in two places, in sql/mysql.sql for new installs and in the update script for sites that already have the module. If you add a table to mysql.sql and don't add the matching block to the update script, every site that updates will hit "Table doesn't exist" (error 1146). That's exactly what the inspection warns about. For these tables the warning doesn't appear, because the update script mentions them.
Support XOOPS => DONATE
Use 2.7.x | Docs | Modules | Bugs