October: Class name resolution usage breaks script parser script.

Created on 2 Mar 2019  Â·  6Comments  Â·  Source: octobercms/october

  • OctoberCMS Build: 446
  • PHP Version: 7.2.15

    Description:

The October\Rain\Database\Updater.php causes an issue with migrations if a second 'class' keyword is present in the file that is being parsed, usually the class name resolution keyword.

E.g.

ClassName::class

Steps To Reproduce:

Created a new plugin or any new migration file. Use class name resolution keyword.
Concrete example:

class AddFeaturedColumnToPostsTable extends Migration
{

    public function __construct()
    {
        if (!class_exists(Post::class)) {
            return;
        }
    }
}

So here we have 2 class keyword occurrences and it will break if it finds more than one.

The migration attempt breaks with the error message:

[ErrorException]                
  Uninitialized string offset: 1 

The code breaks because it doesn't account for more than one class keyword occurrence in the parsed file tokens.

The issue seems to be in this file: October\Rain\Database\Updater.php

Completed Bug

All 6 comments

@iulianwebdev are you able to submit a PR to fix it?

Yes, I'll try and fix the problem and submit a PR today.

On Sun, Mar 3, 2019 at 3:59 PM Luke Towers notifications@github.com wrote:

@iulianwebdev https://github.com/iulianwebdev are you able to submit a
PR to fix it?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/octobercms/october/issues/4176#issuecomment-469036180,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ANoVg1lb3yOec1hzabvwAK39tVz_z8tUks5vS_FLgaJpZM4bap4c
.

I can confirm this issue is still present in latest build.

For example, if you use the resolve method to get some container binding in you migration, it will break immediately with Uninitialized string offset: 1.

$connection = resolve(ConnectionInterface::class);
$connection->beginTransaction();
// ...

@adrenth can you look into it more and submit a PR to fix it?

@LukeTowers there is already pending pr: https://github.com/octobercms/library/pull/384

Was this page helpful?
0 / 5 - 0 ratings

Related issues

m49n picture m49n  Â·  3Comments

dunets picture dunets  Â·  3Comments

atrauzzi picture atrauzzi  Â·  3Comments

LukeTowers picture LukeTowers  Â·  3Comments

Flynsarmy picture Flynsarmy  Â·  3Comments