Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#7870 closed defect (bug) (invalid)

gears-manifest.php might be included on administration page, when it should not be

Reported by: impleri's profile impleri Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: gears reporter-feedback
Focuses: Cc:

Description

I am working on a very simple plugin to initialized all widgets in a given directory at once. However, I run across the following error when I activate it:
Fatal error: Cannot redeclare () (previously declared in /path/to/wp-includes/l10n.php:116) in /path/to/wp-admin/gears-manifest.php on line 6
It seems totally unrelated to my plugin (which displays no text whatsoever anywhere), which is why I am reporting it here. And, yes, this did occur once on another plugin's activation, but that one worked on the second try.

Change History (5)

#1 @darkdragon
15 years ago

  • Component changed from Optimization to Administration
  • Keywords reporter-feedback added; plugin activate l10n redeclare removed
  • Summary changed from Plugin Activation to gears-manifest.php might be included on administration page, when it should not be

Can you perhaps install XDebug and submit a stack trace? The file /wp-admin/gears-manifest.php should not be included in any WordPress page. It is self contained, which is why it has a definition for __(). This will be closed as invalid, if no further information is given.

#2 @darkdragon
15 years ago

  • Milestone changed from 2.7 to 2.8

#3 @DD32
15 years ago

An example plugin which can cause the error to surface would be enough if you cant install XDebug too.

#4 @impleri
15 years ago

Here is my plugin which I am working on:

<?php
/*
Plugin Name: Widgets Directory
Plugin URI: http://impleri.net/
Description: Loads all widgets in the current directory
Version: 1.0
Author: impleri
Author URI: http://impleri.net/
*/

$me = basename(__FILE__);
$here = dirname($me);

// make a directory object and iterate through its contents
function _load_the_modules($where)
{
        global $me;
        static $files=array();
        static $done = false;

        if($done)
        {
                return $files;
        }
        $done = true;

        $dir = dir($where);
        while($it = $dir->read())
        {
                if (($it != $me) && ($it != '.') && ($it != '..'))
                {
                        include($dir->path . '/' . $it);
                        $files[] = $it;
                }
        }
        $dir->close();

        // put all included files into a string
        $files = (empty($files)) ? 'None' : implode(', ', $files);

        return $files;
}

_load_the_modules($here);
?>

The file is located in a subdirectory under plugins (currently "widgets") with a number of widgets that work fine one their own (I just hate having to activate/deactivate 12 widgets when it can be a single plugin instead).
The other plugin which threw this error once (then mysteriously worked) is the Organize Series plugin.

#5 @DD32
15 years ago

  • Milestone 2.8 deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 2.6.1 deleted

For a start, That should be being run on an activation hook rather than in the global context, have a look at register_activation_hook()

Secondly, The reason for the errors are because you're using the wrong pathname, and are instead, including every file in /wp-admin/. (Hint: dirname(basename(FILE)) == '.')

Note: See TracTickets for help on using tickets.