Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2, 2.3.2, 2.4
    • Fix Version/s: 2.3.3
    • Component/s: Blog
    • Labels:
    • Testing Instructions:
      Hide

      Before testing
      [Test across supported DB drivers]

      • You need access to the database tables. You will be manually creating data and inserting it into the tables.

      Creating a blog entry with associations

      1. Go to [Settings ► Site administration ► Appearance ► Blog] and 'Enable blog associations'
      2. Go to a course or create on if you don't have one.
      3. Add the Blog Menu block.
      4. 'Add an entry about this course' (Fill out the form details). Save changes.

      Testing

      The idea here is to create some fake associations in the database to replicate orphaned blog associations. Another method is to check out a version of moodle before MDL-34318 was introduced and create blog entries with associations (see above).

      1. Check the xxx_post table. Observe what number the 'id' column is up to.
      2. Add entries to the xxx_blog_association table. Make sure to insert id numbers into the 'blogid' column that don't exist in the xxx_post table.
      3. Run the upgrade script. Alter the version number in the xxx_config table if you have already upgraded.
        Check the xxx_blog_association table and make sure that the orphaned entries have been deleted.
      Show
      Before testing [Test across supported DB drivers] You need access to the database tables. You will be manually creating data and inserting it into the tables. Creating a blog entry with associations Go to [Settings ► Site administration ► Appearance ► Blog] and 'Enable blog associations' Go to a course or create on if you don't have one. Add the Blog Menu block. 'Add an entry about this course' (Fill out the form details). Save changes. Testing The idea here is to create some fake associations in the database to replicate orphaned blog associations. Another method is to check out a version of moodle before MDL-34318 was introduced and create blog entries with associations (see above). Check the xxx_post table. Observe what number the 'id' column is up to. Add entries to the xxx_blog_association table. Make sure to insert id numbers into the 'blogid' column that don't exist in the xxx_post table. Run the upgrade script. Alter the version number in the xxx_config table if you have already upgraded. Check the xxx_blog_association table and make sure that the orphaned entries have been deleted.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-35265-master
    • Rank:
      43919

      Description

      MDL-34318 put in place a solution to delete blog associations when deleting a blog entry, but it doesn't remove old associations that might exist from deleting blog entries before the patch.

        Activity

        Hide
        Michael de Raadt added a comment -

        I've turned this into a sub-task as that reflects it is part of a greater issue.

        Show
        Michael de Raadt added a comment - I've turned this into a sub-task as that reflects it is part of a greater issue.
        Hide
        Ankit Agarwal added a comment -

        Hi Adrian,
        The patch looks good. Just a few minor things:-

        1. I suggest using $DB->sql_empty() instead of hardcoding NULL
        2. please confirm with the integrators about the version to be used, I think in master we need to update it to the current date and use .0x in stables
        3. Please add testing instructions to test it in all database, as we are doing some explosion here

        Rest looks awesome.
        Thanks

        Show
        Ankit Agarwal added a comment - Hi Adrian, The patch looks good. Just a few minor things:- I suggest using $DB->sql_empty() instead of hardcoding NULL please confirm with the integrators about the version to be used, I think in master we need to update it to the current date and use .0x in stables Please add testing instructions to test it in all database, as we are doing some explosion here Rest looks awesome. Thanks
        Hide
        Adrian Greeve added a comment -

        I had a talk with Ankit about $DB->sql_empty()

        Because I am doing a LEFT JOIN in the sql query it generates it's own blank cells. NULL has to be used. the $DB->sql_empty() function doesn't do this. The hope is that Oracle will read the self generated empty cells as null and proceed like normal databases do.

        I'll test it out first before pushing for integration.

        Show
        Adrian Greeve added a comment - I had a talk with Ankit about $DB->sql_empty() Because I am doing a LEFT JOIN in the sql query it generates it's own blank cells. NULL has to be used. the $DB->sql_empty() function doesn't do this. The hope is that Oracle will read the self generated empty cells as null and proceed like normal databases do. I'll test it out first before pushing for integration.
        Hide
        Adrian Greeve added a comment -

        I tested the sql query in Oracle and it works fine.

        Submitting for integration.

        Show
        Adrian Greeve added a comment - I tested the sql query in Oracle and it works fine. Submitting for integration.
        Hide
        Aparup Banerjee added a comment -

        i'm guessing this needs to be backported?

        Show
        Aparup Banerjee added a comment - i'm guessing this needs to be backported?
        Hide
        Aparup Banerjee added a comment -

        Thanks, integrated into master and 23 only.

        ps: 22 seemed to far and halfway i saw that this wasn't really reported from out there.

        Show
        Aparup Banerjee added a comment - Thanks, integrated into master and 23 only. ps: 22 seemed to far and halfway i saw that this wasn't really reported from out there.
        Hide
        Rajesh Taneja added a comment -

        Thanks Adrian,
        Works as expected, all orphan associations are removed.

        FYI:
        Any duplicate association will remain for valid blog. This will never happen in practice so ignoring it.

        Show
        Rajesh Taneja added a comment - Thanks Adrian, Works as expected, all orphan associations are removed. FYI: Any duplicate association will remain for valid blog. This will never happen in practice so ignoring it.
        Hide
        Aparup Banerjee added a comment -

        Your issue has dug up some gold.
        It works great i've been told.
        Go forth, be brave, be bold.

        yay! "All your thoughts are belong to everyone."

        Thanks and ciao!

        Show
        Aparup Banerjee added a comment - Your issue has dug up some gold. It works great i've been told. Go forth, be brave, be bold. yay! "All your thoughts are belong to everyone." Thanks and ciao!

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: