Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-359

Specified, but empty CLI Options --option= causes Notice undefined offset: 0 [Test case for CliController included]

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0-ALPHA4
    • Fix Version/s: 2.0-BETA1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      PHP 5.3.1

      Description

      Specified, but empty CLI Options --option= cause a Notice (undefined offset: 0)

      This problem also exists in trunk.

      What I ran:

      naderman@Chaumont:~/projects/doctrine/Doctrine-trunk/tools/sandbox$ ./doctrine Orm:generate-proxies --class-dir=
      

      Expected output:

      Doctrine Command Line Interface
      
      No classes to process.
      

      Actual output:

      PHP Notice:  Undefined offset: 0 in /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php on line 230
      PHP Stack trace:
      PHP   1. {main}() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:0
      PHP   2. include() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:4
      PHP   3. Doctrine\Common\Cli\CliController->run() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine.php:12
      PHP   4. Doctrine\Common\Cli\CliController->_processArguments() /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php:127
      Doctrine Command Line Interface
      
      Orm:generate-proxies => The supplied configuration uses the annotation metadata driver. The 'class-dir' argument is required for this driver.
      

      I decided to write a patch and a test case for the issue but it turns out there aren't any tests for CliController, so I added some. You can find the result attached. Not sure if you can still call this "unit" test but it looks to me like the best you can currently do and should work quite well.

      I also came across another problem in CliController where it incorrectly refers to AbstractPrinter, rather than Printers\AbstractPrinter which is now included in the patch for the original bug.

      I'm not sure what your guideline on @author tags is, I added them to the test case and the TaskMock class now, but feel free to remove them if you like. Some of Doctrine's files seem to have them and some not.

      1. cli_controller_tests.diff
        7 kB
        Nils Adermann
      2. empty_option_bug.diff
        1 kB
        Nils Adermann

        Issue Links

          Activity

          Nils Adermann created issue -
          Nils Adermann made changes -
          Field Original Value New Value
          Description Specified, but empty CLI Options --option= cause a Notice (undefined offset: 0)

          This problem also exists in trunk.

          What I ran:
          {code}
          naderman@Chaumont:~/projects/doctrine/Doctrine-trunk/tools/sandbox$ ./doctrine Orm:generate-proxies --class-dir=
          {code}

          Expected output:
          {code}
          Doctrine Command Line Interface

          No classes to process.
          {code}

          Actual output:
          {code}
          PHP Notice: Undefined offset: 0 in /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php on line 230
          PHP Stack trace:
          PHP 1. {main}() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:0
          PHP 2. include() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:4
          PHP 3. Doctrine\Common\Cli\CliController->run() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine.php:12
          PHP 4. Doctrine\Common\Cli\CliController->_processArguments() /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php:127
          Doctrine Command Line Interface

          Orm:generate-proxies => The supplied configuration uses the annotation metadata driver. The 'class-dir' argument is required for this driver.
          {code}

          Specified, but empty CLI Options --option= cause a Notice (undefined offset: 0)

          This problem also exists in trunk.

          What I ran:
          {code}
          naderman@Chaumont:~/projects/doctrine/Doctrine-trunk/tools/sandbox$ ./doctrine Orm:generate-proxies --class-dir=
          {code}

          Expected output:
          {code}
          Doctrine Command Line Interface

          No classes to process.
          {code}

          Actual output:
          {code}
          PHP Notice: Undefined offset: 0 in /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php on line 230
          PHP Stack trace:
          PHP 1. {main}() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:0
          PHP 2. include() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine:4
          PHP 3. Doctrine\Common\Cli\CliController->run() /home/naderman/projects/doctrine/Doctrine-trunk/tools/sandbox/doctrine.php:12
          PHP 4. Doctrine\Common\Cli\CliController->_processArguments() /home/naderman/projects/doctrine/Doctrine-trunk/lib/Doctrine/Common/Cli/CliController.php:127
          Doctrine Command Line Interface

          Orm:generate-proxies => The supplied configuration uses the annotation metadata driver. The 'class-dir' argument is required for this driver.
          {code}

          I decided to write a patch and a test case for the issue but it turns out there aren't any tests for CliController, so I added some. You can find the result attached. Not sure if you can still call this "unit" test but it looks to me like the best you can currently do and should work quite well.

          I also came across another problem in CliController where it incorrectly refers to AbstractPrinter, rather than Printers\AbstractPrinter which is now included in the patch for the original bug.

          I'm not sure what your guideline on @author tags is, I added them to the test case and the TaskMock class now, but feel free to remove them if you like. Some of Doctrine's files seem to have them and some not.
          Roman S. Borschel made changes -
          Assignee Roman S. Borschel [ romanb ] Guilherme Blanco [ guilhermeblanco ]
          Roman S. Borschel made changes -
          Link This issue relates to DDC-222 [ DDC-222 ]
          Roman S. Borschel made changes -
          Fix Version/s 2.0-BETA2 [ 10050 ]
          Jonathan H. Wage made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Guilherme Blanco [ guilhermeblanco ] Jonathan H. Wage [ jwage ]
          Fix Version/s 2.0-BETA1 [ 10030 ]
          Fix Version/s 2.0-BETA2 [ 10050 ]
          Resolution Fixed [ 1 ]
          Roman S. Borschel made changes -
          Component/s ORM [ 10012 ]
          Component/s Common [ 10010 ]
          Benjamin Eberlei made changes -
          Workflow jira [ 10929 ] jira-feedback [ 14288 ]
          Benjamin Eberlei made changes -
          Workflow jira-feedback [ 14288 ] jira-feedback2 [ 16152 ]
          Benjamin Eberlei made changes -
          Workflow jira-feedback2 [ 16152 ] jira-feedback3 [ 18405 ]

            People

            • Assignee:
              Jonathan H. Wage
              Reporter:
              Nils Adermann
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: